borgbackup/borg

View on GitHub
src/borg/testsuite/hashindex.py

Summary

Maintainability
C
1 day
Test Coverage

File hashindex.py has 455 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# Note: these tests are part of the self test, do not use or import pytest functionality here.
#       See borg.selftest for details. If you add/remove test methods, update SELFTEST_COUNT

import base64
import hashlib
Severity: Minor
Found in src/borg/testsuite/hashindex.py - About 6 hrs to fix

    Function _generic_test has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

        def _generic_test(self, cls, make_value, sha):
            idx = cls()
            self.assert_equal(len(idx), 0)
            # Test set
            for x in range(100):
    Severity: Minor
    Found in src/borg/testsuite/hashindex.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 test_chunk_indexer has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def test_chunk_indexer(self):
            # see _hashindex.c hash_sizes, we want to be close to the max. load
            # because interesting errors happen there.
            key_count = int(65537 * ChunkIndex.MAX_LOAD_FACTOR) - 10
            index = ChunkIndex(key_count)
    Severity: Minor
    Found in src/borg/testsuite/hashindex.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