borgbackup/borg

View on GitHub

Showing 611 of 611 total issues

Avoid too many return statements within this function.
Open

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

    Avoid too many return statements within this function.
    Open

            return True
    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 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

                Similar blocks of code found in 2 locations. Consider refactoring.
                Open

                    with patch.object(RemoteRepository, "extra_test_args", ["--restrict-to-path", repo_path]):
                        with pytest.raises(PathNotAllowed):
                            remote_archiver.repository_location = original_location + "_0"
                            cmd(remote_archiver, "repo-create", RK_ENCRYPTION)
                Severity: Minor
                Found in src/borg/testsuite/archiver/checks_test.py and 1 other location - About 30 mins to fix
                src/borg/testsuite/archiver/checks_test.py on lines 291..294

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 32.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

                Similar blocks of code found in 2 locations. Consider refactoring.
                Open

                    with patch.object(RemoteRepository, "extra_test_args", ["--restrict-to-path", "/foo"]):
                        with pytest.raises(PathNotAllowed):
                            remote_archiver.repository_location = original_location + "_1"
                            cmd(remote_archiver, "repo-create", RK_ENCRYPTION)
                Severity: Minor
                Found in src/borg/testsuite/archiver/checks_test.py and 1 other location - About 30 mins to fix
                src/borg/testsuite/archiver/checks_test.py on lines 286..289

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 32.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

                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

                Severity
                Category
                Status
                Source
                Language