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] Meaningless Math Operation #16626

Merged

Conversation

tx-tomcat
Copy link
Contributor

@tx-tomcat tx-tomcat commented Mar 12, 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:
  • CLI: Move will now lint against unnecessary math operations in many cases.
  • Rust SDK:

Copy link

vercel bot commented Mar 12, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
explorer ✅ Ready (Inspect) Visit Preview 💬 Add feedback Aug 23, 2024 0:01am
multisig-toolkit ✅ Ready (Inspect) Visit Preview 💬 Add feedback Aug 23, 2024 0:01am
mysten-ui ✅ Ready (Inspect) Visit Preview 💬 Add feedback Aug 23, 2024 0:01am
sui-core ✅ Ready (Inspect) Visit Preview 💬 Add feedback Aug 23, 2024 0:01am
sui-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Aug 23, 2024 0:01am
sui-kiosk ✅ Ready (Inspect) Visit Preview 💬 Add feedback Aug 23, 2024 0:01am
sui-typescript-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Aug 23, 2024 0:01am

Copy link

vercel bot commented May 31, 2024

@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.

@tnowacki tnowacki merged commit c724ed0 into MystenLabs:main Aug 23, 2024
40 of 44 checks passed
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
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants