Skip to content

Commit

Permalink
Merge pull request #1530 from bart1e/no_uppercase_for_public_vars
Browse files Browse the repository at this point in the history
'Not in UPPER_CASE_WITH_UNDERSCORES' warning for public constant vars removed
  • Loading branch information
montyly authored Jan 25, 2023
2 parents b6d6294 + 339d661 commit 2caf510
Show file tree
Hide file tree
Showing 10 changed files with 50 additions and 1 deletion.
3 changes: 2 additions & 1 deletion slither/detectors/naming_convention/naming_convention.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,8 @@ def _detect(self): # pylint: disable=too-many-branches,too-many-statements
# 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 ",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
contract A
{
uint256 public constant myVal = 0;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[
[]
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
contract A
{
uint256 public constant myVal = 0;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[
[]
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
contract A
{
uint256 public constant myVal = 0;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[
[]
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
contract A
{
uint256 public constant myVal = 0;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[
[]
]
20 changes: 20 additions & 0 deletions tests/test_detectors.py
Original file line number Diff line number Diff line change
Expand Up @@ -609,6 +609,26 @@ def id_test(test_item: Test):
"naming_convention.sol",
"0.7.6",
),
Test(
all_detectors.NamingConvention,
"no_warning_for_public_constants.sol",
"0.4.25",
),
Test(
all_detectors.NamingConvention,
"no_warning_for_public_constants.sol",
"0.5.16",
),
Test(
all_detectors.NamingConvention,
"no_warning_for_public_constants.sol",
"0.6.11",
),
Test(
all_detectors.NamingConvention,
"no_warning_for_public_constants.sol",
"0.7.6",
),
Test(
all_detectors.ControlledDelegateCall,
"controlled_delegatecall.sol",
Expand Down

0 comments on commit 2caf510

Please sign in to comment.