-
Notifications
You must be signed in to change notification settings - Fork 11.1k
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] Meaningless Math Operation #16626
Merged
tnowacki
merged 3 commits into
MystenLabs:main
from
tx-tomcat:custom_rules/meaningless_math_operation
Aug 23, 2024
Merged
[Linter] Meaningless Math Operation #16626
tnowacki
merged 3 commits into
MystenLabs:main
from
tx-tomcat:custom_rules/meaningless_math_operation
Aug 23, 2024
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
tx-tomcat
force-pushed
the
custom_rules/meaningless_math_operation
branch
from
May 31, 2024 15:06
964aba7
to
4098c56
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. |
tx-tomcat
force-pushed
the
custom_rules/meaningless_math_operation
branch
from
August 15, 2024 10:36
4098c56
to
6a3aa91
Compare
tx-tomcat
force-pushed
the
custom_rules/meaningless_math_operation
branch
5 times, most recently
from
August 15, 2024 10:51
9cf7150
to
82ccfff
Compare
tx-tomcat
force-pushed
the
custom_rules/meaningless_math_operation
branch
from
August 15, 2024 11:14
82ccfff
to
fc68fa2
Compare
tx-tomcat
force-pushed
the
custom_rules/meaningless_math_operation
branch
from
August 15, 2024 11:31
fc68fa2
to
4d0443b
Compare
tnowacki
approved these changes
Aug 22, 2024
suiwombat
pushed a commit
that referenced
this pull request
Sep 16, 2024
## Description The lint identifies operations that have no effect on the result, such as multiplying by 0 or 1, adding or subtracting 0, or shifting by 0. These operations are considered redundant and can be simplified to improve code clarity. Main Logic: For binary operations, it checks the operator and the right-hand side operand. It identifies specific patterns of meaningless operations. Detected Patterns: The lint checks for the following meaningless operations: Multiplication or division by 0 Multiplication by 1 Addition or subtraction of 0 Left or right shift by 0 ## Test plan Added more use case including true positive, true negative, false positive, false negative case ## Release notes - [ ] Protocol: - [ ] Nodes (Validators and Full nodes): - [ ] Indexer: - [ ] JSON-RPC: - [ ] GraphQL: - [X] CLI: Move will now lint against unnecessary math operations in many cases. - [ ] Rust SDK: --------- Co-authored-by: jamedzung <dung.dinhnguyen@digitalavenues.com> Co-authored-by: Todd Nowacki <tmn@mystenlabs.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
The lint identifies operations that have no effect on the result, such as multiplying by 0 or 1, adding or subtracting 0, or shifting by 0. These operations are considered redundant and can be simplified to improve code clarity.
Main Logic:
For binary operations, it checks the operator and the right-hand side operand.
It identifies specific patterns of meaningless operations.
Detected Patterns:
The lint checks for the following meaningless operations:
Multiplication or division by 0
Multiplication by 1
Addition or subtraction of 0
Left or right shift by 0
Test plan
Added more use case including true positive, true negative, false positive, false negative case
Release notes