From 62902d74b460e2d52e7561357b82173faa221604 Mon Sep 17 00:00:00 2001 From: bart1e Date: Sun, 18 Dec 2022 16:00:12 +0100 Subject: [PATCH 1/5] 'No uppercase' warning for public vars removed --- slither/detectors/naming_convention/naming_convention.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/slither/detectors/naming_convention/naming_convention.py b/slither/detectors/naming_convention/naming_convention.py index 5e81f003c..94fd2e8f9 100644 --- a/slither/detectors/naming_convention/naming_convention.py +++ b/slither/detectors/naming_convention/naming_convention.py @@ -139,7 +139,8 @@ Solidity defines a [naming convention](https://solidity.readthedocs.io/en/v0.4.2 # For ERC20 compatibility if var.name in ["symbol", "name", "decimals"]: continue - + if var.visibility == "public": + continue if not self.is_upper_case_with_underscores(var.name): info = [ "Constant ", From d400d19ffd01ccfa927759cd82579ea1d3baea06 Mon Sep 17 00:00:00 2001 From: bart1e Date: Thu, 12 Jan 2023 18:02:33 +0100 Subject: [PATCH 2/5] Tests added --- .../0.4.25/no_warning_for_public_vars.sol | 4 ++++ ...blic_vars.sol.0.4.25.NamingConvention.json | 3 +++ .../0.5.16/no_warning_for_public_vars.sol | 4 ++++ ...blic_vars.sol.0.5.16.NamingConvention.json | 3 +++ .../0.6.11/no_warning_for_public_vars.sol | 4 ++++ ...blic_vars.sol.0.6.11.NamingConvention.json | 3 +++ .../0.7.6/no_warning_for_public_vars.sol | 4 ++++ ...ublic_vars.sol.0.7.6.NamingConvention.json | 3 +++ tests/test_detectors.py | 20 +++++++++++++++++++ 9 files changed, 48 insertions(+) create mode 100644 tests/detectors/naming-convention/0.4.25/no_warning_for_public_vars.sol create mode 100644 tests/detectors/naming-convention/0.4.25/no_warning_for_public_vars.sol.0.4.25.NamingConvention.json create mode 100644 tests/detectors/naming-convention/0.5.16/no_warning_for_public_vars.sol create mode 100644 tests/detectors/naming-convention/0.5.16/no_warning_for_public_vars.sol.0.5.16.NamingConvention.json create mode 100644 tests/detectors/naming-convention/0.6.11/no_warning_for_public_vars.sol create mode 100644 tests/detectors/naming-convention/0.6.11/no_warning_for_public_vars.sol.0.6.11.NamingConvention.json create mode 100644 tests/detectors/naming-convention/0.7.6/no_warning_for_public_vars.sol create mode 100644 tests/detectors/naming-convention/0.7.6/no_warning_for_public_vars.sol.0.7.6.NamingConvention.json diff --git a/tests/detectors/naming-convention/0.4.25/no_warning_for_public_vars.sol b/tests/detectors/naming-convention/0.4.25/no_warning_for_public_vars.sol new file mode 100644 index 000000000..a66aa41a4 --- /dev/null +++ b/tests/detectors/naming-convention/0.4.25/no_warning_for_public_vars.sol @@ -0,0 +1,4 @@ +contract A +{ + uint256 public myVal; +} diff --git a/tests/detectors/naming-convention/0.4.25/no_warning_for_public_vars.sol.0.4.25.NamingConvention.json b/tests/detectors/naming-convention/0.4.25/no_warning_for_public_vars.sol.0.4.25.NamingConvention.json new file mode 100644 index 000000000..5825bcacc --- /dev/null +++ b/tests/detectors/naming-convention/0.4.25/no_warning_for_public_vars.sol.0.4.25.NamingConvention.json @@ -0,0 +1,3 @@ +[ + [] +] \ No newline at end of file diff --git a/tests/detectors/naming-convention/0.5.16/no_warning_for_public_vars.sol b/tests/detectors/naming-convention/0.5.16/no_warning_for_public_vars.sol new file mode 100644 index 000000000..a66aa41a4 --- /dev/null +++ b/tests/detectors/naming-convention/0.5.16/no_warning_for_public_vars.sol @@ -0,0 +1,4 @@ +contract A +{ + uint256 public myVal; +} diff --git a/tests/detectors/naming-convention/0.5.16/no_warning_for_public_vars.sol.0.5.16.NamingConvention.json b/tests/detectors/naming-convention/0.5.16/no_warning_for_public_vars.sol.0.5.16.NamingConvention.json new file mode 100644 index 000000000..5825bcacc --- /dev/null +++ b/tests/detectors/naming-convention/0.5.16/no_warning_for_public_vars.sol.0.5.16.NamingConvention.json @@ -0,0 +1,3 @@ +[ + [] +] \ No newline at end of file diff --git a/tests/detectors/naming-convention/0.6.11/no_warning_for_public_vars.sol b/tests/detectors/naming-convention/0.6.11/no_warning_for_public_vars.sol new file mode 100644 index 000000000..a66aa41a4 --- /dev/null +++ b/tests/detectors/naming-convention/0.6.11/no_warning_for_public_vars.sol @@ -0,0 +1,4 @@ +contract A +{ + uint256 public myVal; +} diff --git a/tests/detectors/naming-convention/0.6.11/no_warning_for_public_vars.sol.0.6.11.NamingConvention.json b/tests/detectors/naming-convention/0.6.11/no_warning_for_public_vars.sol.0.6.11.NamingConvention.json new file mode 100644 index 000000000..5825bcacc --- /dev/null +++ b/tests/detectors/naming-convention/0.6.11/no_warning_for_public_vars.sol.0.6.11.NamingConvention.json @@ -0,0 +1,3 @@ +[ + [] +] \ No newline at end of file diff --git a/tests/detectors/naming-convention/0.7.6/no_warning_for_public_vars.sol b/tests/detectors/naming-convention/0.7.6/no_warning_for_public_vars.sol new file mode 100644 index 000000000..a66aa41a4 --- /dev/null +++ b/tests/detectors/naming-convention/0.7.6/no_warning_for_public_vars.sol @@ -0,0 +1,4 @@ +contract A +{ + uint256 public myVal; +} diff --git a/tests/detectors/naming-convention/0.7.6/no_warning_for_public_vars.sol.0.7.6.NamingConvention.json b/tests/detectors/naming-convention/0.7.6/no_warning_for_public_vars.sol.0.7.6.NamingConvention.json new file mode 100644 index 000000000..5825bcacc --- /dev/null +++ b/tests/detectors/naming-convention/0.7.6/no_warning_for_public_vars.sol.0.7.6.NamingConvention.json @@ -0,0 +1,3 @@ +[ + [] +] \ No newline at end of file diff --git a/tests/test_detectors.py b/tests/test_detectors.py index 994f87aac..bc40ceb81 100644 --- a/tests/test_detectors.py +++ b/tests/test_detectors.py @@ -609,6 +609,26 @@ ALL_TEST_OBJECTS = [ "naming_convention.sol", "0.7.6", ), + Test( + all_detectors.NamingConvention, + "no_warning_for_public_vars.sol", + "0.4.25", + ), + Test( + all_detectors.NamingConvention, + "no_warning_for_public_vars.sol", + "0.5.16", + ), + Test( + all_detectors.NamingConvention, + "no_warning_for_public_vars.sol", + "0.6.11", + ), + Test( + all_detectors.NamingConvention, + "no_warning_for_public_vars.sol", + "0.7.6", + ), Test( all_detectors.ControlledDelegateCall, "controlled_delegatecall.sol", From 1af71e695bc3449b500bc2e9f13acc49e82840bc Mon Sep 17 00:00:00 2001 From: bart1e Date: Fri, 13 Jan 2023 17:47:27 +0100 Subject: [PATCH 3/5] Tests fixed --- .../0.4.25/no_warning_for_public_constants.sol | 4 ++++ ...ning_for_public_constants.sol.0.4.25.NamingConvention.json | 3 +++ .../0.5.16/no_warning_for_public_constants.sol | 4 ++++ ...ning_for_public_constants.sol.0.5.16.NamingConvention.json | 3 +++ .../0.6.11/no_warning_for_public_constants.sol | 4 ++++ ...ning_for_public_constants.sol.0.6.11.NamingConvention.json | 3 +++ .../0.7.6/no_warning_for_public_constants.sol | 4 ++++ ...rning_for_public_constants.sol.0.7.6.NamingConvention.json | 3 +++ 8 files changed, 28 insertions(+) create mode 100644 tests/detectors/naming-convention/0.4.25/no_warning_for_public_constants.sol create mode 100644 tests/detectors/naming-convention/0.4.25/no_warning_for_public_constants.sol.0.4.25.NamingConvention.json create mode 100644 tests/detectors/naming-convention/0.5.16/no_warning_for_public_constants.sol create mode 100644 tests/detectors/naming-convention/0.5.16/no_warning_for_public_constants.sol.0.5.16.NamingConvention.json create mode 100644 tests/detectors/naming-convention/0.6.11/no_warning_for_public_constants.sol create mode 100644 tests/detectors/naming-convention/0.6.11/no_warning_for_public_constants.sol.0.6.11.NamingConvention.json create mode 100644 tests/detectors/naming-convention/0.7.6/no_warning_for_public_constants.sol create mode 100644 tests/detectors/naming-convention/0.7.6/no_warning_for_public_constants.sol.0.7.6.NamingConvention.json diff --git a/tests/detectors/naming-convention/0.4.25/no_warning_for_public_constants.sol b/tests/detectors/naming-convention/0.4.25/no_warning_for_public_constants.sol new file mode 100644 index 000000000..0c1da4c26 --- /dev/null +++ b/tests/detectors/naming-convention/0.4.25/no_warning_for_public_constants.sol @@ -0,0 +1,4 @@ +contract A +{ + uint256 public constant myVal = 0; +} \ No newline at end of file diff --git a/tests/detectors/naming-convention/0.4.25/no_warning_for_public_constants.sol.0.4.25.NamingConvention.json b/tests/detectors/naming-convention/0.4.25/no_warning_for_public_constants.sol.0.4.25.NamingConvention.json new file mode 100644 index 000000000..5825bcacc --- /dev/null +++ b/tests/detectors/naming-convention/0.4.25/no_warning_for_public_constants.sol.0.4.25.NamingConvention.json @@ -0,0 +1,3 @@ +[ + [] +] \ No newline at end of file diff --git a/tests/detectors/naming-convention/0.5.16/no_warning_for_public_constants.sol b/tests/detectors/naming-convention/0.5.16/no_warning_for_public_constants.sol new file mode 100644 index 000000000..0c1da4c26 --- /dev/null +++ b/tests/detectors/naming-convention/0.5.16/no_warning_for_public_constants.sol @@ -0,0 +1,4 @@ +contract A +{ + uint256 public constant myVal = 0; +} \ No newline at end of file diff --git a/tests/detectors/naming-convention/0.5.16/no_warning_for_public_constants.sol.0.5.16.NamingConvention.json b/tests/detectors/naming-convention/0.5.16/no_warning_for_public_constants.sol.0.5.16.NamingConvention.json new file mode 100644 index 000000000..5825bcacc --- /dev/null +++ b/tests/detectors/naming-convention/0.5.16/no_warning_for_public_constants.sol.0.5.16.NamingConvention.json @@ -0,0 +1,3 @@ +[ + [] +] \ No newline at end of file diff --git a/tests/detectors/naming-convention/0.6.11/no_warning_for_public_constants.sol b/tests/detectors/naming-convention/0.6.11/no_warning_for_public_constants.sol new file mode 100644 index 000000000..0c1da4c26 --- /dev/null +++ b/tests/detectors/naming-convention/0.6.11/no_warning_for_public_constants.sol @@ -0,0 +1,4 @@ +contract A +{ + uint256 public constant myVal = 0; +} \ No newline at end of file diff --git a/tests/detectors/naming-convention/0.6.11/no_warning_for_public_constants.sol.0.6.11.NamingConvention.json b/tests/detectors/naming-convention/0.6.11/no_warning_for_public_constants.sol.0.6.11.NamingConvention.json new file mode 100644 index 000000000..5825bcacc --- /dev/null +++ b/tests/detectors/naming-convention/0.6.11/no_warning_for_public_constants.sol.0.6.11.NamingConvention.json @@ -0,0 +1,3 @@ +[ + [] +] \ No newline at end of file diff --git a/tests/detectors/naming-convention/0.7.6/no_warning_for_public_constants.sol b/tests/detectors/naming-convention/0.7.6/no_warning_for_public_constants.sol new file mode 100644 index 000000000..e5371cbe3 --- /dev/null +++ b/tests/detectors/naming-convention/0.7.6/no_warning_for_public_constants.sol @@ -0,0 +1,4 @@ +contract A +{ + uint256 public constant myVal = 0; +} diff --git a/tests/detectors/naming-convention/0.7.6/no_warning_for_public_constants.sol.0.7.6.NamingConvention.json b/tests/detectors/naming-convention/0.7.6/no_warning_for_public_constants.sol.0.7.6.NamingConvention.json new file mode 100644 index 000000000..5825bcacc --- /dev/null +++ b/tests/detectors/naming-convention/0.7.6/no_warning_for_public_constants.sol.0.7.6.NamingConvention.json @@ -0,0 +1,3 @@ +[ + [] +] \ No newline at end of file From df912bea5af2a2dded15f99bca66379c4be8ffbc Mon Sep 17 00:00:00 2001 From: bart1e Date: Fri, 13 Jan 2023 17:50:20 +0100 Subject: [PATCH 4/5] Old tests removed --- .../naming-convention/0.4.25/no_warning_for_public_vars.sol | 4 ---- ...o_warning_for_public_vars.sol.0.4.25.NamingConvention.json | 3 --- .../naming-convention/0.5.16/no_warning_for_public_vars.sol | 4 ---- ...o_warning_for_public_vars.sol.0.5.16.NamingConvention.json | 3 --- .../naming-convention/0.6.11/no_warning_for_public_vars.sol | 4 ---- ...o_warning_for_public_vars.sol.0.6.11.NamingConvention.json | 3 --- .../naming-convention/0.7.6/no_warning_for_public_vars.sol | 4 ---- ...no_warning_for_public_vars.sol.0.7.6.NamingConvention.json | 3 --- 8 files changed, 28 deletions(-) delete mode 100644 tests/detectors/naming-convention/0.4.25/no_warning_for_public_vars.sol delete mode 100644 tests/detectors/naming-convention/0.4.25/no_warning_for_public_vars.sol.0.4.25.NamingConvention.json delete mode 100644 tests/detectors/naming-convention/0.5.16/no_warning_for_public_vars.sol delete mode 100644 tests/detectors/naming-convention/0.5.16/no_warning_for_public_vars.sol.0.5.16.NamingConvention.json delete mode 100644 tests/detectors/naming-convention/0.6.11/no_warning_for_public_vars.sol delete mode 100644 tests/detectors/naming-convention/0.6.11/no_warning_for_public_vars.sol.0.6.11.NamingConvention.json delete mode 100644 tests/detectors/naming-convention/0.7.6/no_warning_for_public_vars.sol delete mode 100644 tests/detectors/naming-convention/0.7.6/no_warning_for_public_vars.sol.0.7.6.NamingConvention.json diff --git a/tests/detectors/naming-convention/0.4.25/no_warning_for_public_vars.sol b/tests/detectors/naming-convention/0.4.25/no_warning_for_public_vars.sol deleted file mode 100644 index a66aa41a4..000000000 --- a/tests/detectors/naming-convention/0.4.25/no_warning_for_public_vars.sol +++ /dev/null @@ -1,4 +0,0 @@ -contract A -{ - uint256 public myVal; -} diff --git a/tests/detectors/naming-convention/0.4.25/no_warning_for_public_vars.sol.0.4.25.NamingConvention.json b/tests/detectors/naming-convention/0.4.25/no_warning_for_public_vars.sol.0.4.25.NamingConvention.json deleted file mode 100644 index 5825bcacc..000000000 --- a/tests/detectors/naming-convention/0.4.25/no_warning_for_public_vars.sol.0.4.25.NamingConvention.json +++ /dev/null @@ -1,3 +0,0 @@ -[ - [] -] \ No newline at end of file diff --git a/tests/detectors/naming-convention/0.5.16/no_warning_for_public_vars.sol b/tests/detectors/naming-convention/0.5.16/no_warning_for_public_vars.sol deleted file mode 100644 index a66aa41a4..000000000 --- a/tests/detectors/naming-convention/0.5.16/no_warning_for_public_vars.sol +++ /dev/null @@ -1,4 +0,0 @@ -contract A -{ - uint256 public myVal; -} diff --git a/tests/detectors/naming-convention/0.5.16/no_warning_for_public_vars.sol.0.5.16.NamingConvention.json b/tests/detectors/naming-convention/0.5.16/no_warning_for_public_vars.sol.0.5.16.NamingConvention.json deleted file mode 100644 index 5825bcacc..000000000 --- a/tests/detectors/naming-convention/0.5.16/no_warning_for_public_vars.sol.0.5.16.NamingConvention.json +++ /dev/null @@ -1,3 +0,0 @@ -[ - [] -] \ No newline at end of file diff --git a/tests/detectors/naming-convention/0.6.11/no_warning_for_public_vars.sol b/tests/detectors/naming-convention/0.6.11/no_warning_for_public_vars.sol deleted file mode 100644 index a66aa41a4..000000000 --- a/tests/detectors/naming-convention/0.6.11/no_warning_for_public_vars.sol +++ /dev/null @@ -1,4 +0,0 @@ -contract A -{ - uint256 public myVal; -} diff --git a/tests/detectors/naming-convention/0.6.11/no_warning_for_public_vars.sol.0.6.11.NamingConvention.json b/tests/detectors/naming-convention/0.6.11/no_warning_for_public_vars.sol.0.6.11.NamingConvention.json deleted file mode 100644 index 5825bcacc..000000000 --- a/tests/detectors/naming-convention/0.6.11/no_warning_for_public_vars.sol.0.6.11.NamingConvention.json +++ /dev/null @@ -1,3 +0,0 @@ -[ - [] -] \ No newline at end of file diff --git a/tests/detectors/naming-convention/0.7.6/no_warning_for_public_vars.sol b/tests/detectors/naming-convention/0.7.6/no_warning_for_public_vars.sol deleted file mode 100644 index a66aa41a4..000000000 --- a/tests/detectors/naming-convention/0.7.6/no_warning_for_public_vars.sol +++ /dev/null @@ -1,4 +0,0 @@ -contract A -{ - uint256 public myVal; -} diff --git a/tests/detectors/naming-convention/0.7.6/no_warning_for_public_vars.sol.0.7.6.NamingConvention.json b/tests/detectors/naming-convention/0.7.6/no_warning_for_public_vars.sol.0.7.6.NamingConvention.json deleted file mode 100644 index 5825bcacc..000000000 --- a/tests/detectors/naming-convention/0.7.6/no_warning_for_public_vars.sol.0.7.6.NamingConvention.json +++ /dev/null @@ -1,3 +0,0 @@ -[ - [] -] \ No newline at end of file From 339d6619d8e15ac98b869dee626d110e071757e2 Mon Sep 17 00:00:00 2001 From: bart1e Date: Fri, 13 Jan 2023 17:52:01 +0100 Subject: [PATCH 5/5] test_detectors updated --- tests/test_detectors.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/test_detectors.py b/tests/test_detectors.py index bc40ceb81..860b281b3 100644 --- a/tests/test_detectors.py +++ b/tests/test_detectors.py @@ -611,22 +611,22 @@ ALL_TEST_OBJECTS = [ ), Test( all_detectors.NamingConvention, - "no_warning_for_public_vars.sol", + "no_warning_for_public_constants.sol", "0.4.25", ), Test( all_detectors.NamingConvention, - "no_warning_for_public_vars.sol", + "no_warning_for_public_constants.sol", "0.5.16", ), Test( all_detectors.NamingConvention, - "no_warning_for_public_vars.sol", + "no_warning_for_public_constants.sol", "0.6.11", ), Test( all_detectors.NamingConvention, - "no_warning_for_public_vars.sol", + "no_warning_for_public_constants.sol", "0.7.6", ), Test(