Check s_ and i_ naming convention for private and internal only

pull/2125/head
Judy Wu 1 year ago
parent f00e520625
commit f07d506b4a
  1. 15
      slither/detectors/naming_convention/naming_convention.py
  2. 16
      tests/e2e/detectors/snapshots/detectors__detector_NamingConvention_0_4_25_naming_convention_sol__0.txt
  3. 16
      tests/e2e/detectors/snapshots/detectors__detector_NamingConvention_0_5_16_naming_convention_sol__0.txt
  4. 32
      tests/e2e/detectors/snapshots/detectors__detector_NamingConvention_0_6_11_naming_convention_sol__0.txt
  5. 32
      tests/e2e/detectors/snapshots/detectors__detector_NamingConvention_0_7_6_naming_convention_sol__0.txt
  6. 2
      tests/e2e/detectors/test_data/naming-convention/0.4.25/naming_convention.sol
  7. BIN
      tests/e2e/detectors/test_data/naming-convention/0.4.25/naming_convention.sol-0.4.25.zip
  8. BIN
      tests/e2e/detectors/test_data/naming-convention/0.4.25/no_warning_for_public_constants.sol-0.4.25.zip
  9. 2
      tests/e2e/detectors/test_data/naming-convention/0.5.16/naming_convention.sol
  10. BIN
      tests/e2e/detectors/test_data/naming-convention/0.5.16/naming_convention.sol-0.5.16.zip
  11. BIN
      tests/e2e/detectors/test_data/naming-convention/0.5.16/no_warning_for_public_constants.sol-0.5.16.zip
  12. 3
      tests/e2e/detectors/test_data/naming-convention/0.6.11/naming_convention.sol
  13. BIN
      tests/e2e/detectors/test_data/naming-convention/0.6.11/naming_convention.sol-0.6.11.zip
  14. BIN
      tests/e2e/detectors/test_data/naming-convention/0.6.11/no_warning_for_public_constants.sol-0.6.11.zip
  15. 3
      tests/e2e/detectors/test_data/naming-convention/0.7.6/naming_convention.sol
  16. BIN
      tests/e2e/detectors/test_data/naming-convention/0.7.6/naming_convention.sol-0.7.6.zip
  17. BIN
      tests/e2e/detectors/test_data/naming-convention/0.7.6/no_warning_for_public_constants.sol-0.7.6.zip

