-
Notifications
You must be signed in to change notification settings - Fork 11.4k
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] Checks for equal operands to comparison, logical and bitwise, difference and division binary operators (==, >, etc., &&, ||, &, |, ^, - and /). #17115
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
3 Skipped Deployments
|
e910abd
to
4712fa4
Compare
@tx-tomcat is attempting to deploy a commit to the Mysten Labs Team on Vercel. A member of the Team first needs to authorize it. |
This PR is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 7 days. |
4712fa4
to
36b16e3
Compare
36484e3
to
437cc53
Compare
)); | ||
} | ||
|
||
fn equal_operands(lhs: &Value_, op: BinOp_, rhs: &Value_) -> Option<&'static str> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now that I have it working, I am not sure how to feel about this
Description
Implements a new lint rule that detects binary operations with identical operands, which often indicate programming errors or redundant code. This lint helps maintain code quality by catching potentially problematic patterns early in development.
What it checks
The lint analyzes binary operations for the following operators when used with identical operands:
Comparison operators:
==
,!=
,>
,>=
,<
,<=
let x = 10; let _ = x == x; // ⚠️ Warning: Equal operands in comparison
Logical operators:
&&
,||
let _ = true && true; // ⚠️ Warning: Redundant logical operation
Bitwise operators:
&
,|
,^
let x = 5; let _ = x & x; // ⚠️ Warning: Redundant bitwise operation
Arithmetic operators:
-
,/
let x = 10; let _ = x - x; // ⚠️ Warning: Subtraction with equal operands
Test plan
Added more use case including true positive, true negative, false positive, false negative case
Release notes