borgbackup/borg

View on GitHub
src/borg/testsuite/archiver/transfer_cmd.py

Summary

Maintainability
D
1 day
Test Coverage

Function test_transfer_upgrade has a Cognitive Complexity of 71 (exceeds 5 allowed). Consider refactoring.
Open

def test_transfer_upgrade(archivers, request):
    archiver = request.getfixturevalue(archivers)
    if archiver.get_kind() in ["remote", "binary"]:
        pytest.skip("only works locally")

Severity: Minor
Found in src/borg/testsuite/archiver/transfer_cmd.py - About 1 day 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

Consider simplifying this complex logical expression.
Open

                if item.path.endswith("directory") or item.path.endswith("borgtest"):
                    assert stat.S_ISDIR(item.mode)
                    assert item.uid > 0
                    assert "hlid" not in item
                elif item.path.endswith("no_hardlink") or item.path.endswith("target"):
Severity: Major
Found in src/borg/testsuite/archiver/transfer_cmd.py - About 1 hr to fix

    Avoid deeply nested control flow statements.
    Open

                        if not is_win32:
                            # The S_IFBLK macro is broken on MINGW
                            assert stat.S_ISBLK(item.mode)
                        # looks like we can't use os.major/minor with data coming from another platform,
                        # thus we only do a rather rough check here:
    Severity: Major
    Found in src/borg/testsuite/archiver/transfer_cmd.py - About 45 mins to fix

      There are no issues that match your filters.

      Category
      Status