Marcello-Sega/pytim

View on GitHub

Showing 573 of 573 total issues

Remove this commented out code.
Open

           # return cartesian[:,self.dirmask]

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:
    # ...

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 field "R_" to prevent any misunderstanding/clash with field "r_" defined on line 263
Open

            self.r_, self.z_, self.theta_, self.R_ = [], [], [], []
Severity: Blocker
Found in pytim/observables/contactangle.py by sonar-python

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

Method "__init__" has 8 parameters, which is greater than the 7 authorized.
Open

    def __init__(self,
                 direction=None,
                 observable=None,
                 interface=None,
                 symmetry='default',
Severity: Major
Found in pytim/observables/profile.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 15 parameters, which is greater than the 7 authorized.
Open

    def __init__(self,
                 universe,
                 alpha=2.0,
                 tau=1.5,
                 group=None,
Severity: Major
Found in pytim/chacon_tarazona.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

        #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"

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 16 to the 15 allowed.
Open

def patchTrajectory(trajectory, interface):
Severity: Critical
Found in pytim/patches.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

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

Rename function "patchOpenMM" to match the regular expression ^[a-z_][a-z0-9_]{2,}$.
Open

def patchOpenMM(simulation, interface):
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 "sample" has 10 parameters, which is greater than the 7 authorized.
Open

    def sample(self, inter, bins=100, cut=3.5, alpha=2.5, pdbOut=None, binning='theta', periodic=None, removeCOM=None, base_cut=0.0):

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 "_assign_one_side" has 8 parameters, which is greater than the 7 authorized.
Open

    def _assign_one_side(self,
                         uplow,
                         sorted_atoms,
                         _x,
                         _y,
Severity: Major
Found in pytim/itim.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