borgbackup/borg

View on GitHub

Showing 507 of 611 total issues

File archive_test.py has 291 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import json
import os
from collections import OrderedDict
from datetime import datetime, timezone
from io import StringIO
Severity: Minor
Found in src/borg/testsuite/archive_test.py - About 3 hrs to fix

    Function rows_to_table has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
    Open

        def rows_to_table(self, rows, write):
            def write_row_separator():
                write("+")
                for column_width in column_widths:
                    write("-" * (column_width + 1))
    Severity: Minor
    Found in scripts/make.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 generate_level has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
    Open

        def generate_level(self, prefix, parser, Archiver, extra_choices=None):
            is_subcommand = False
            choices = {}
            for action in parser._actions:
                if action.choices is not None and "SubParsersAction" in str(action.__class__):
    Severity: Minor
    Found in scripts/make.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 _update_index has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
    Open

        def _update_index(self, segment, objects, report=None):
            """some code shared between replay_segments and check"""
            self.segments[segment] = 0
            for tag, key, offset, size, _ in objects:
                if tag in (TAG_PUT2, TAG_PUT):
    Severity: Minor
    Found in src/borg/legacyrepository.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 with_repository has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
    Open

    def with_repository(
        create=False, lock=True, exclusive=False, manifest=True, cache=False, secure=True, compatibility=None
    ):
        """
        Method decorator for subcommand-handling methods: do_XYZ(self, args, repository, …)
    Severity: Minor
    Found in src/borg/archiver/_common.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_diff has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
    Open

        def do_diff(self, args, repository, manifest):
            """Diff contents of two archives"""
    
            def actual_change(j):
                j = j.to_dict()
    Severity: Minor
    Found in src/borg/archiver/diff_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 test_chunkpoints_unchanged has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
    Open

    def test_chunkpoints_unchanged():
        def twist(size):
            x = 1
            a = bytearray(size)
            for i in range(size):
    Severity: Minor
    Found in src/borg/testsuite/chunker_slow_test.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 kill_stale_lock has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
    Open

        def kill_stale_lock(self):
            try:
                names = os.listdir(self.path)
            except FileNotFoundError:  # another process did our job in the meantime.
                return False
    Severity: Minor
    Found in src/borg/fslocking.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

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

          def __init__(
              self,
              location,
              create=False,
              exclusive=False,
      Severity: Minor
      Found in src/borg/remote.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 get_by_id has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
      Open

          def get_by_id(self, id, raw=False):
              assert isinstance(id, bytes)
              if not self.legacy:
                  if id in self.ids():  # check directory
                      # looks like this archive id is in the archives directory, thus it is NOT deleted.
      Severity: Minor
      Found in src/borg/manifest.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 ChunkerParams has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
      Open

      def ChunkerParams(s):
          params = s.strip().split(",")
          count = len(params)
          if count == 0:
              raise argparse.ArgumentTypeError("no chunker params given")
      Severity: Minor
      Found in src/borg/helpers/parseformat.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 __init__ has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
      Open

          def __init__(
              self,
              location,
              create=False,
              exclusive=False,
      Severity: Minor
      Found in src/borg/legacyremote.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 test_fuse has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
      Open

      def test_fuse(archivers, request):
          archiver = request.getfixturevalue(archivers)
          if archiver.EXE and fakeroot_detected():
              pytest.skip("test_fuse with the binary is not compatible with fakeroot")
      
      
      Severity: Minor
      Found in src/borg/testsuite/archiver/mount_cmds_test.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

      File patterns.py has 279 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      import argparse
      import fnmatch
      import os.path
      import re
      import sys
      Severity: Minor
      Found in src/borg/patterns.py - About 2 hrs to fix

        LoggedIO has 24 functions (exceeds 20 allowed). Consider refactoring.
        Open

        class LoggedIO:
            class SegmentFull(Exception):
                """raised when a segment is full, before opening next"""
        
            header_fmt = struct.Struct("<IIB")
        Severity: Minor
        Found in src/borg/legacyrepository.py - About 2 hrs to fix

          Function build_parser_debug has 65 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              def build_parser_debug(self, subparsers, common_parser, mid_common_parser):
                  debug_epilog = process_epilog(
                      """
                  These commands are not intended for normal use and potentially very
                  dangerous if used incorrectly.
          Severity: Major
          Found in src/borg/archiver/debug_cmd.py - About 2 hrs to fix

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

                def recover_segment(self, segment, filename):
                    logger.info("Attempting to recover " + filename)
                    if segment in self.fds:
                        del self.fds[segment]
                    if os.path.getsize(filename) < MAGIC_LEN + self.header_fmt.size:
            Severity: Minor
            Found in src/borg/legacyrepository.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_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_tag has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
            Open

                def do_tag(self, args, repository, manifest, cache):
                    """Manage tags"""
            
                    def tags_set(tags):
                        """return a set of tags, removing empty tags"""
            Severity: Minor
            Found in src/borg/archiver/tag_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

            Severity
            Category
            Status
            Source
            Language