@ -175,19 +175,12 @@ Solidity defines a [naming convention](https://solidity.readthedocs.io/en/v0.4.2
results.append(res)
else:
# first priority: check for immutable variable naming conventions
if var.is_immutable:
correct_naming = self.is_immutable_naming(var.name)
if var.visibility in ["private", "internal"]:
correct_naming = self.is_mixed_case_with_underscore(var.name) or self.is_state_naming(var.name)
# second priority: check for state variable naming conventions
elif self.is_state_naming(var.name):
correct_naming = True
if not correct_naming and var.is_immutable:
correct_naming = self.is_immutable_naming(var.name)
# third priority: check if visibility is private or internal and check for underscore mixed case
elif var.visibility in ["private", "internal"]:
correct_naming = self.is_mixed_case_with_underscore(var.name)
# fourth priority: check for mixed case naming conventions
else:
correct_naming = self.is_mixed_case(var.name)

@ -1,10 +1,12 @@
Variable T.s_myStateVar (tests/e2e/detectors/test_data/naming-convention/0.4.25/naming_convention.sol#60) is not in mixedCase
Struct naming.test (tests/e2e/detectors/test_data/naming-convention/0.4.25/naming_convention.sol#14-16) is not in CapWords
Variable T.I (tests/e2e/detectors/test_data/naming-convention/0.4.25/naming_convention.sol#71) is not in mixedCase
Variable T.I (tests/e2e/detectors/test_data/naming-convention/0.4.25/naming_convention.sol#73) is not in mixedCase
Variable T.I (tests/e2e/detectors/test_data/naming-convention/0.4.25/naming_convention.sol#71) is single letter l, O, or I, which should not be used
Variable T.I (tests/e2e/detectors/test_data/naming-convention/0.4.25/naming_convention.sol#73) is single letter l, O, or I, which should not be used
Variable T.O (tests/e2e/detectors/test_data/naming-convention/0.4.25/naming_convention.sol#70) is not in mixedCase
Variable T.O (tests/e2e/detectors/test_data/naming-convention/0.4.25/naming_convention.sol#72) is not in mixedCase
Variable naming.Var_One (tests/e2e/detectors/test_data/naming-convention/0.4.25/naming_convention.sol#11) is not in mixedCase
@ -14,11 +16,11 @@ Contract naming (tests/e2e/detectors/test_data/naming-convention/0.4.25/naming_c
Enum naming.numbers (tests/e2e/detectors/test_data/naming-convention/0.4.25/naming_convention.sol#6) is not in CapWords
Parameter T.test(uint256,uint256)._used (tests/e2e/detectors/test_data/naming-convention/0.4.25/naming_convention.sol#61) is not in mixedCase
Parameter T.test(uint256,uint256)._used (tests/e2e/detectors/test_data/naming-convention/0.4.25/naming_convention.sol#63) is not in mixedCase
Variable T._myPublicVar (tests/e2e/detectors/test_data/naming-convention/0.4.25/naming_convention.sol#57) is not in mixedCase
Variable T._myPublicVar (tests/e2e/detectors/test_data/naming-convention/0.4.25/naming_convention.sol#59) is not in mixedCase
Variable T.O (tests/e2e/detectors/test_data/naming-convention/0.4.25/naming_convention.sol#70) is single letter l, O, or I, which should not be used
Variable T.O (tests/e2e/detectors/test_data/naming-convention/0.4.25/naming_convention.sol#72) is single letter l, O, or I, which should not be used
Event naming.event_(uint256) (tests/e2e/detectors/test_data/naming-convention/0.4.25/naming_convention.sol#23) is not in CapWords
@ -26,7 +28,7 @@ Modifier naming.CantDo() (tests/e2e/detectors/test_data/naming-convention/0.4.25
Function naming.GetOne() (tests/e2e/detectors/test_data/naming-convention/0.4.25/naming_convention.sol#30-33) is not in mixedCase
Variable T.l (tests/e2e/detectors/test_data/naming-convention/0.4.25/naming_convention.sol#69) is single letter l, O, or I, which should not be used
Variable T.l (tests/e2e/detectors/test_data/naming-convention/0.4.25/naming_convention.sol#71) is single letter l, O, or I, which should not be used
Parameter naming.setInt(uint256,uint256).Number2 (tests/e2e/detectors/test_data/naming-convention/0.4.25/naming_convention.sol#35) is not in mixedCase

@ -1,10 +1,12 @@
Variable T.s_myStateVar (tests/e2e/detectors/test_data/naming-convention/0.5.16/naming_convention.sol#60) is not in mixedCase
Struct naming.test (tests/e2e/detectors/test_data/naming-convention/0.5.16/naming_convention.sol#14-16) is not in CapWords
Variable T.I (tests/e2e/detectors/test_data/naming-convention/0.5.16/naming_convention.sol#71) is not in mixedCase
Variable T.I (tests/e2e/detectors/test_data/naming-convention/0.5.16/naming_convention.sol#73) is not in mixedCase
Variable T.I (tests/e2e/detectors/test_data/naming-convention/0.5.16/naming_convention.sol#71) is single letter l, O, or I, which should not be used
Variable T.I (tests/e2e/detectors/test_data/naming-convention/0.5.16/naming_convention.sol#73) is single letter l, O, or I, which should not be used
Variable T.O (tests/e2e/detectors/test_data/naming-convention/0.5.16/naming_convention.sol#70) is not in mixedCase
Variable T.O (tests/e2e/detectors/test_data/naming-convention/0.5.16/naming_convention.sol#72) is not in mixedCase
Variable naming.Var_One (tests/e2e/detectors/test_data/naming-convention/0.5.16/naming_convention.sol#11) is not in mixedCase
@ -14,11 +16,11 @@ Contract naming (tests/e2e/detectors/test_data/naming-convention/0.5.16/naming_c
Enum naming.numbers (tests/e2e/detectors/test_data/naming-convention/0.5.16/naming_convention.sol#6) is not in CapWords
Parameter T.test(uint256,uint256)._used (tests/e2e/detectors/test_data/naming-convention/0.5.16/naming_convention.sol#61) is not in mixedCase
Parameter T.test(uint256,uint256)._used (tests/e2e/detectors/test_data/naming-convention/0.5.16/naming_convention.sol#63) is not in mixedCase
Variable T._myPublicVar (tests/e2e/detectors/test_data/naming-convention/0.5.16/naming_convention.sol#57) is not in mixedCase
Variable T._myPublicVar (tests/e2e/detectors/test_data/naming-convention/0.5.16/naming_convention.sol#59) is not in mixedCase
Variable T.O (tests/e2e/detectors/test_data/naming-convention/0.5.16/naming_convention.sol#70) is single letter l, O, or I, which should not be used
Variable T.O (tests/e2e/detectors/test_data/naming-convention/0.5.16/naming_convention.sol#72) is single letter l, O, or I, which should not be used
Event naming.event_(uint256) (tests/e2e/detectors/test_data/naming-convention/0.5.16/naming_convention.sol#23) is not in CapWords
@ -26,7 +28,7 @@ Modifier naming.CantDo() (tests/e2e/detectors/test_data/naming-convention/0.5.16
Function naming.GetOne() (tests/e2e/detectors/test_data/naming-convention/0.5.16/naming_convention.sol#30-33) is not in mixedCase
Variable T.l (tests/e2e/detectors/test_data/naming-convention/0.5.16/naming_convention.sol#69) is single letter l, O, or I, which should not be used
Variable T.l (tests/e2e/detectors/test_data/naming-convention/0.5.16/naming_convention.sol#71) is single letter l, O, or I, which should not be used
Parameter naming.setInt(uint256,uint256).Number2 (tests/e2e/detectors/test_data/naming-convention/0.5.16/naming_convention.sol#35) is not in mixedCase

@ -1,32 +1,36 @@
Struct naming.test (tests/e2e/detectors/test_data/naming-convention/0.6.11/naming_convention.sol#16-18) is not in CapWords
Variable T.s_myStateVar (tests/e2e/detectors/test_data/naming-convention/0.6.11/naming_convention.sol#63) is not in mixedCase
Variable T.I (tests/e2e/detectors/test_data/naming-convention/0.6.11/naming_convention.sol#73) is not in mixedCase
Struct naming.test (tests/e2e/detectors/test_data/naming-convention/0.6.11/naming_convention.sol#17-19) is not in CapWords
Variable T.I (tests/e2e/detectors/test_data/naming-convention/0.6.11/naming_convention.sol#73) is single letter l, O, or I, which should not be used
Variable T.I (tests/e2e/detectors/test_data/naming-convention/0.6.11/naming_convention.sol#76) is not in mixedCase
Variable T.O (tests/e2e/detectors/test_data/naming-convention/0.6.11/naming_convention.sol#72) is not in mixedCase
Variable T.I (tests/e2e/detectors/test_data/naming-convention/0.6.11/naming_convention.sol#76) is single letter l, O, or I, which should not be used
Variable naming.Var_One (tests/e2e/detectors/test_data/naming-convention/0.6.11/naming_convention.sol#13) is not in mixedCase
Variable T.O (tests/e2e/detectors/test_data/naming-convention/0.6.11/naming_convention.sol#75) is not in mixedCase
Variable naming.Var_One (tests/e2e/detectors/test_data/naming-convention/0.6.11/naming_convention.sol#14) is not in mixedCase
Constant naming.MY_other_CONSTANT (tests/e2e/detectors/test_data/naming-convention/0.6.11/naming_convention.sol#9) is not in UPPER_CASE_WITH_UNDERSCORES
Contract naming (tests/e2e/detectors/test_data/naming-convention/0.6.11/naming_convention.sol#3-50) is not in CapWords
Contract naming (tests/e2e/detectors/test_data/naming-convention/0.6.11/naming_convention.sol#3-51) is not in CapWords
Enum naming.numbers (tests/e2e/detectors/test_data/naming-convention/0.6.11/naming_convention.sol#6) is not in CapWords
Parameter T.test(uint256,uint256)._used (tests/e2e/detectors/test_data/naming-convention/0.6.11/naming_convention.sol#63) is not in mixedCase
Parameter T.test(uint256,uint256)._used (tests/e2e/detectors/test_data/naming-convention/0.6.11/naming_convention.sol#66) is not in mixedCase
Variable T._myPublicVar (tests/e2e/detectors/test_data/naming-convention/0.6.11/naming_convention.sol#62) is not in mixedCase
Variable T._myPublicVar (tests/e2e/detectors/test_data/naming-convention/0.6.11/naming_convention.sol#59) is not in mixedCase
Variable T.O (tests/e2e/detectors/test_data/naming-convention/0.6.11/naming_convention.sol#75) is single letter l, O, or I, which should not be used
Variable T.O (tests/e2e/detectors/test_data/naming-convention/0.6.11/naming_convention.sol#72) is single letter l, O, or I, which should not be used
Event naming.event_(uint256) (tests/e2e/detectors/test_data/naming-convention/0.6.11/naming_convention.sol#26) is not in CapWords
Event naming.event_(uint256) (tests/e2e/detectors/test_data/naming-convention/0.6.11/naming_convention.sol#25) is not in CapWords
Modifier naming.CantDo() (tests/e2e/detectors/test_data/naming-convention/0.6.11/naming_convention.sol#44-46) is not in mixedCase
Modifier naming.CantDo() (tests/e2e/detectors/test_data/naming-convention/0.6.11/naming_convention.sol#43-45) is not in mixedCase
Function naming.GetOne() (tests/e2e/detectors/test_data/naming-convention/0.6.11/naming_convention.sol#33-36) is not in mixedCase
Function naming.GetOne() (tests/e2e/detectors/test_data/naming-convention/0.6.11/naming_convention.sol#32-35) is not in mixedCase
Variable T.l (tests/e2e/detectors/test_data/naming-convention/0.6.11/naming_convention.sol#74) is single letter l, O, or I, which should not be used
Variable T.l (tests/e2e/detectors/test_data/naming-convention/0.6.11/naming_convention.sol#71) is single letter l, O, or I, which should not be used
Variable naming.i_myImutableVar (tests/e2e/detectors/test_data/naming-convention/0.6.11/naming_convention.sol#11) is not in mixedCase
Parameter naming.setInt(uint256,uint256).Number2 (tests/e2e/detectors/test_data/naming-convention/0.6.11/naming_convention.sol#37) is not in mixedCase
Parameter naming.setInt(uint256,uint256).Number2 (tests/e2e/detectors/test_data/naming-convention/0.6.11/naming_convention.sol#38) is not in mixedCase

@ -1,32 +1,36 @@
Struct naming.test (tests/e2e/detectors/test_data/naming-convention/0.7.6/naming_convention.sol#16-18) is not in CapWords
Variable T.s_myStateVar (tests/e2e/detectors/test_data/naming-convention/0.7.6/naming_convention.sol#63) is not in mixedCase
Variable T.I (tests/e2e/detectors/test_data/naming-convention/0.7.6/naming_convention.sol#73) is not in mixedCase
Struct naming.test (tests/e2e/detectors/test_data/naming-convention/0.7.6/naming_convention.sol#17-19) is not in CapWords
Variable T.I (tests/e2e/detectors/test_data/naming-convention/0.7.6/naming_convention.sol#73) is single letter l, O, or I, which should not be used
Variable T.I (tests/e2e/detectors/test_data/naming-convention/0.7.6/naming_convention.sol#76) is not in mixedCase
Variable T.O (tests/e2e/detectors/test_data/naming-convention/0.7.6/naming_convention.sol#72) is not in mixedCase
Variable T.I (tests/e2e/detectors/test_data/naming-convention/0.7.6/naming_convention.sol#76) is single letter l, O, or I, which should not be used
Variable naming.Var_One (tests/e2e/detectors/test_data/naming-convention/0.7.6/naming_convention.sol#13) is not in mixedCase
Variable T.O (tests/e2e/detectors/test_data/naming-convention/0.7.6/naming_convention.sol#75) is not in mixedCase
Variable naming.Var_One (tests/e2e/detectors/test_data/naming-convention/0.7.6/naming_convention.sol#14) is not in mixedCase
Constant naming.MY_other_CONSTANT (tests/e2e/detectors/test_data/naming-convention/0.7.6/naming_convention.sol#9) is not in UPPER_CASE_WITH_UNDERSCORES
Contract naming (tests/e2e/detectors/test_data/naming-convention/0.7.6/naming_convention.sol#3-50) is not in CapWords
Contract naming (tests/e2e/detectors/test_data/naming-convention/0.7.6/naming_convention.sol#3-51) is not in CapWords
Enum naming.numbers (tests/e2e/detectors/test_data/naming-convention/0.7.6/naming_convention.sol#6) is not in CapWords
Parameter T.test(uint256,uint256)._used (tests/e2e/detectors/test_data/naming-convention/0.7.6/naming_convention.sol#63) is not in mixedCase
Parameter T.test(uint256,uint256)._used (tests/e2e/detectors/test_data/naming-convention/0.7.6/naming_convention.sol#66) is not in mixedCase
Variable T._myPublicVar (tests/e2e/detectors/test_data/naming-convention/0.7.6/naming_convention.sol#62) is not in mixedCase
Variable T._myPublicVar (tests/e2e/detectors/test_data/naming-convention/0.7.6/naming_convention.sol#59) is not in mixedCase
Variable T.O (tests/e2e/detectors/test_data/naming-convention/0.7.6/naming_convention.sol#75) is single letter l, O, or I, which should not be used
Variable T.O (tests/e2e/detectors/test_data/naming-convention/0.7.6/naming_convention.sol#72) is single letter l, O, or I, which should not be used
Event naming.event_(uint256) (tests/e2e/detectors/test_data/naming-convention/0.7.6/naming_convention.sol#26) is not in CapWords
Event naming.event_(uint256) (tests/e2e/detectors/test_data/naming-convention/0.7.6/naming_convention.sol#25) is not in CapWords
Modifier naming.CantDo() (tests/e2e/detectors/test_data/naming-convention/0.7.6/naming_convention.sol#44-46) is not in mixedCase
Modifier naming.CantDo() (tests/e2e/detectors/test_data/naming-convention/0.7.6/naming_convention.sol#43-45) is not in mixedCase
Function naming.GetOne() (tests/e2e/detectors/test_data/naming-convention/0.7.6/naming_convention.sol#33-36) is not in mixedCase
Function naming.GetOne() (tests/e2e/detectors/test_data/naming-convention/0.7.6/naming_convention.sol#32-35) is not in mixedCase
Variable T.l (tests/e2e/detectors/test_data/naming-convention/0.7.6/naming_convention.sol#74) is single letter l, O, or I, which should not be used
Variable T.l (tests/e2e/detectors/test_data/naming-convention/0.7.6/naming_convention.sol#71) is single letter l, O, or I, which should not be used
Variable naming.i_myImutableVar (tests/e2e/detectors/test_data/naming-convention/0.7.6/naming_convention.sol#11) is not in mixedCase
Parameter naming.setInt(uint256,uint256).Number2 (tests/e2e/detectors/test_data/naming-convention/0.7.6/naming_convention.sol#37) is not in mixedCase
Parameter naming.setInt(uint256,uint256).Number2 (tests/e2e/detectors/test_data/naming-convention/0.7.6/naming_convention.sol#38) is not in mixedCase

@ -53,7 +53,9 @@ contract Test {
contract T {
uint private _myPrivateVar;
uint private s_myPrivateVar;
uint internal _myInternalVar;
uint internal s_myInternalVar;
uint public _myPublicVar;
uint public s_myStateVar;
uint public myPublicVar;

@ -53,7 +53,9 @@ contract Test {
contract T {
uint private _myPrivateVar;
uint private s_myPrivateVar;
uint internal _myInternalVar;
uint internal s_myInternalVar;
uint public _myPublicVar;
uint public s_myStateVar;
uint public myPublicVar;

@ -9,6 +9,7 @@ contract naming {
uint constant MY_other_CONSTANT = 2;
uint public immutable i_myImutableVar = 1;
uint private immutable i_myPrivateImutableVar = 1;
uint Var_One = 1;
uint varTwo = 2;
@ -55,7 +56,9 @@ contract Test {
contract T {
uint private _myPrivateVar;
uint private s_myPrivateVar;
uint internal _myInternalVar;
uint internal s_myInternalVar;
uint public _myPublicVar;
uint public s_myStateVar;
uint public myPublicVar;

@ -9,6 +9,7 @@ contract naming {
uint constant MY_other_CONSTANT = 2;
uint public immutable i_myImutableVar = 1;
uint private immutable i_myPrivateImutableVar = 1;
uint Var_One = 1;
uint varTwo = 2;
@ -55,7 +56,9 @@ contract Test {
contract T {
uint private _myPrivateVar;
uint private s_myPrivateVar;
uint internal _myInternalVar;
uint internal s_myInternalVar;
uint public _myPublicVar;
uint public s_myStateVar;
uint public myPublicVar;

Loading…
Cancel
Save