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

New Lint: Implement unnecessary_paren_in_negated_if lint #14464

Conversation

DeepakSilaych
Copy link

changelog: [unnecessary_paren_in_negated_if]: Add new lint to check for unnecessary parentheses in negated if conditions

This PR adds a new lint that detects unnecessary parentheses in negated if conditions like if !(condition) and suggests the cleaner if !condition form. This improves code readability by reducing visual noise in conditional expressions.

The implementation:

  • Detects negated if conditions using pattern matching
  • Identifies parenthesized expressions by examining the source snippet
  • Provides a machine-applicable suggestion for removing the parentheses

fixes #14439

@rustbot
Copy link
Collaborator

rustbot commented Mar 24, 2025

r? @llogiq

rustbot has assigned @llogiq.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label Mar 24, 2025
@samueltardieu
Copy link
Contributor

@DeepakSilaych Thanks for your contribution. Are you planning to continue working on it (and fix the errors detected by the CI), or should we close this PR?

@rustbot author

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action from the author. (Use `@rustbot ready` to update this status) and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties labels Apr 6, 2025
@rustbot
Copy link
Collaborator

rustbot commented Apr 6, 2025

Reminder, once the PR becomes ready for a review, use @rustbot ready.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-author Status: This is awaiting some action from the author. (Use `@rustbot ready` to update this status)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unnecessary Parentheses Improvement
4 participants