borgbackup/borg

View on GitHub

Showing 507 of 611 total issues

Avoid too many return statements within this function.
Open

            return True, None
Severity: Major
Found in src/borg/cache.py - About 30 mins to fix

    Avoid too many return statements within this function.
    Open

                        return False
    Severity: Major
    Found in src/borg/fslocking.py - About 30 mins to fix

      Avoid too many return statements within this function.
      Open

                  return True, None
      Severity: Major
      Found in src/borg/cache.py - About 30 mins to fix

        Avoid too many return statements within this function.
        Open

                return True, chunks
        Severity: Major
        Found in src/borg/cache.py - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

                          return False
          Severity: Major
          Found in src/borg/fslocking.py - About 30 mins to fix

            Function load has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                def load(self, target, passphrase):
                    if self.STORAGE == KeyBlobStorage.KEYFILE:
                        with open(target) as fd:
                            key_data = "".join(fd.readlines()[1:])
                    elif self.STORAGE == KeyBlobStorage.REPO:
            Severity: Minor
            Found in src/borg/crypto/key.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

            Function sanity_check has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                def sanity_check(self, filename, id):
                    file_id = self.FILE_ID.encode() + b" "
                    repo_id = bin_to_hex(id).encode("ascii")
                    with open(filename, "rb") as fd:
                        # we do the magic / id check in binary mode to avoid stumbling over
            Severity: Minor
            Found in src/borg/crypto/key.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

            Function filter_archives_by_date has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

            def filter_archives_by_date(archives, older=None, newer=None, oldest=None, newest=None):
                def get_first_and_last_archive_ts(archives_list):
                    timestamps = [x.ts for x in archives_list]
                    return min(timestamps), max(timestamps)
            
            
            Severity: Minor
            Found in src/borg/manifest.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

            Function sizeof_fmt has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

            def sizeof_fmt(num, suffix="B", units=None, power=None, sep="", precision=2, sign=False):
                sign = "+" if sign and num > 0 else ""
                fmt = "{0:{1}.{2}f}{3}{4}{5}"
                prec = 0
                for unit in units[:-1]:
            Severity: Minor
            Found in src/borg/helpers/parseformat.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

            Function keys_help has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                def keys_help(cls):
                    help = []
                    keys: Set[str] = set()
                    keys.update(cls.KEY_DESCRIPTIONS.keys())
                    keys.update(key for group in cls.KEY_GROUPS for key in group)
            Severity: Minor
            Found in src/borg/helpers/parseformat.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

            Function decode_tuple has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                def decode_tuple(t):
                    res = []
                    for value in t:
                        if isinstance(value, dict):
                            value = decode(value)
            Severity: Minor
            Found in src/borg/helpers/parseformat.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

            Function _find_locks has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                def _find_locks(self, *, only_exclusive=False, only_mine=False):
                    locks = self._get_locks()
                    found_locks = []
                    for key in locks:
                        lock = locks[key]
            Severity: Minor
            Found in src/borg/storelocking.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

            Function read has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                def read(self, n):
                    if not self.closed:
                        try:
                            return super().read(n)
                        except BrokenPipeError:
            Severity: Minor
            Found in src/borg/helpers/misc.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

            Function __logger has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                def __logger(self):
                    if self.__real_logger is None:
                        if not configured:
                            raise Exception("tried to call a logger before setup_logging() was called")
                        self.__real_logger = logging.getLogger(self.__name)
            Severity: Minor
            Found in src/borg/logger.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

            Function list has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                def list(
                    self,
                    *,
                    match=None,
                    match_end=r"\Z",
            Severity: Minor
            Found in src/borg/manifest.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

            Function dash_open has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

            def dash_open(path, mode):
                assert "+" not in mode  # the streams are either r or w, but never both
                if path == "-":
                    stream = sys.stdin if "r" in mode else sys.stdout
                    return stream.buffer if "b" in mode else stream
            Severity: Minor
            Found in src/borg/helpers/fs.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

            Function validator has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                def validator(text):
                    try:
                        loc = Location(text, other=other)
                    except ValueError as err:
                        raise argparse.ArgumentTypeError(str(err)) from None
            Severity: Minor
            Found in src/borg/helpers/parseformat.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

            Function decrypt_key_file has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                def decrypt_key_file(self, data, passphrase):
                    unpacker = get_limited_unpacker("key")
                    unpacker.feed(data)
                    data = unpacker.unpack()
                    encrypted_key = EncryptedKey(internal_dict=data)
            Severity: Minor
            Found in src/borg/crypto/key.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

            Function refresh has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                def refresh(self):
                    """refresh the lock - call this frequently, but not later than every <stale> seconds"""
                    now = datetime.datetime.now(datetime.timezone.utc)
                    if self.last_refresh_dt is not None and now > self.last_refresh_dt + self.refresh_td:
                        old_locks = self._find_locks(only_mine=True)
            Severity: Minor
            Found in src/borg/storelocking.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

            Function get_config_dir has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

            def get_config_dir(*, legacy=False, create=True):
                """Determine where to store whole config"""
            
                # Get config home path
                if legacy:
            Severity: Minor
            Found in src/borg/helpers/fs.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

            Severity
            Category
            Status
            Source
            Language