ionelmc/pytest-benchmark

View on GitHub
src/pytest_benchmark/fixture.py

Summary

Maintainability
C
1 day
Test Coverage

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

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

    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 _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

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

          There are no issues that match your filters.

          Category
          Status