psyinfra/onyo

View on GitHub

Showing 56 of 56 total issues

File commands.py has 1066 lines of code (exceeds 250 allowed). Consider refactoring.
Open

from __future__ import annotations

import copy
import logging
import subprocess
Severity: Major
Found in onyo/lib/commands.py - About 2 days to fix

    File onyo.py has 574 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    from __future__ import annotations
    
    import logging
    import shutil
    import subprocess
    Severity: Major
    Found in onyo/lib/onyo.py - About 1 day to fix

      File inventory.py has 540 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      from __future__ import annotations
      
      from dataclasses import dataclass
      from functools import partial
      from pathlib import Path
      Severity: Major
      Found in onyo/lib/inventory.py - About 1 day to fix

        File main.py has 421 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        from __future__ import annotations
        
        import os
        import re
        import sys
        Severity: Minor
        Found in onyo/main.py - About 6 hrs to fix

          Function is_equal_assets_dict has a Cognitive Complexity of 39 (exceeds 5 allowed). Consider refactoring.
          Open

          def is_equal_assets_dict(a: Dict | UserDict, b: Dict | UserDict) -> bool:
              r"""Whether two asset dictionaries have the same content.
          
              This accounts for comments in YAML.
              For this to return `True`, both assets need to
          Severity: Minor
          Found in onyo/lib/utils.py - About 5 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 _edit_asset has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring.
          Open

          def _edit_asset(inventory: Inventory,
                          asset: dict | UserDict,
                          operation: Callable,
                          editor: str | None) -> dict | UserDict:
              r"""Edit `asset` via configured editor and a temporary asset file.
          Severity: Minor
          Found in onyo/lib/commands.py - About 5 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

          File git.py has 328 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          from __future__ import annotations
          
          import logging
          import subprocess
          from pathlib import Path
          Severity: Minor
          Found in onyo/lib/git.py - About 3 hrs to fix

            Function main has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
            Open

            def main() -> None:
                r"""Execute Onyo's CLI.
                """
                #
                # ARGPARSE Hack #1
            Severity: Minor
            Found in onyo/main.py - About 3 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

            File utils.py has 297 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            from __future__ import annotations
            
            import copy
            from collections import UserDict
            from io import StringIO
            Severity: Minor
            Found in onyo/lib/utils.py - About 3 hrs to fix

              Function onyo_get has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
              Open

              def onyo_get(inventory: Inventory,
                           include: list[Path] | None = None,
                           exclude: list[Path] | Path | None = None,
                           depth: int = 0,
                           machine_readable: bool = False,
              Severity: Minor
              Found in onyo/lib/commands.py - About 2 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 setup_parser has 69 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              def setup_parser() -> OnyoArgumentParser:
                  r"""Setup and return a fully populated OnyoArgumentParser for Onyo and all subcommands.
                  """
                  from onyo.onyo_arguments import args_onyo
                  from onyo.cli.cat import args_cat, epilog_cat
              Severity: Major
              Found in onyo/main.py - About 2 hrs to fix

                Function __getitem__ has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
                Open

                    def __getitem__(self, key):
                        if isinstance(key, str):
                            parts = key.split('.')
                            effective_dict = self.data
                            if len(parts) > 1:
                Severity: Minor
                Found in onyo/lib/utils.py - About 2 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

                OnyoRepo has 21 functions (exceeds 20 allowed). Consider refactoring.
                Open

                class OnyoRepo(object):
                    r"""
                    An object representing an Onyo repository.
                
                    Allows identifying and working with asset paths and directories, getting and
                Severity: Minor
                Found in onyo/lib/onyo.py - About 2 hrs to fix

                  Function new has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
                  Open

                  def new(args: argparse.Namespace) -> None:
                      r"""
                      Create new **ASSET**\ s and populate with **KEY-VALUE** pairs. Destination
                      directories are created if they are missing.
                  
                  
                  Severity: Minor
                  Found in onyo/cli/new.py - About 2 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 remove_directory has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def remove_directory(self, directory: Path, recursive: bool = True) -> list[InventoryOperation]:
                          if directory in self._get_pending_removals(mode='dirs'):
                              ui.log_debug(f"{directory} already queued for removal")
                              # TODO: Consider NoopError when addressing #546.
                              return []
                  Severity: Minor
                  Found in onyo/lib/inventory.py - About 1 hr 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 __call__ has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def __call__(self,
                                   parser: argparse.ArgumentParser,
                                   namespace: argparse.Namespace,
                                   key_values: list[str],
                                   option_string: str | None = None) -> None:
                  Severity: Minor
                  Found in onyo/argparse_helpers.py - About 1 hr 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 request_user_response has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def request_user_response(self,
                                                question: str,
                                                default: str = 'yes',
                                                answers: list[tuple] | None = None) -> Any:
                          r"""Print `question` and read a response from `stdin`.
                  Severity: Minor
                  Found in onyo/lib/ui.py - About 1 hr 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 generate_auto_message has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def generate_auto_message(format_string: str,
                                                max_length: int = 80,
                                                **kwargs) -> str:
                          r"""Generate a commit message subject.
                  
                  
                  Severity: Minor
                  Found in onyo/lib/onyo.py - About 1 hr 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 modify_asset has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def modify_asset(self, asset: dict | UserDict | Path, new_asset: dict | UserDict) -> list[InventoryOperation]:
                          operations = []
                          path = asset if isinstance(asset, Path) else Path(asset.get('path'))
                          if not self.repo.is_asset_path(path):
                              raise ValueError(f"No such asset: {path}")
                  Severity: Minor
                  Found in onyo/lib/inventory.py - About 1 hr 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_asset has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def add_asset(self, asset: dict | UserDict) -> list[InventoryOperation]:
                          # TODO: what if I call this with a modified (possibly moved) asset?
                          # -> check for conflicts and raise InvalidInventoryOperationError("something about either commit first or rest")
                          operations = []
                          path = None
                  Severity: Minor
                  Found in onyo/lib/inventory.py - About 1 hr 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