borgbackup/borg

View on GitHub
src/borg/archiver/benchmark_cmd.py

Summary

Maintainability
C
7 hrs
Test Coverage

File benchmark_cmd.py has 284 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import argparse
from contextlib import contextmanager
import functools
import os
import tempfile
Severity: Minor
Found in src/borg/archiver/benchmark_cmd.py - About 2 hrs to fix

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

        def do_benchmark_crud(self, args):
            """Benchmark Create, Read, Update, Delete for archives."""
    
            def parse_args(args, cmd):
                # we need to inherit some essential options from the "borg benchmark crud" invocation
    Severity: Minor
    Found in src/borg/archiver/benchmark_cmd.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 do_benchmark_cpu has 39 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def do_benchmark_cpu(self, args):
            """Benchmark CPU bound operations."""
            from timeit import timeit
    
            random_10M = os.urandom(10 * 1000 * 1000)
    Severity: Minor
    Found in src/borg/archiver/benchmark_cmd.py - About 1 hr to fix

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

          def do_benchmark_cpu(self, args):
              """Benchmark CPU bound operations."""
              from timeit import timeit
      
              random_10M = os.urandom(10 * 1000 * 1000)
      Severity: Minor
      Found in src/borg/archiver/benchmark_cmd.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

      There are no issues that match your filters.

      Category
      Status