ionelmc/pytest-benchmark

View on GitHub

Showing 47 of 49 total issues

Function _make_runner has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    def _make_runner(self, function_to_benchmark, args, kwargs):
        def runner(loops_range, timer=self._timer):
            gc_enabled = gc.isenabled()
            if self._disable_gc:
                gc.disable()
Severity: Minor
Found in src/pytest_benchmark/fixture.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_cprofile_functions has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

def get_cprofile_functions(stats):
    """
    Convert pstats structure to list of sorted dicts about each function.
    """
    result = []
Severity: Minor
Found in src/pytest_benchmark/utils.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 a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    def __init__(self, config):
        self.verbose = config.getoption('benchmark_verbose')
        self.quiet = False if self.verbose else config.getoption('benchmark_quiet')
        level = Logger.QUIET if self.quiet else Logger.NORMAL
        if self.verbose:
Severity: Minor
Found in src/pytest_benchmark/session.py - About 55 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 handle_saving has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    def handle_saving(self):
        save = self.save or self.autosave
        if save or self.json:
            if not self.benchmarks:
                if not self.disabled:
Severity: Minor
Found in src/pytest_benchmark/session.py - About 55 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 exec_in_env has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

def exec_in_env():
    env_path = base_path / '.tox' / 'bootstrap'
    if sys.platform == 'win32':
        bin_path = env_path / 'Scripts'
    else:
Severity: Minor
Found in ci/bootstrap.py - About 55 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 pedantic has 7 arguments (exceeds 4 allowed). Consider refactoring.
Open

    def pedantic(self, target, args=(), kwargs=None, setup=None, rounds=1, warmup_rounds=0, iterations=1):
Severity: Major
Found in src/pytest_benchmark/fixture.py - About 50 mins to fix

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

        def _raw_pedantic(self, target, args=(), kwargs=None, setup=None, rounds=1, warmup_rounds=0, iterations=1):
    Severity: Major
    Found in src/pytest_benchmark/fixture.py - About 50 mins to fix

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

          def _tooltip_data(self, node, value, x, y, classes=None, xlabel=None):
      Severity: Major
      Found in src/pytest_benchmark/histogram.py - About 50 mins to fix

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

            def __init__(self, columns, sort, histogram, name_format, logger, scale_unit):
        Severity: Minor
        Found in src/pytest_benchmark/table.py - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                                  if self.compare_fail:
                                      for check in self.compare_fail:
                                          fail = check.fails(bench, flat_bench)
                                          if fail:
                                              self.performance_regressions.append((self.name_format(flat_bench), fail))
          Severity: Major
          Found in src/pytest_benchmark/session.py - About 45 mins to fix

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

            def pytest_benchmark_scale_unit(config, unit, benchmarks, best, worst, sort):
            Severity: Minor
            Found in src/pytest_benchmark/hookspec.py - About 45 mins to fix

              Function compute_baseline_scale has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

              def compute_baseline_scale(baseline, value, width):
                  if not width:
                      return ''
                  if value == baseline:
                      return ' (1.0)'.ljust(width)
              Severity: Minor
              Found in src/pytest_benchmark/table.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 pytest_benchmark_scale_unit has 6 arguments (exceeds 4 allowed). Consider refactoring.
              Open

              def pytest_benchmark_scale_unit(config, unit, benchmarks, best, worst, sort):
              Severity: Minor
              Found in src/pytest_benchmark/plugin.py - About 45 mins to fix

                Function pytest_runtest_setup has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                Open

                def pytest_runtest_setup(item):
                    marker = item.get_closest_marker('benchmark')
                    if marker:
                        if marker.args:
                            raise ValueError("benchmark mark can't have positional arguments.")
                Severity: Minor
                Found in src/pytest_benchmark/plugin.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 __init__ has 6 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                    def __init__(self, hosts, index, doctype, project_name, logger, default_machine_id=None):
                Severity: Minor
                Found in src/pytest_benchmark/storage/elasticsearch.py - About 45 mins to fix

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

                  def pytest_benchmark_generate_json(config, benchmarks, include_data, machine_info, commit_info):
                  Severity: Minor
                  Found in src/pytest_benchmark/plugin.py - About 35 mins to fix

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

                    def make_histogram(output_prefix, name, benchmarks, unit, adjustment):
                    Severity: Minor
                    Found in src/pytest_benchmark/histogram.py - About 35 mins to fix

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

                      def pytest_benchmark_generate_json(config, benchmarks, include_data, machine_info, commit_info):
                      Severity: Minor
                      Found in src/pytest_benchmark/hookspec.py - About 35 mins to fix

                        Function short_filename has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                        Open

                        def short_filename(path, machine_id=None):
                            parts = []
                            try:
                                last = len(path.parts) - 1
                            except AttributeError:
                        Severity: Minor
                        Found in src/pytest_benchmark/utils.py - About 35 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 warning has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                        Open

                            def warning(self, text, warner=None, suspend=False):
                                if self.level >= self.VERBOSE:
                                    if suspend and self.suspend_capture:
                                        self.suspend_capture(in_=True)
                                    self.term.line('')
                        Severity: Minor
                        Found in src/pytest_benchmark/logger.py - About 35 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

                        Severity
                        Category
                        Status
                        Source
                        Language