Skip to content

[Linter]: Support for deprecated arguments#2630

Draft
gigalasr wants to merge 9 commits into
mainfrom
1870-deprecated-args-support
Draft

[Linter]: Support for deprecated arguments#2630
gigalasr wants to merge 9 commits into
mainfrom
1870-deprecated-args-support

Conversation

@gigalasr

@gigalasr gigalasr commented Jul 9, 2026

Copy link
Copy Markdown
Collaborator

closes #1870

TODO:

  • Support for ifValue for args
  • Support for Identifiers with package name

@gigalasr gigalasr self-assigned this Jul 9, 2026
Comment thread src/linter/rules/deprecated-functions.ts Outdated
@gigalasr

gigalasr commented Jul 9, 2026

Copy link
Copy Markdown
Collaborator Author

Questions:

  1. Should the linter rule return the node id and source range of the entire function, or just of the deprecated arg?
  2. How can I make this work with the new identifiers that are prefixed with the package name?

@EagleoutIce

Copy link
Copy Markdown
Member
1. Should the linter rule return the node id and source range of the entire function, or just of the deprecated arg?

Just for the argument please

2. How can I make this work with the new identifiers that are prefixed with the package name?

unsure what you mean here because the argument names cannot be namespaced? Could you please elaborate with an example?

@gigalasr

gigalasr commented Jul 9, 2026

Copy link
Copy Markdown
Collaborator Author
  1. Oki, thank you!
  2. In line 76 (https://github.com/flowr-analysis/flowr/pull/2630/changes#diff-08ba3901670b25d88a746877af089e407a93f5ec8a0b09db4b1bf47e1eb71c4aR76) I use the target from the CallTargetsEnrichment to index the whenArgs record. However, target can have names like deply:someFn, but the whenArgs record (currently) only contains names like someFn.

@EagleoutIce

Copy link
Copy Markdown
Member

Aah okay so you can use either Identifier::toQualified or also Identifier::matches (or match? not sure rn) to bridge the gap - is this what you needed?

@gigalasr

gigalasr commented Jul 9, 2026

Copy link
Copy Markdown
Collaborator Author

Sounds like it, I will try that! Thank you!

Comment thread src/linter/rules/deprecated-functions.ts Outdated
Comment thread src/linter/rules/deprecated-functions.ts Outdated
Comment thread src/linter/rules/deprecated-functions.ts

export interface DeprecatedFunctionsConfig extends MergeableRecord{
/** Functions to mark as deprecated */
fns: (string | DeprecatedFunctionInformation)[]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not Identifier?

}

export interface DeprecatedFunctionResultBase extends LintingResult {
function: BrandedIdentifier

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why just branded? please use the full Identifier here

Comment thread src/linter/rules/deprecated-functions.ts Outdated
return undefined;
}

const arg = vertex.args.find((arg, idx) =>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we have argument finders like pMatch for this, please use them :D
There is also getValueOfArgument`

Comment thread src/linter/rules/deprecated-functions.ts Outdated
certainty: LintingResultCertainty.Certain,
involvedId: argNode.info.id,
function: e.target,
arg: (deprecatedArgInfo.argName ?? deprecatedArgInfo.argIdx) as string | number,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is the cast necessary?

}
str.push(`Function \`${result.function}\` is ${result.state ?? 'deprecated'}`);
if(result.sinceVersion) {
str.push(`since version ${result.sinceVersion.format()}`);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't we check whether the since Version range contract is even fulfilled?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Linter] Deprecated arguments support

2 participants