Showing 713 of 713 total issues
Refactor this function to reduce its Cognitive Complexity from 16 to the 15 allowed. Open
def _define_cluster_group(self):
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
Cognitive Complexity is a measure of how hard the control flow of a function is to understand. Functions with high Cognitive Complexity will be difficult to maintain.
See
Refactor this function to reduce its Cognitive Complexity from 17 to the 15 allowed. Open
def _ellipse_general_to_canonical(coeffs, check_coeffs=True):
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
Cognitive Complexity is a measure of how hard the control flow of a function is to understand. Functions with high Cognitive Complexity will be difficult to maintain.
See
Method "__init__" has 16 parameters, which is greater than the 7 authorized. Open
def __init__(self,
universe,
order,
nbins=75,
start=None,
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
A long parameter list can indicate that a new structure should be created to wrap the numerous parameters or that the function is doing too many things.
Noncompliant Code Example
With a maximum number of 4 parameters:
def do_something(param1, param2, param3, param4, param5): ...
Compliant Solution
def do_something(param1, param2, param3, param4): ...
Rename function "_NoReplacementTables" to match the regular expression ^[a-z_][a-z0-9_]{2,}$. Open
def _NoReplacementTables():
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
Shared coding conventions allow teams to collaborate efficiently. This rule checks that all function names match a provided regular expression.
Noncompliant Code Example
With the default provided regular expression: ^[a-z_][a-z0-9_]{2,30}$
def MyFunction(a,b): ...
Compliant Solution
def my_function(a,b): ...
Method "__init__" has 10 parameters, which is greater than the 7 authorized. Open
def __init__(self, inter, substrate, periodic=None, hcut=0.0, hcut_upper=None,
contact_cut=0.0, bins=100, removeCOM=None, store=False):
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
A long parameter list can indicate that a new structure should be created to wrap the numerous parameters or that the function is doing too many things.
Noncompliant Code Example
With a maximum number of 4 parameters:
def do_something(param1, param2, param3, param4, param5): ...
Compliant Solution
def do_something(param1, param2, param3, param4): ...
Refactor this function to reduce its Cognitive Complexity from 38 to the 15 allowed. Open
def _set_default_values(self, generalized_coordinate, max_distance, nbins):
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
Cognitive Complexity is a measure of how hard the control flow of a function is to understand. Functions with high Cognitive Complexity will be difficult to maintain.
See
Remove this return value. Open
return Position.__init__(self, arg, **kwarg)
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
By contract, every Python function returns something, even if it's the None
value, which can be returned implicitly by omitting the
return
statement, or explicitly.
The __init__
method is required to return None
. A TypeError
will be raised if the __init__
method either yield
s or return
s any expression other than None
. Returning some expression that evaluates to
None
will not raise an error, but is considered bad practice.
Noncompliant Code Example
class MyClass(object): def __init__(self): self.message = 'Hello' return self # Noncompliant
Compliant Solution
class MyClass(object): def __init__(self): self.message = 'Hello'
Remove this commented out code. Open
#labels = [label for label, val in self.type.iteritems() if val == name]
- Read upRead up
- Create a ticketCreate a ticket
- 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"
Merge this if statement with the enclosing one. Open
if self.interface.cluster_cut is None:
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
Merging collapsible if
statements increases the code's readability.
Noncompliant Code Example
if condition1: if condition2: # ...
Compliant Solution
if condition1 and condition2: # ...
Rename function "_" to match the regular expression ^[a-z_][a-z0-9_]{2,}$. Open
def _():
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
Shared coding conventions allow teams to collaborate efficiently. This rule checks that all function names match a provided regular expression.
Noncompliant Code Example
With the default provided regular expression: ^[a-z_][a-z0-9_]{2,30}$
def MyFunction(a,b): ...
Compliant Solution
def my_function(a,b): ...
Method "__init__" has 9 parameters, which is greater than the 7 authorized. Open
def __init__(self,
universe,
group=None,
alpha=1.5,
symmetry='generic',
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
A long parameter list can indicate that a new structure should be created to wrap the numerous parameters or that the function is doing too many things.
Noncompliant Code Example
With a maximum number of 4 parameters:
def do_something(param1, param2, param3, param4, param5): ...
Compliant Solution
def do_something(param1, param2, param3, param4): ...
Method "__init__" has 12 parameters, which is greater than the 7 authorized. Open
def __init__(self,
universe,
nbins=75,
max_radius='full',
start=None,
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
A long parameter list can indicate that a new structure should be created to wrap the numerous parameters or that the function is doing too many things.
Noncompliant Code Example
With a maximum number of 4 parameters:
def do_something(param1, param2, param3, param4, param5): ...
Compliant Solution
def do_something(param1, param2, param3, param4): ...
Remove this commented out code. Open
#import sphinx_rtd_theme
- Read upRead up
- Create a ticketCreate a ticket
- 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 function "patchMDTRAJ_ReplacementTables" to match the regular expression ^[a-z_][a-z0-9_]{2,}$. Open
def patchMDTRAJ_ReplacementTables():
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
Shared coding conventions allow teams to collaborate efficiently. This rule checks that all function names match a provided regular expression.
Noncompliant Code Example
With the default provided regular expression: ^[a-z_][a-z0-9_]{2,30}$
def MyFunction(a,b): ...
Compliant Solution
def my_function(a,b): ...
Remove this commented out code. Open
#import sphinx_rtd_theme
- Read upRead up
- Create a ticketCreate a ticket
- 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"
Merge this if statement with the enclosing one. Open
if self.interface._frame != self.frame:
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
Merging collapsible if
statements increases the code's readability.
Noncompliant Code Example
if condition1: if condition2: # ...
Compliant Solution
if condition1 and condition2: # ...
Rename function "patchNumpy" to match the regular expression ^[a-z_][a-z0-9_]{2,}$. Open
def patchNumpy():
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
Shared coding conventions allow teams to collaborate efficiently. This rule checks that all function names match a provided regular expression.
Noncompliant Code Example
With the default provided regular expression: ^[a-z_][a-z0-9_]{2,30}$
def MyFunction(a,b): ...
Compliant Solution
def my_function(a,b): ...
Refactor this function to reduce its Cognitive Complexity from 16 to the 15 allowed. Open
def _atom_coverage(self, index):
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
Cognitive Complexity is a measure of how hard the control flow of a function is to understand. Functions with high Cognitive Complexity will be difficult to maintain.
See
Remove this commented out code. Open
# return _openmm.CompoundIntegrator_step(self, steps)
- Read upRead up
- Create a ticketCreate a ticket
- 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"
Method "__init__" has 16 parameters, which is greater than the 7 authorized. Open
def __init__(self,
universe,
group=None,
alpha=2.0,
radii_dict=None,
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
A long parameter list can indicate that a new structure should be created to wrap the numerous parameters or that the function is doing too many things.
Noncompliant Code Example
With a maximum number of 4 parameters:
def do_something(param1, param2, param3, param4, param5): ...
Compliant Solution
def do_something(param1, param2, param3, param4): ...