borgbackup/borg

View on GitHub

Showing 507 of 611 total issues

Function _translate_alternatives has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

def _translate_alternatives(pat):
    """Translates the shell-style alternative portions of the pattern to regular expression groups.

    For example: {alt1,alt2} -> (alt1|alt2)
    """
Severity: Minor
Found in src/borg/helpers/shellpattern.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_item_uid_gid has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

def get_item_uid_gid(item, *, numeric, uid_forced=None, gid_forced=None, uid_default=0, gid_default=0):
    if uid_forced is not None:
        uid = uid_forced
    else:
        uid = None if numeric else user2uid(item.get("user"))
Severity: Minor
Found in src/borg/archive.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 check_free_space has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

    def check_free_space(self):
        """Pre-commit check for sufficient free space necessary to perform the commit."""
        # As a baseline we take four times the current (on-disk) index size.
        # At this point the index may only be updated by compaction, which won't resize it.
        # We still apply a factor of four so that a later, separate invocation can free space
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 get_tar_filter has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

def get_tar_filter(fname, decompress):
    # Note that filter is None if fname is '-'.
    if fname.endswith((".tar.gz", ".tgz")):
        filter = "gzip -d" if decompress else "gzip"
    elif fname.endswith((".tar.bz2", ".tbz")):
Severity: Minor
Found in src/borg/archiver/tar_cmds.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_all_parsers has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

def get_all_parsers():
    # Return dict mapping command to parser.
    parser = Archiver(prog="borg").build_parser()
    borgfs_parser = Archiver(prog="borgfs").build_parser()
    parsers = {}
Severity: Minor
Found in src/borg/testsuite/archiver/help_cmd_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 do_repo_compress has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

    def do_repo_compress(self, args, repository, manifest, cache):
        """Repository (re-)compression"""

        def get_csettings(c):
            if isinstance(c, Auto):
Severity: Minor
Found in src/borg/archiver/repo_compress_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 are_acls_working has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

def are_acls_working():
    with unopened_tempfile() as filepath:
        open(filepath, "w").close()
        try:
            if is_darwin:
Severity: Minor
Found in src/borg/testsuite/platform_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 _write_files_cache has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

    def _write_files_cache(self, files):
        """write files cache to cache directory"""
        max_time_ns = 2**63 - 1  # nanoseconds, good until y2262
        # _self._newest_cmtime might be None if it was never set because no files were modified/added.
        newest_cmtime = self._newest_cmtime if self._newest_cmtime is not None else max_time_ns
Severity: Minor
Found in src/borg/cache.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 logger.py has 252 lines of code (exceeds 250 allowed). Consider refactoring.
Open

"""logging facilities

The way to use this is as follows:

* each module declares its own logger, using:
Severity: Minor
Found in src/borg/logger.py - About 2 hrs to fix

    Function daemonizing has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
    Open

    def daemonizing(*, timeout=5):
        """Like daemonize(), but as context manager.
    
        The with-body is executed in the background process,
        while the foreground process survives until the body is left
    Severity: Minor
    Found in src/borg/helpers/process.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 rebuild_archives_directory has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
    Open

        def rebuild_archives_directory(self):
            """Rebuild the archives directory, undeleting archives.
    
            Iterates through all objects in the repository looking for archive metadata blocks.
            When finding some that do not have a corresponding archives directory entry, it will
    Severity: Minor
    Found in src/borg/archive.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 test_prune_quarterly has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
    Open

    def test_prune_quarterly(archivers, request):
        # Example worked through by hand when developing quarterly
        # strategy, based upon existing backups where quarterly strategy
        # is desired. Weekly/monthly backups that don't affect results were
        # trimmed to speed up the test.
    Severity: Minor
    Found in src/borg/testsuite/archiver/prune_cmd_test.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 resolve has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
    Open

            def resolve(self, args: argparse.Namespace):  # Namespace has "in" but otherwise is not like a dict.
                """
                Resolve the multiple definitions of each common option to the final value.
                """
                for suffix in self.suffix_precedence:
    Severity: Minor
    Found in src/borg/archiver/__init__.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 do_repo_space has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
    Open

        def do_repo_space(self, args, repository):
            """Manage reserved space in repository"""
            # we work without locking here because locks don't work with full disk.
            if args.reserve_space > 0:
                storage_space_reserve_object_size = 64 * 2**20  # 64 MiB per object
    Severity: Minor
    Found in src/borg/archiver/repo_space_cmd.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 load has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
    Open

        def load(self):
            try:
                with open(self.path) as f:
                    data = json.load(f)
    
    
    Severity: Minor
    Found in src/borg/fslocking.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 _build_files_cache has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
    Open

        def _build_files_cache(self):
            """rebuild the files cache by reading previous archive from repository"""
            if "d" in self.cache_mode:  # d(isabled)
                return
    
    
    Severity: Minor
    Found in src/borg/cache.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 _rec_walk has 15 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        def _rec_walk(
    Severity: Major
    Found in src/borg/archiver/create_cmd.py - About 1 hr to fix

      Function build_parser has 44 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def build_parser(self):
              from ._common import define_common_options
      
              parser = argparse.ArgumentParser(prog=self.prog, description="Borg - Deduplicated Backups", add_help=False)
              # paths and patterns must have an empty list as default everywhere
      Severity: Minor
      Found in src/borg/archiver/__init__.py - About 1 hr to fix

        Function detect has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
        Open

            def detect(cls, repository, manifest_data):
                key = cls(repository)
                target = key.find_key()
                prompt = "Enter passphrase for key %s: " % target
                passphrase = Passphrase.env_passphrase()
        Severity: Minor
        Found in src/borg/crypto/key.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 upgrade_item has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
        Open

            def upgrade_item(self, *, item):
                """upgrade item as needed, get rid of legacy crap"""
                ITEM_KEY_WHITELIST = {
                    "path",
                    "rdev",
        Severity: Minor
        Found in src/borg/upgrade.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

        Severity
        Category
        Status
        Source
        Language