All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.sonar.l10n.py.rules.python.S1542.html Maven / Gradle / Ivy

There is a newer version: 4.23.0.17664
Show newest version

This rule raises an issue when a function name doesn’t respect the naming convention.

Why is this an issue?

Shared coding conventions allow teams to collaborate efficiently. This rule checks that all function names match a provided regular expression.

According to PEP8, function names should be lowercase, with words separated by underscores as necessary to improve readability. This convention is known as "snake_case." For example: calculate_area, print_hello, process_data

To fix this, respect the naming convention for the function. The default naming convention is snake case, as recommended by PEP8. Other naming conventions can be defined through the format rule parameter.

Code examples

Noncompliant code example

With the default provided regular expression: ^[a-z_][a-z0-9_]*$

def MyFunction(a,b):
    ...

Compliant solution

def my_function(a,b):
    ...

Resources

Documentation





© 2015 - 2024 Weber Informatics LLC | Privacy Policy