borgbackup/borg

View on GitHub

Showing 611 of 611 total issues

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_test.py - About 1 hr to fix

    Function format has 8 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        def format(
    Severity: Major
    Found in src/borg/repoobj.py - About 1 hr to fix

      Function _create_archive_ts has 8 arguments (exceeds 4 allowed). Consider refactoring.
      Open

      def _create_archive_ts(archiver, name, y, m, d, H=0, M=0, S=0):
      Severity: Major
      Found in src/borg/testsuite/archiver/prune_cmd_test.py - About 1 hr to fix

        Function format has 8 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            def format(
        Severity: Major
        Found in src/borg/repoobj.py - About 1 hr to fix

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

                  subparser = subparsers.add_parser(
                      "list",
                      parents=[common_parser],
                      add_help=False,
                      description=self.do_list.__doc__,
          Severity: Major
          Found in src/borg/archiver/list_cmd.py and 7 other locations - About 1 hr to fix
          src/borg/archiver/check_cmd.py on lines 190..196
          src/borg/archiver/extract_cmd.py on lines 135..141
          src/borg/archiver/info_cmd.py on lines 79..85
          src/borg/archiver/rename_cmd.py on lines 31..37
          src/borg/archiver/repo_list_cmd.py on lines 88..94
          src/borg/archiver/serve_cmd.py on lines 46..52
          src/borg/archiver/tar_cmds.py on lines 383..389

          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 38.

          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 __init__ has 8 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              def __init__(
          Severity: Major
          Found in src/borg/cache.py - About 1 hr to fix

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

                    subparser = subparsers.add_parser(
                        "info",
                        parents=[common_parser],
                        add_help=False,
                        description=self.do_info.__doc__,
            Severity: Major
            Found in src/borg/archiver/info_cmd.py and 7 other locations - About 1 hr to fix
            src/borg/archiver/check_cmd.py on lines 190..196
            src/borg/archiver/extract_cmd.py on lines 135..141
            src/borg/archiver/list_cmd.py on lines 91..97
            src/borg/archiver/rename_cmd.py on lines 31..37
            src/borg/archiver/repo_list_cmd.py on lines 88..94
            src/borg/archiver/serve_cmd.py on lines 46..52
            src/borg/archiver/tar_cmds.py on lines 383..389

            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 38.

            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 8 locations. Consider refactoring.
            Open

                    subparser = subparsers.add_parser(
                        "repo-list",
                        parents=[common_parser],
                        add_help=False,
                        description=self.do_repo_list.__doc__,
            Severity: Major
            Found in src/borg/archiver/repo_list_cmd.py and 7 other locations - About 1 hr to fix
            src/borg/archiver/check_cmd.py on lines 190..196
            src/borg/archiver/extract_cmd.py on lines 135..141
            src/borg/archiver/info_cmd.py on lines 79..85
            src/borg/archiver/list_cmd.py on lines 91..97
            src/borg/archiver/rename_cmd.py on lines 31..37
            src/borg/archiver/serve_cmd.py on lines 46..52
            src/borg/archiver/tar_cmds.py on lines 383..389

            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 38.

            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 8 locations. Consider refactoring.
            Open

                    subparser = subparsers.add_parser(
                        "rename",
                        parents=[common_parser],
                        add_help=False,
                        description=self.do_rename.__doc__,
            Severity: Major
            Found in src/borg/archiver/rename_cmd.py and 7 other locations - About 1 hr to fix
            src/borg/archiver/check_cmd.py on lines 190..196
            src/borg/archiver/extract_cmd.py on lines 135..141
            src/borg/archiver/info_cmd.py on lines 79..85
            src/borg/archiver/list_cmd.py on lines 91..97
            src/borg/archiver/repo_list_cmd.py on lines 88..94
            src/borg/archiver/serve_cmd.py on lines 46..52
            src/borg/archiver/tar_cmds.py on lines 383..389

            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 38.

            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 8 locations. Consider refactoring.
            Open

                    subparser = subparsers.add_parser(
                        "check",
                        parents=[common_parser],
                        add_help=False,
                        description=self.do_check.__doc__,
            Severity: Major
            Found in src/borg/archiver/check_cmd.py and 7 other locations - About 1 hr to fix
            src/borg/archiver/extract_cmd.py on lines 135..141
            src/borg/archiver/info_cmd.py on lines 79..85
            src/borg/archiver/list_cmd.py on lines 91..97
            src/borg/archiver/rename_cmd.py on lines 31..37
            src/borg/archiver/repo_list_cmd.py on lines 88..94
            src/borg/archiver/serve_cmd.py on lines 46..52
            src/borg/archiver/tar_cmds.py on lines 383..389

            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 38.

            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 8 locations. Consider refactoring.
            Open

                    subparser = subparsers.add_parser(
                        "extract",
                        parents=[common_parser],
                        add_help=False,
                        description=self.do_extract.__doc__,
            Severity: Major
            Found in src/borg/archiver/extract_cmd.py and 7 other locations - About 1 hr to fix
            src/borg/archiver/check_cmd.py on lines 190..196
            src/borg/archiver/info_cmd.py on lines 79..85
            src/borg/archiver/list_cmd.py on lines 91..97
            src/borg/archiver/rename_cmd.py on lines 31..37
            src/borg/archiver/repo_list_cmd.py on lines 88..94
            src/borg/archiver/serve_cmd.py on lines 46..52
            src/borg/archiver/tar_cmds.py on lines 383..389

            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 38.

            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 8 locations. Consider refactoring.
            Open

                    subparser = subparsers.add_parser(
                        "export-tar",
                        parents=[common_parser],
                        add_help=False,
                        description=self.do_export_tar.__doc__,
            Severity: Major
            Found in src/borg/archiver/tar_cmds.py and 7 other locations - About 1 hr to fix
            src/borg/archiver/check_cmd.py on lines 190..196
            src/borg/archiver/extract_cmd.py on lines 135..141
            src/borg/archiver/info_cmd.py on lines 79..85
            src/borg/archiver/list_cmd.py on lines 91..97
            src/borg/archiver/rename_cmd.py on lines 31..37
            src/borg/archiver/repo_list_cmd.py on lines 88..94
            src/borg/archiver/serve_cmd.py on lines 46..52

            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 38.

            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 8 locations. Consider refactoring.
            Open

                    subparser = subparsers.add_parser(
                        "serve",
                        parents=[common_parser],
                        add_help=False,
                        description=self.do_serve.__doc__,
            Severity: Major
            Found in src/borg/archiver/serve_cmd.py and 7 other locations - About 1 hr to fix
            src/borg/archiver/check_cmd.py on lines 190..196
            src/borg/archiver/extract_cmd.py on lines 135..141
            src/borg/archiver/info_cmd.py on lines 79..85
            src/borg/archiver/list_cmd.py on lines 91..97
            src/borg/archiver/rename_cmd.py on lines 31..37
            src/borg/archiver/repo_list_cmd.py on lines 88..94
            src/borg/archiver/tar_cmds.py on lines 383..389

            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 38.

            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

                    fmap = [(0, 123, True), (123, 4096, True), (123 + 4096, 4096, True), (123 + 8192, 4096, True)]
            Severity: Major
            Found in src/borg/testsuite/chunker_test.py and 1 other location - About 1 hr to fix
            src/borg/testsuite/chunker_test.py on lines 61..61

            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 38.

            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

                    fmap = [(0, 123, True), (123, 4096, False), (123 + 4096, 4096, True), (123 + 8192, 4096, False)]
            Severity: Major
            Found in src/borg/testsuite/chunker_test.py and 1 other location - About 1 hr to fix
            src/borg/testsuite/chunker_test.py on lines 52..52

            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 38.

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

                def find_key(self):
                    if self.STORAGE == KeyBlobStorage.KEYFILE:
                        keyfile = self._find_key_file_from_environment()
                        if keyfile is not None:
                            return self.sanity_check(keyfile, self.repository.id)
            Severity: Minor
            Found in src/borg/crypto/key.py - About 55 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 set_all has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

            def set_all(path, xattrs, follow_symlinks=False):
                """
                Set all extended attributes on *path* from a mapping.
            
                *path* can either be a path (str or bytes) or an open file descriptor (int).
            Severity: Minor
            Found in src/borg/xattr.py - About 55 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 add_entry has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

                def add_entry(self, key, data, cache, complete):
                    transformed = self.transform(key, data)
                    if not cache:
                        return transformed
                    packed = self.pack(transformed)
            Severity: Minor
            Found in src/borg/remote.py - About 55 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 write_options_group has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

                def write_options_group(self, write, group):
                    def is_positional_group(group):
                        return any(not o.option_strings for o in group._group_actions)
            
                    if is_positional_group(group):
            Severity: Minor
            Found in scripts/make.py - About 55 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 exists_name_and_id has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

                def exists_name_and_id(self, name, id):
                    # check if an archive with this name AND id exists
                    assert isinstance(name, str)
                    assert isinstance(id, bytes)
                    if not self.legacy:
            Severity: Minor
            Found in src/borg/manifest.py - About 55 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