ionelmc/pytest-benchmark

View on GitHub

Showing 49 of 49 total issues

File utils.py has 472 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import argparse
import json
import netrc
import os
import platform
Severity: Minor
Found in src/pytest_benchmark/utils.py - About 7 hrs to fix

    File plugin.py has 433 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import argparse
    import operator
    import platform
    import sys
    import traceback
    Severity: Minor
    Found in src/pytest_benchmark/plugin.py - About 6 hrs to fix

      Function display has a Cognitive Complexity of 38 (exceeds 5 allowed). Consider refactoring.
      Open

          def display(self, tr, groups, progress_reporter=report_progress):
              tr.write_line('')
              report_online_progress(progress_reporter, tr, 'Computing stats ...')
              for line, (group, benchmarks) in progress_reporter(groups, tr, 'Computing stats ... group {pos}/{total}'):
                  benchmarks = sorted(benchmarks, key=operator.itemgetter(self.sort))
      Severity: Minor
      Found in src/pytest_benchmark/table.py - About 5 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

      Function prepare_benchmarks has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
      Open

          def prepare_benchmarks(self):
              for bench in self.benchmarks:
                  if bench:
                      compared = False
                      for path, compared_mapping in self.compared_mapping.items():
      Severity: Minor
      Found in src/pytest_benchmark/session.py - About 4 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

      Function _raw_pedantic has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
      Open

          def _raw_pedantic(self, target, args=(), kwargs=None, setup=None, rounds=1, warmup_rounds=0, iterations=1):
              if kwargs is None:
                  kwargs = {}
      
              has_args = bool(args or kwargs)
      Severity: Minor
      Found in src/pytest_benchmark/fixture.py - About 3 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

      Function as_dict has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
      Open

          def as_dict(self, include_data=True, flat=False, stats=True, cprofile=None):
              result = {
                  'group': self.group,
                  'name': self.name,
                  'fullname': self.fullname,
      Severity: Minor
      Found in src/pytest_benchmark/stats.py - About 3 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

      Function display_cprofile has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
      Open

          def display_cprofile(self, tr):
              section_displayed = False
              for group in self.groups:
                  group_name, benchmarks = group
                  for benchmark in benchmarks:
      Severity: Minor
      Found in src/pytest_benchmark/session.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

      File fixture.py has 266 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      import cProfile
      import gc
      import pstats
      import sys
      import time
      Severity: Minor
      Found in src/pytest_benchmark/fixture.py - About 2 hrs to fix

        Stats has 22 functions (exceeds 20 allowed). Consider refactoring.
        Open

        class Stats:
            fields = (
                'min',
                'max',
                'mean',
        Severity: Minor
        Found in src/pytest_benchmark/stats.py - About 2 hrs to fix

          Function pytest_benchmark_group_stats has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
          Open

          def pytest_benchmark_group_stats(config, benchmarks, group_by):
              groups = defaultdict(list)
              for bench in benchmarks:
                  key = ()
                  for grouping in group_by.split(','):
          Severity: Minor
          Found in src/pytest_benchmark/plugin.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

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

              def __init__(
          Severity: Major
          Found in src/pytest_benchmark/fixture.py - About 1 hr to fix

            Function compute_timer_precision has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
            Open

            def compute_timer_precision(timer):
                precision = None
                points = 0
                timeout = timeout_timer() + 1.0
                previous = timer()
            Severity: Minor
            Found in src/pytest_benchmark/timers.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 load has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
            Open

                def load(self, *globs_or_files):
                    if not globs_or_files:
                        globs_or_files = ('[0-9][0-9][0-9][0-9]_',)
            
                    for file in self.query(*globs_or_files):
            Severity: Minor
            Found in src/pytest_benchmark/storage/file.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_commit_info has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
            Open

            def get_commit_info(project_name=None):
                dirty = False
                commit = 'unversioned'
                commit_time = None
                author_time = None
            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 handle_loading has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
            Open

                def handle_loading(self):
                    compared_mapping = {}
                    if self.compare:
                        if self.compare is True:
                            compared_benchmarks = list(self.storage.load())[-1:]
            Severity: Minor
            Found in src/pytest_benchmark/session.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 query has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
            Open

                def query(self, *globs_or_files):
                    files = []
                    globs = []
                    if not globs_or_files:
                        globs_or_files = ('*',)
            Severity: Minor
            Found in src/pytest_benchmark/storage/file.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 pytest_collection_modifyitems has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
            Open

            def pytest_collection_modifyitems(config, items):
                bs = config._benchmarksession
                skip_bench = pytest.mark.skip(reason='Skipping benchmark (--benchmark-skip active).')
                skip_other = pytest.mark.skip(reason='Skipping non-benchmark (--benchmark-only active).')
                for item in items:
            Severity: Minor
            Found in src/pytest_benchmark/plugin.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 31 lines of code (exceeds 25 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 1 hr to fix

              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 _raw has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
              Open

                  def _raw(self, function_to_benchmark, *args, **kwargs):
                      if self.enabled:
                          runner = self._make_runner(function_to_benchmark, args, kwargs)
              
                          duration, iterations, loops_range = self._calibrate_timer(runner)
              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

              Severity
              Category
              Status
              Source
              Language