org.sonar.l10n.py.rules.python.S101.html Maven / Gradle / Ivy
Why is this an issue?
Shared naming conventions allow teams to collaborate efficiently.
This rule raises an issue when a class name does not match a provided regular expression.
The default regular expression allows the "CapWords" convention and the "snake_case" in lowercase. The style guide PEP-8 recommends using the
"CapWords" convention in every case but also accepts the "snake_case" convention when the class is primarily used as a callable (ex: decorator,
context manager, etc…).
For example, with the default provided regular expression ^_?([A-Z_][a-zA-Z0-9]*|[a-z_][a-z0-9_]*)$
, the classes:
class myClass: # Noncompliant
...
class my_CONTEXT_manager: # Noncompliant
def __enter__(self):
pass
def __exit__(self, type, value, traceback):
pass
should be renamed to
class MyClass:
...
class my_context_manager:
def __enter__(self):
pass
def __exit__(self, type, value, traceback):
pass
Resources
Documentation
© 2015 - 2024 Weber Informatics LLC | Privacy Policy