diff --git a/solidity/underscore-prefix-function.sol b/solidity/underscore-prefix-function.sol new file mode 100644 index 0000000..b27b9b8 --- /dev/null +++ b/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; + } + +} \ No newline at end of file diff --git a/solidity/underscore-prefix-function.yaml b/solidity/underscore-prefix-function.yaml new file mode 100644 index 0000000..e76052c --- /dev/null +++ b/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 { ... }