-
Notifications
You must be signed in to change notification settings - Fork 480
Linter: Warn about strict balance equality #1914
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
c00652c
feat(linter): strict balance equality lint
jubnzv 422eff5
feat(lint): Handle temporary values resulted after Rvalue::Use
jubnzv c0c2b80
fix(lint): spans to emit diagnostics
jubnzv 4de5d35
feat(tests): more tests
jubnzv e679c6f
feat(lint): Manually traverse functions in user-defined code
jubnzv 0d2953f
feat(lint): interprocedural analysis that finds tainted returns
jubnzv 20c34c5
fix(lint): recursive calls in interprocedural analysis
jubnzv 233ddfa
fix(lint): false negative on `CheckedBinaryOp`
jubnzv 1cfe0e4
feat(lint): propagation through references
jubnzv 6512927
feat(lint): Propagate tainted values through `&mut` arguments
jubnzv 7725462
chore(lint): docstring, comments
jubnzv c8434d4
feat(lint): handle comparison of references in functions
jubnzv 62a5a35
chore(tests): comments
jubnzv 0f99906
feat(lint+tests): updated `pass` test, fixed binop conditions
jubnzv 3e8bde3
feat(tests): test for lint suppressions
jubnzv 0e7bfee
Merge remote-tracking branch 'origin/master' into 1811-balance-condition
jubnzv 46238bb
chore(tests): fmt
jubnzv 0be39dd
chore(tests): fmt
jubnzv e202891
chore: Add changelog entry
jubnzv fc4a143
Merge remote-tracking branch 'origin/master' into 1811-balance-condition
jubnzv 96d84e0
chore(lint): Reuse utility functions introduced in #1932
jubnzv 5b5054a
chore: Fix changelog
jubnzv 09f8f9b
Merge remote-tracking branch 'origin/master' into 1811-balance-condition
jubnzv fd358b8
chore: Fix comments
jubnzv File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
feat(lint): handle comparison of references in functions
- Loading branch information
commit c8434d4fca29d8177c7ff3b9af56bafb77a8a231
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,58 +1,76 @@ | ||
| error: dangerous strict balance equality | ||
| --> $DIR/strict_balance_equality.rs:50:37 | ||
| --> $DIR/strict_balance_equality.rs:57:16 | ||
| | | ||
| LL | if self.env().balance() == 10 { /* ... */ } | ||
| | ^^ help: consider using non-strict equality operators instead: `<`, `>` | ||
| | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using non-strict equality operators instead: `<`, `>` | ||
| | | ||
| = note: `-D strict-balance-equality` implied by `-D warnings` | ||
|
|
||
| error: dangerous strict balance equality | ||
| --> $DIR/strict_balance_equality.rs:51:22 | ||
| --> $DIR/strict_balance_equality.rs:58:16 | ||
| | | ||
| LL | if value == 11 { /* ... */ } | ||
| | ^^ help: consider using non-strict equality operators instead: `<`, `>` | ||
| | ^^^^^^^^^^^ help: consider using non-strict equality operators instead: `<`, `>` | ||
|
|
||
| error: dangerous strict balance equality | ||
| --> $DIR/strict_balance_equality.rs:52:37 | ||
| --> $DIR/strict_balance_equality.rs:59:16 | ||
| | | ||
| LL | if self.env().balance() == threshold { /* ... */ } | ||
| | ^^ help: consider using non-strict equality operators instead: `<`, `>` | ||
| | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using non-strict equality operators instead: `<`, `>` | ||
|
|
||
| error: dangerous strict balance equality | ||
| --> $DIR/strict_balance_equality.rs:55:37 | ||
| --> $DIR/strict_balance_equality.rs:62:16 | ||
| | | ||
| LL | if self.get_balance_1() == 10 { /* ... */ } | ||
| | ^^ help: consider using non-strict equality operators instead: `<`, `>` | ||
| | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using non-strict equality operators instead: `<`, `>` | ||
|
|
||
| error: dangerous strict balance equality | ||
| --> $DIR/strict_balance_equality.rs:56:37 | ||
| --> $DIR/strict_balance_equality.rs:63:16 | ||
| | | ||
| LL | if self.get_balance_2() == 10 { /* ... */ } | ||
| | ^^ help: consider using non-strict equality operators instead: `<`, `>` | ||
| | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using non-strict equality operators instead: `<`, `>` | ||
|
|
||
| error: dangerous strict balance equality | ||
| --> $DIR/strict_balance_equality.rs:57:37 | ||
| --> $DIR/strict_balance_equality.rs:64:16 | ||
| | | ||
| LL | if self.get_balance_3() == 10 { /* ... */ } | ||
| | ^^ help: consider using non-strict equality operators instead: `<`, `>` | ||
| | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using non-strict equality operators instead: `<`, `>` | ||
|
|
||
| error: dangerous strict balance equality | ||
| --> $DIR/strict_balance_equality.rs:58:48 | ||
| --> $DIR/strict_balance_equality.rs:65:16 | ||
| | | ||
| LL | if self.get_balance_recursive(&10) == 10 { /* ... */ } | ||
| | ^^ help: consider using non-strict equality operators instead: `<`, `>` | ||
| | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using non-strict equality operators instead: `<`, `>` | ||
|
|
||
| error: dangerous strict balance equality | ||
| --> $DIR/strict_balance_equality.rs:65:22 | ||
| --> $DIR/strict_balance_equality.rs:69:16 | ||
| | | ||
| LL | if self.cmp_balance_1(&10) { /* ... */ } | ||
| | ^^^^^^^^^^^^^^^^^^^^^^^ help: consider using non-strict equality operators instead: `<`, `>` | ||
|
|
||
| error: dangerous strict balance equality | ||
| --> $DIR/strict_balance_equality.rs:70:16 | ||
| | | ||
| LL | if self.cmp_balance_2(&self.env().balance(), &threshold) { /* ... */ } | ||
| | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using non-strict equality operators instead: `<`, `>` | ||
|
|
||
| error: dangerous strict balance equality | ||
| --> $DIR/strict_balance_equality.rs:71:16 | ||
| | | ||
| LL | if self.cmp_balance_3(self.env().balance(), threshold) { /* ... */ } | ||
| | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using non-strict equality operators instead: `<`, `>` | ||
|
|
||
| error: dangerous strict balance equality | ||
| --> $DIR/strict_balance_equality.rs:76:16 | ||
| | | ||
| LL | if res_1 == 10 { /* ... */ } | ||
| | ^^ help: consider using non-strict equality operators instead: `<`, `>` | ||
| | ^^^^^^^^^^^ help: consider using non-strict equality operators instead: `<`, `>` | ||
|
|
||
| error: dangerous strict balance equality | ||
| --> $DIR/strict_balance_equality.rs:68:22 | ||
| --> $DIR/strict_balance_equality.rs:79:16 | ||
| | | ||
| LL | if res_2 == 10 { /* ... */ } | ||
| | ^^ help: consider using non-strict equality operators instead: `<`, `>` | ||
| | ^^^^^^^^^^^ help: consider using non-strict equality operators instead: `<`, `>` | ||
|
|
||
| error: aborting due to 9 previous errors | ||
| error: aborting due to 12 previous errors | ||
|
|
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.
Uh oh!
There was an error while loading. Please reload this page.