ionelmc/pytest-benchmark

View on GitHub
src/pytest_benchmark/plugin.py

Summary

Maintainability
C
1 day
Test Coverage

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

        def benchmark(request):
            bs = request.config._benchmarksession
        
            if bs.skip:
                pytest.skip('Benchmarks are skipped (--benchmark-skip was used).')
        Severity: Minor
        Found in src/pytest_benchmark/plugin.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

        There are no issues that match your filters.

        Category
        Status