Showing 4 of 18 total issues
Rename method "pause" to prevent any misunderstanding/clash with field "PAUSE" defined on line 31 Open
def pause(self):
- Read upRead up
- Exclude checks
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.
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
Rename method "stop" to prevent any misunderstanding/clash with field "STOP" defined on line 32 Open
def stop(self):
- Read upRead up
- Exclude checks
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.
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
Remove this commented out code. Open
# instance.position = (20, 0)
- Read upRead up
- Exclude checks
Programmers should not comment out code as it bloats programs and reduces readability.
Unused code should be deleted and can be retrieved from source control history if required.
See
- MISRA C:2004, 2.4 - Sections of code should not be "commented out".
- MISRA C++:2008, 2-7-2 - Sections of code shall not be "commented out" using C-style comments.
- MISRA C++:2008, 2-7-3 - Sections of code should not be "commented out" using C++ comments.
- MISRA C:2012, Dir. 4.4 - Sections of code should not be "commented out"
Rename method "play" to prevent any misunderstanding/clash with field "PLAY" defined on line 30 Open
def play(self):
- Read upRead up
- Exclude checks
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.
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