Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from Decurity/underscore-prefix-function
Adding the underscore-prefix-function rule
- Loading branch information
Showing
2 changed files
with
39 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
contract Test { | ||
// ok: underscore-prefix-function | ||
function _smth() internal { | ||
// | ||
} | ||
|
||
// ruleid: underscore-prefix-function | ||
function _not_Internal(bytes opa) public { | ||
uint256 a = 1; | ||
} | ||
|
||
// ok: underscore-prefix-function | ||
function _smth(string lulz) private { | ||
uint256 a = 1; | ||
} | ||
|
||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
rules: | ||
- id: underscore-prefix-function | ||
message: The convention of functions named with the "_" prefix is not clear. Sometimes it is used for internal functions and other times it's not | ||
languages: | ||
- solidity | ||
severity: WARNING | ||
metadata: | ||
category: coding-style | ||
tags: | ||
- compound | ||
references: | ||
- https://github.com/compound-finance/comet/issues/396 | ||
patterns: | ||
- metavariable-regex: | ||
metavariable: $FUNC | ||
regex: "^_" | ||
- pattern: | | ||
function $FUNC(...) { ... } | ||
- pattern-not: | | ||
function $FUNC(...) internal { ... } | ||
- pattern-not: | | ||
function $FUNC(...) private { ... } |