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

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

The newest version!

This rule raises an issue when there is a method and a field in a class with names that differ only by capitalization.

Why is this an issue?

Looking at the set of methods and fields in a class and finding two that differ only by capitalization is confusing to users of the class.

This situation may simply indicate poor naming. Method names should be action-oriented, and thus contain a verb, which is unlikely in the case where both a method and a field have the same name (with or without capitalization differences). However, renaming a public method could be disruptive to callers. Therefore renaming the member is the recommended action.

Code examples

Noncompliant code example

class SomeClass:
    lookUp = false
    def lookup():       # Non-compliant; method name differs from field name only by capitalization
        pass

Compliant solution

class SomeClass:
    lookUp = false
    def getLookUp():
        pass




© 2015 - 2025 Weber Informatics LLC | Privacy Policy