Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

linter: Rework only_used_in_recursion detection logic #7275

Open
no-yan opened this issue Nov 13, 2024 · 2 comments
Open

linter: Rework only_used_in_recursion detection logic #7275

no-yan opened this issue Nov 13, 2024 · 2 comments
Labels
A-linter Area - Linter C-enhancement Category - New feature or request good first issue Experience Level - Good for newcomers

Comments

@no-yan
Copy link
Contributor

no-yan commented Nov 13, 2024

What version of Oxlint are you using?

No response

What command did you run?

No response

What does your .oxlint.json config file look like?

No response

What happened?

To improve detection, I propose modifying the algorithm to support a wider range of patterns, including multi-node expressions and cases with more complex references.

The current detection logic is conservative and based on the following conditions:

  1. All references are used in the appropriate position (property or argument) of the recursive function call.
  2. The call is a single-node invocation, e.g., recurfunc(arg), and not a multi-node expression, e.g., recurfunc(arg + 1).

Due to this, the following cases are not detected by the current implementation:

function recursive(arg) {
    return recursive(arg + 1);
}
function recursive(arg) {
    console.log(arg);
    return recursive(arg);
}

Clippy's implementation avoids issuing warnings for expressions with side effects.
We might consider adopting a similar approach in our implementation.

@no-yan no-yan added A-linter Area - Linter C-bug Category - Bug labels Nov 13, 2024
@camc314 camc314 added C-enhancement Category - New feature or request and removed C-bug Category - Bug labels Nov 13, 2024
@Boshen
Copy link
Member

Boshen commented Dec 6, 2024

@no-yan would like to work on this, or should I change this to good first issue?

@no-yan
Copy link
Contributor Author

no-yan commented Dec 8, 2024

@Boshen Unfortunately, I didn't have the bandwidth to work on this for now.
Could you please unassign me?

@camc314 camc314 added the good first issue Experience Level - Good for newcomers label Dec 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-linter Area - Linter C-enhancement Category - New feature or request good first issue Experience Level - Good for newcomers
Projects
None yet
Development

No branches or pull requests

3 participants