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

Unnecessary Parentheses Improvement #14439

Open
dxvid-pts opened this issue Mar 19, 2025 · 2 comments
Open

Unnecessary Parentheses Improvement #14439

dxvid-pts opened this issue Mar 19, 2025 · 2 comments
Assignees
Labels
A-lint Area: New lints

Comments

@dxvid-pts
Copy link

dxvid-pts commented Mar 19, 2025

What it does

Currently, normal if clauses work as intended:

unnecessary parentheses around if condition: remove these parentheses

if (authorization.chars().count() < 100) {
        /*authorization must be at least 100 characters long*/
        return None;
    }

However, when the if clause is negated, it doesn't get recognized.
I'd suggest adding a linter for negated if clauses as well.

Advantage

  • Increase consistency between linter hints
  • Readability

Drawbacks

No response

Example

if !(authorization.starts_with("ey")) {
        /*authorization must start with ey*/
        return None;
    }

Could be written as:

if !authorization.starts_with("ey") {
        /*authorization must start with ey*/
        return None;
    }
@dxvid-pts dxvid-pts added the A-lint Area: New lints label Mar 19, 2025
@lapla-cogito
Copy link
Contributor

Note that unused_parens is a lint in rustc, not in clippy.

@DeepakSilaych
Copy link

@rustbot claim

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-lint Area: New lints
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants