distributed-system-analysis/run-perf

View on GitHub
runperf/result.py

Summary

Maintainability
C
1 day
Test Coverage
A
92%

File result.py has 1075 lines of code (exceeds 1000 allowed). Consider refactoring.
Wontfix

#!/bin/env python3
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
Severity: Major
Found in runperf/result.py - About 3 hrs to fix

    Function _recalculate has a Cognitive Complexity of 18 (exceeds 6 allowed). Consider refactoring.
    Open

        def _recalculate(self):
            """Recalculate this result status"""
            if not self.agg_weights:
                if not self.error:
                    self._score = -100
    Severity: Minor
    Found in runperf/result.py - About 2 hrs to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    Cyclomatic complexity is too high in method _recalculate. (12)
    Open

        def _recalculate(self):
            """Recalculate this result status"""
            if not self.agg_weights:
                if not self.error:
                    self._score = -100
    Severity: Minor
    Found in runperf/result.py by radon

    Cyclomatic Complexity

    Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

    Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

    Construct Effect on CC Reasoning
    if +1 An if statement is a single decision.
    elif +1 The elif statement adds another decision.
    else +0 The else statement does not cause a new decision. The decision is at the if.
    for +1 There is a decision at the start of the loop.
    while +1 There is a decision at the while statement.
    except +1 Each except branch adds a new conditional path of execution.
    finally +0 The finally block is unconditionally executed.
    with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
    assert +1 The assert statement internally roughly equals a conditional statement.
    Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
    Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

    Source: http://radon.readthedocs.org/en/latest/intro.html

    Cyclomatic complexity is too high in method get_merged_name. (11)
    Open

        def get_merged_name(self, merge):
            """
            Report full test name but replace parts specified in "merge" wiht '*'
            """
            if not merge:
    Severity: Minor
    Found in runperf/result.py by radon

    Cyclomatic Complexity

    Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

    Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

    Construct Effect on CC Reasoning
    if +1 An if statement is a single decision.
    elif +1 The elif statement adds another decision.
    else +0 The else statement does not cause a new decision. The decision is at the if.
    for +1 There is a decision at the start of the loop.
    while +1 There is a decision at the while statement.
    except +1 Each except branch adds a new conditional path of execution.
    finally +0 The finally block is unconditionally executed.
    with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
    assert +1 The assert statement internally roughly equals a conditional statement.
    Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
    Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

    Source: http://radon.readthedocs.org/en/latest/intro.html

    Function record_result has 10 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        def record_result(self, test_name, src, dst, primary=False, grouped=False,
    Severity: Major
    Found in runperf/result.py - About 1 hr to fix

      Function identify has a Cognitive Complexity of 12 (exceeds 6 allowed). Consider refactoring.
      Open

          def identify(self, data):
              """
              Identify model based on data
      
              :param data: dict of {result: [value, value, value]}
      Severity: Minor
      Found in runperf/result.py - About 1 hr to fix

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

      Function identify has a Cognitive Complexity of 12 (exceeds 6 allowed). Consider refactoring.
      Open

          def identify(self, data):
              """
              Identify model based on data
      
              :param data: dict of {result: [value, value, value]}
      Severity: Minor
      Found in runperf/result.py - About 1 hr to fix

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

      Function get_merged_name has a Cognitive Complexity of 11 (exceeds 6 allowed). Consider refactoring.
      Open

          def get_merged_name(self, merge):
              """
              Report full test name but replace parts specified in "merge" wiht '*'
              """
              if not merge:
      Severity: Minor
      Found in runperf/result.py - About 1 hr to fix

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

      Function __init__ has 8 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def __init__(self, log, tolerance, stddev_tolerance, models,
      Severity: Major
      Found in runperf/result.py - About 1 hr to fix

        Function add_bad has 7 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            def add_bad(self, suffix, name, details, difference, weight, src=None):
        Severity: Major
        Found in runperf/result.py - About 50 mins to fix

          Function __init__ has 7 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              def __init__(self, log, mean_tolerance, stddev_tolerance, models,
          Severity: Major
          Found in runperf/result.py - About 50 mins to fix

            Function check_result has a Cognitive Complexity of 9 (exceeds 6 allowed). Consider refactoring.
            Open

                def check_result(self, test_name, src, dst):
                    model = self.model.get(test_name)
                    if model is None:
                        return []
                    equation = model["equation"]
            Severity: Minor
            Found in runperf/result.py - About 45 mins to fix

            Cognitive Complexity

            Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

            A method's cognitive complexity is based on a few simple rules:

            • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
            • Code is considered more complex for each "break in the linear flow of the code"
            • Code is considered more complex when "flow breaking structures are nested"

            Further reading

            Function add has 6 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                def add(self, suffix, name, difference, weight, src=None):
            Severity: Minor
            Found in runperf/result.py - About 45 mins to fix

              Function __init__ has 5 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                  def __init__(self, test, dst, tolerance, primary=False, params=None):
              Severity: Minor
              Found in runperf/result.py - About 35 mins to fix

                Function record_broken has 5 arguments (exceeds 4 allowed). Consider refactoring.
                Wontfix

                    def record_broken(self, test_name, details=None, primary=True, params=None):
                Severity: Minor
                Found in runperf/result.py - About 35 mins to fix

                  Function add_result_by_path has 5 arguments (exceeds 4 allowed). Consider refactoring.
                  Wontfix

                      def add_result_by_path(self, name, path, last=False, skip_incorrect=True):
                  Severity: Minor
                  Found in runperf/result.py - About 35 mins to fix

                    Function __init__ has a Cognitive Complexity of 7 (exceeds 6 allowed). Consider refactoring.
                    Open

                        def __init__(self, mean_tolerance, stddev_tolerance, model=None):
                            self.mean_tolerance = mean_tolerance
                            self.stddev_tolerance = stddev_tolerance
                            if model:
                                with open(model, encoding="utf-8") as fd_model:
                    Severity: Minor
                    Found in runperf/result.py - About 25 mins to fix

                    Cognitive Complexity

                    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                    A method's cognitive complexity is based on a few simple rules:

                    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                    • Code is considered more complex for each "break in the linear flow of the code"
                    • Code is considered more complex when "flow breaking structures are nested"

                    Further reading

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

                    def iter_results(path, skip_incorrect=False):
                    Severity: Critical
                    Found in runperf/result.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 record_result(self, test_name, src, dst, primary=False, grouped=False,
                    Severity: Critical
                    Found in runperf/result.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 18 to the 15 allowed.
                    Open

                        def _recalculate(self):
                    Severity: Critical
                    Found in runperf/result.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 110 to the 15 allowed.
                    Open

                    def closest_result(src_path, dst_path_groups, flatten_coefficient=1):
                    Severity: Critical
                    Found in runperf/result.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 "record_result" has 10 parameters, which is greater than the 7 authorized.
                    Open

                        def record_result(self, test_name, src, dst, primary=False, grouped=False,
                                          difference=None, tolerance=None, params=None,
                                          last=False):
                    Severity: Major
                    Found in runperf/result.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 8 parameters, which is greater than the 7 authorized.
                    Wontfix

                        def __init__(self, log, tolerance, stddev_tolerance, models,
                                     src_name, src_path, modifiers):
                    Severity: Major
                    Found in runperf/result.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):
                        ...
                    

                    There are no issues that match your filters.

                    Category
                    Status