test: cover override+public+constant in naming-convention regression#3027
Open
js360000 wants to merge 2 commits into
Open
test: cover override+public+constant in naming-convention regression#3027js360000 wants to merge 2 commits into
js360000 wants to merge 2 commits into
Conversation
Adds an explicit regression fixture for the scenario described in crytic#930: a public constant that overrides an interface getter must not be flagged by the UPPER_CASE_WITH_UNDERSCORES naming-convention rule. The behavior has been correct since the public-constant skip was added in slither/detectors/naming_convention/naming_convention.py — but the existing no_warning_for_public_constants.sol fixture only exercises a plain public constant. This change locks in the override variant so a future refactor of the public/override ordering can't silently regress. Coverage is added for solc 0.6.11 and 0.7.6 (the override keyword is a 0.6.x addition; pre-0.6 versions don't apply). Snapshots are empty, matching the existing no_warning_for_public_constants.sol baselines. Closes crytic#930.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds an explicit regression fixture for the scenario described in #930: a public constant that overrides an interface getter must not be flagged by the
naming-conventiondetector'sUPPER_CASE_WITH_UNDERSCORESrule.The behavior has been correct since the public-constant skip was added in
slither/detectors/naming_convention/naming_convention.py— but the existingno_warning_for_public_constants.solfixture only exercises a plain public constant. This change locks in theoverridevariant so a future refactor of the public/override ordering can't silently regress.Why this instead of code changes
I verified against the current detector code that the issue's repro:
…already produces zero findings because the detector skips the entire
publicbranch before ever evaluatingoverride.@cats2101came to the same conclusion in the 2026-03-31 issue comment, but the case still isn't pinned by a fixture. Adding the regression test now means anyone touchingnaming_convention.pylater will get an immediate signal if the ordering of thepublicskip vs. theis_constantbranch gets swapped.What changed
tests/e2e/detectors/test_data/naming-convention/0.6.11/no_warning_for_public_constants_with_override.sol— new fixture exercising override+public+constant on solc 0.6.11.tests/e2e/detectors/test_data/naming-convention/0.7.6/no_warning_for_public_constants_with_override.sol— same for solc 0.7.6.tests/e2e/detectors/snapshots/(matches the existingno_warning_for_public_constants.solbaselines, which are also empty).Test(NamingConvention, …)entries intests/e2e/detectors/test_detectors.py.Pre-0.6 solc versions are intentionally skipped — the
overridekeyword is a 0.6.x addition.Diff
```
.../naming-convention/0.6.11/no_warning_for_public_constants_with_override.sol | 14 ++++++++++++++
.../naming-convention/0.7.6/no_warning_for_public_constants_with_override.sol | 14 ++++++++++++++
tests/e2e/detectors/snapshots/..._0_6_11..._with_override_sol__0.txt | 0
tests/e2e/detectors/snapshots/..._0_7_6..._with_override_sol__0.txt | 0
tests/e2e/detectors/test_detectors.py | 10 ++++++++++
5 files changed, 38 insertions(+)
```
Closes
Closes #930.