borgbackup/borg

View on GitHub

Showing 611 of 611 total issues

Function serve has a Cognitive Complexity of 85 (exceeds 5 allowed). Consider refactoring.
Open

    def serve(self):
        def inner_serve():
            os.set_blocking(self.stdin_fd, False)
            assert not os.get_blocking(self.stdin_fd)
            os.set_blocking(self.stdout_fd, True)
Severity: Minor
Found in src/borg/remote.py - About 1 day 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 cache.py has 725 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import configparser
import io
import os
import shutil
import stat
Severity: Major
Found in src/borg/cache.py - About 1 day to fix

    Function rst_to_text has a Cognitive Complexity of 83 (exceeds 5 allowed). Consider refactoring.
    Open

    def rst_to_text(text, state_hook=None, references=None):
        """
        Convert rST to a more human text form.
    
        This is a very loose conversion. No advanced rST features are supported.
    Severity: Minor
    Found in src/borg/helpers/nanorst.py - About 1 day 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_transfer_upgrade has a Cognitive Complexity of 71 (exceeds 5 allowed). Consider refactoring.
    Open

    def test_transfer_upgrade(archivers, request):
        archiver = request.getfixturevalue(archivers)
        if archiver.get_kind() in ["remote", "binary"]:
            pytest.skip("only works locally")
    
    
    Severity: Minor
    Found in src/borg/testsuite/archiver/transfer_cmd_test.py - About 1 day 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 extract_cmd_test.py has 563 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import errno
    import os
    import shutil
    import time
    from unittest.mock import patch
    Severity: Major
    Found in src/borg/testsuite/archiver/extract_cmd_test.py - About 1 day to fix

      Function check has a Cognitive Complexity of 60 (exceeds 5 allowed). Consider refactoring.
      Open

          def check(self, repair=False, max_duration=0):
              """Check repository consistency"""
      
              def log_error(msg):
                  nonlocal obj_corrupted
      Severity: Minor
      Found in src/borg/repository.py - About 1 day 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 has a Cognitive Complexity of 60 (exceeds 5 allowed). Consider refactoring.
      Open

          def check(self, repair=False, max_duration=0):
              """Check repository consistency
      
              This method verifies all segment checksums and makes sure
              the index is consistent with the data stored in the segments.
      Severity: Minor
      Found in src/borg/legacyrepository.py - About 1 day 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 a Cognitive Complexity of 60 (exceeds 5 allowed). Consider refactoring.
      Open

          def _rec_walk(
              self,
              *,
              path,
              parent_fd,
      Severity: Minor
      Found in src/borg/archiver/create_cmd.py - About 1 day 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 _common.py has 555 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      import functools
      import os
      import textwrap
      
      import borg
      Severity: Major
      Found in src/borg/archiver/_common.py - About 1 day to fix

        Function restore_attrs has a Cognitive Complexity of 59 (exceeds 5 allowed). Consider refactoring.
        Open

            def restore_attrs(self, path, item, symlink=False, fd=None):
                """
                Restore filesystem attributes on *path* (*fd*) from *item*.
        
                Does not access the repository.
        Severity: Minor
        Found in src/borg/archive.py - About 1 day 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

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

        @pytest.mark.skipif(not is_utime_fully_supported(), reason="cannot properly setup and execute test without utime")
        def test_directory_timestamps3(archivers, request):
            archiver = request.getfixturevalue(archivers)
            create_test_files(archiver.input_path)
            cmd(archiver, "repo-create", RK_ENCRYPTION)
        Severity: Major
        Found in src/borg/testsuite/archiver/extract_cmd_test.py and 1 other location - About 1 day to fix
        src/borg/testsuite/archiver/extract_cmd_test.py on lines 87..102

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

        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

        @pytest.mark.skipif(not is_utime_fully_supported(), reason="cannot properly setup and execute test without utime")
        def test_directory_timestamps2(archivers, request):
            archiver = request.getfixturevalue(archivers)
            create_test_files(archiver.input_path)
            cmd(archiver, "repo-create", RK_ENCRYPTION)
        Severity: Major
        Found in src/borg/testsuite/archiver/extract_cmd_test.py and 1 other location - About 1 day to fix
        src/borg/testsuite/archiver/extract_cmd_test.py on lines 105..120

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

        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

        File __init__.py has 542 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        # borg cli interface / toplevel archiver code
        
        import sys
        import traceback
        
        
        Severity: Major
        Found in src/borg/archiver/__init__.py - About 1 day to fix

          File fuse.py has 539 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          import errno
          import functools
          import io
          import os
          import stat
          Severity: Major
          Found in src/borg/fuse.py - About 1 day to fix

            File patterns_test.py has 535 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            import argparse
            import io
            import os.path
            import sys
            
            
            Severity: Major
            Found in src/borg/testsuite/patterns_test.py - About 1 day to fix

              Function test_basic_functionality has a Cognitive Complexity of 56 (exceeds 5 allowed). Consider refactoring.
              Open

              def test_basic_functionality(archivers, request):
                  archiver = request.getfixturevalue(archivers)
                  # Setup files for the first snapshot
                  create_regular_file(archiver.input_path, "empty", size=0)
                  create_regular_file(archiver.input_path, "file_unchanged", size=128)
              Severity: Minor
              Found in src/borg/testsuite/archiver/diff_cmd_test.py - About 1 day 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 debug_cmd.py has 526 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              import argparse
              import functools
              import json
              import textwrap
              
              
              Severity: Major
              Found in src/borg/archiver/debug_cmd.py - About 1 day to fix

                Function _process_any has a Cognitive Complexity of 52 (exceeds 5 allowed). Consider refactoring.
                Open

                    def _process_any(self, *, path, parent_fd, name, st, fso, cache, read_special, dry_run, strip_prefix):
                        """
                        Call the right method on the given FilesystemObjectProcessor.
                        """
                
                
                Severity: Minor
                Found in src/borg/archiver/create_cmd.py - About 1 day 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 yes has a Cognitive Complexity of 51 (exceeds 5 allowed). Consider refactoring.
                Open

                def yes(
                    msg=None,
                    false_msg=None,
                    true_msg=None,
                    default_msg=None,
                Severity: Minor
                Found in src/borg/helpers/yes_no.py - About 7 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 process_file has a Cognitive Complexity of 51 (exceeds 5 allowed). Consider refactoring.
                Open

                    def process_file(self, *, path, parent_fd, name, st, cache, flags=flags_normal, last_try=False, strip_prefix):
                        with self.create_helper(path, st, None, strip_prefix=strip_prefix) as (
                            item,
                            status,
                            hardlinked,
                Severity: Minor
                Found in src/borg/archive.py - About 7 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