borgbackup/borg

View on GitHub

Showing 611 of 611 total issues

Function _log_warning has 6 arguments (exceeds 4 allowed). Consider refactoring.
Open

def _log_warning(message, category, filename, lineno, file=None, line=None):
Severity: Minor
Found in src/borg/logger.py - About 45 mins to fix

    Avoid deeply nested control flow statements.
    Open

                            while time.monotonic() - started < self.timeout:
                                locks = self._find_locks(only_exclusive=False)
                                if len(locks) == 1 and locks[0]["key"] == key:
                                    logger.debug("LOCK-ACQUIRE: success! no non-exclusive locks are left!")
                                    return self
    Severity: Major
    Found in src/borg/storelocking.py - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                              if not isinstance(unpacked, dict):
                                  raise UnexpectedRPCDataFormatFromServer(data)
      
      
      Severity: Major
      Found in src/borg/remote.py - About 45 mins to fix

        Function export_paperkey has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            def export_paperkey(self, path):
                if path is None:
                    path = "-"
        
                def grouped(s):
        Severity: Minor
        Found in src/borg/crypto/keymanager.py - About 45 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

        Avoid deeply nested control flow statements.
        Open

                                if option.metavar:
                                    option_fmt = "``%s " + option.metavar + "``"
                                else:
                                    option_fmt = "``%s``"
                                option_str = ", ".join(option_fmt % s for s in option.option_strings)
        Severity: Major
        Found in scripts/make.py - About 45 mins to fix

          Function call_many has 6 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              def call_many(self, cmd, calls, wait=True, is_preloaded=False, async_wait=True):
          Severity: Minor
          Found in src/borg/remote.py - About 45 mins to fix

            Function exists_name_and_ts has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                def exists_name_and_ts(self, name, ts):
                    # check if an archive with this name AND timestamp exists
                    assert isinstance(name, str)
                    assert isinstance(ts, datetime)
                    if not self.legacy:
            Severity: Minor
            Found in src/borg/manifest.py - About 45 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 _lookup_name has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                def _lookup_name(self, name, raw=False):
                    assert isinstance(name, str)
                    assert not self.legacy
                    for archive_info in self._infos():
                        if archive_info["exists"] and archive_info["name"] == name:
            Severity: Minor
            Found in src/borg/manifest.py - About 45 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 issue has 6 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                    def issue(name, rawtext, text, lineno, inliner, options={}, content=[]):
            Severity: Minor
            Found in scripts/make.py - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                                      if msgid in self.ignore_responses:
                                          self.ignore_responses.remove(msgid)
                                          # async methods never return values, but may raise exceptions.
                                          if "exception_class" in unpacked:
                                              self.async_responses[msgid] = unpacked
              Severity: Major
              Found in src/borg/remote.py - About 45 mins to fix

                Function __init__ has 6 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                    def __init__(self, store, exclusive=False, sleep=None, timeout=1.0, stale=30 * 60, id=None):
                Severity: Minor
                Found in src/borg/storelocking.py - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                                              if self.repository is not None:
                                                  self.repository.close()
                                              raise UnexpectedRPCDataFormatFromClient(__version__)
                  Severity: Major
                  Found in src/borg/remote.py - About 45 mins to fix

                    Function os_open has 6 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

                    def os_open(*, flags, path=None, parent_fd=None, name=None, noatime=False):
                    Severity: Minor
                    Found in src/borg/helpers/fs.py - About 45 mins to fix

                      Function format_owner has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                      Open

                          def format_owner(self, diff: "ItemDiff", spec: Literal["owner", "user", "group"] = "owner"):
                              if spec == "user":
                                  change = diff.user()
                                  return f"[{change.diff_data['item1']} -> {change.diff_data['item2']}]" if change else ""
                              if spec == "group":
                      Severity: Minor
                      Found in src/borg/helpers/parseformat.py - About 45 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_item_data has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                      Open

                          def get_item_data(self, item: "ItemDiff", jsonline=False) -> dict:
                              diff_data = {}
                              for key in self.used_call_keys:
                                  diff_data[key] = self.call_keys[key](item)
                      
                      
                      Severity: Minor
                      Found in src/borg/helpers/parseformat.py - About 45 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 safe_unlink has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                      Open

                      def safe_unlink(path):
                          """
                          Safely unlink (delete) *path*.
                      
                          If we run out of space while deleting the file, we try truncating it first.
                      Severity: Minor
                      Found in src/borg/helpers/fs.py - About 45 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

                      Avoid deeply nested control flow statements.
                      Open

                                          while True:
                                              char = text.peek(1)
                                              if char == "`":
                                                  text.read(1)
                                                  break
                      Severity: Major
                      Found in src/borg/helpers/nanorst.py - About 45 mins to fix

                        Avoid deeply nested control flow statements.
                        Open

                                            if directive == "nanorst: inline-fill":
                                                inline_mode = "fill"
                                            elif directive == "nanorst: inline-replace":
                                                inline_mode = "replace"
                                            continue
                        Severity: Major
                        Found in src/borg/helpers/nanorst.py - About 45 mins to fix

                          Function unpack has 6 arguments (exceeds 4 allowed). Consider refactoring.
                          Open

                          def unpack(stream, *, raw=RAW, unicode_errors=UNICODE_ERRORS, strict_map_key=False, **kwargs):
                          Severity: Minor
                          Found in src/borg/helpers/msgpack.py - About 45 mins to fix

                            Function process_file_chunks has 6 arguments (exceeds 4 allowed). Consider refactoring.
                            Open

                                def process_file_chunks(self, item, cache, stats, show_progress, chunk_iter, chunk_processor=None):
                            Severity: Minor
                            Found in src/borg/archive.py - About 45 mins to fix
                              Severity
                              Category
                              Status
                              Source
                              Language