- Operating system: Ubuntu 22.04.4 LTS (WSL 2)
- SonarQube for VS Code plugin version: 4.19.0
- Programming language you’re coding in: Python
- Is connected mode used: No
The S100/S116 rules is not applied to method/field names in Python classes that inherit from other classes.
Expected behavior: All method/field names should be validated against the naming convention regex, regardless of whether they are defined in base classes or subclasses.
Actual behavior: Methods/fields defined in subclasses using camelCase are not reported as violations.
This makes it easy to miss inconsistent naming across the codebase when using inheritance.
Steps to reproduce:
- Define a class with
camelCaseMethod
/camelCaseField
that inherits from a base class. - Enable rules S100/S116 with a regex enforcing
snake_case
. - No issue is reported by Sonar.
Example:
class A:
pass
class B(A):
myVar: str # Noncompliant - should trigger S116, but it doesn't
def myTest(self) -> None: # Noncompliant - should trigger S100, but it doesn't
return
class C:
myVar: str # Noncompliant - correctly triggers S116
def myTest(self) -> None: # Noncompliant - correctly triggers S100
return