Marcello-Sega/pytim

View on GitHub

Showing 713 of 713 total issues

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

    def __init__(self,
                 universe,
                 group=None,
                 alpha=2.0,
                 normal='guess',
Severity: Major
Found in pytim/gitim.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):
    ...

Refactor this function to reduce its Cognitive Complexity from 17 to the 15 allowed.
Open

    def compute_sasa(self, group):
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

Method "__init__" has 11 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/rdf.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):
    ...

Refactor this function to reduce its Cognitive Complexity from 35 to the 15 allowed.
Open

    def _select_coords(self, use, bins):
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 "_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):
    ...

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

    def __init__(self,
                 universe,
                 group=None,
                 alpha=1.5,
                 normal='guess',
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):
    ...

Remove or correct this useless self-assignment.
Open

        z = z
Severity: Major
Found in pytim/surface.py by sonar-python

There is no reason to re-assign a variable to itself. Either this statement is redundant and should be removed, or the re-assignment is a mistake and some other value or variable was intended for the assignment instead.

Noncompliant Code Example

name = name

Compliant Solution

name = other.name

See

Remove the code after this "return".
Open

        return sign * dist
Severity: Major
Found in pytim/surface.py by sonar-python

Jump statements (return, break, continue, and raise) move control flow out of the current code block. Typically, any statements in a block that come after a jump are simply wasted keystrokes lying in wait to confuse the unwary.

Noncompliant Code Example

def fun(a):
  i = 10
  return i + a       # Noncompliant
  i += 1             # this is never executed

Compliant Solution

def fun(a):
  i = 10
  return i + a

See

  • MISRA C:2004, 14.1 - There shall be no unreachable code
  • MISRA C++:2008, 0-1-1 - A project shall not contain unreachable code
  • MISRA C++:2008, 0-1-9 - There shall be no dead code
  • MISRA C:2012, 2.1 - A project shall not contain unreachable code
  • MISRA C:2012, 2.2 - There shall be no dead code
  • MITRE, CWE-561 - Dead Code
  • CERT, MSC56-J. - Detect and remove superfluous code and values
  • CERT, MSC12-C. - Detect and remove code that has no effect or is never executed
  • CERT, MSC07-CPP. - Detect and remove dead code

Remove this commented out code.
Open

#oxygens = u.select_atoms("name OW")

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 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 "patchMDTRAJ" to match the regular expression ^[a-z_][a-z0-9_]{2,}$.
Open

def patchMDTRAJ(trajectory, universe):
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,
                 universe,
                 max_distance='full',
                 nbins=75,
                 start=None,
Severity: Major
Found in pytim/observables/rdf.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

        #spacing =  spacing*(grid_size+1.)/grid_size
Severity: Major
Found in pytim/cube.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"
Severity
Category
Status
Source
Language