Skip to content

Commit

Permalink
Merge pull request #7 from Decurity/underscore-prefix-function
Browse files Browse the repository at this point in the history
Adding the underscore-prefix-function rule
  • Loading branch information
h1kk4 committed Mar 30, 2023
2 parents 132061c + e3cc00b commit f663843
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
17 changes: 17 additions & 0 deletions solidity/underscore-prefix-function.sol
@@ -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;
}

}
22 changes: 22 additions & 0 deletions solidity/underscore-prefix-function.yaml
@@ -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 { ... }

0 comments on commit f663843

Please sign in to comment.