Marcello-Sega/pytim

View on GitHub

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):
Severity: Critical
Found in pytim/interface.py by sonar-python

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):
Severity: Critical
Found in pytim/observables/contactangle.py by sonar-python

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,

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():
Severity: Major
Found in pytim/patches.py by sonar-python

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):

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):

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)

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 yields or returns 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]
Severity: Major
Found in pytim/datafiles/__init__.py by sonar-python

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:
Severity: Major
Found in pytim/sanity_check.py by sonar-python

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 _():
Severity: Major
Found in pytim/utilities_dbscan.py by sonar-python

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',
Severity: Major
Found in pytim/simple_interface.py by sonar-python

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,
Severity: Major
Found in pytim/observables/rdf2d.py by sonar-python

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
Severity: Major
Found in docs/source/conf.py by sonar-python

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():
Severity: Major
Found in pytim/patches.py by sonar-python

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
Severity: Major
Found in docs/source/conf.py by sonar-python

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:
Severity: Major
Found in pytim/patches.py by sonar-python

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():
Severity: Major
Found in pytim/patches.py by sonar-python

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):
Severity: Critical
Found in pytim/sasa.py by sonar-python

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)
Severity: Major
Found in pytim/patches.py by sonar-python

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,
Severity: Major
Found in pytim/willard_chandler.py by sonar-python

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):
    ...
Severity
Category
Status
Source
Language