pyapp-org/pyapp

View on GitHub
src/pyapp/app/arguments.py

Summary

Maintainability
D
2 days
Test Coverage

File arguments.py has 420 lines of code (exceeds 250 allowed). Consider refactoring.
Open

"""
Any command associated with a pyApp application can be expanded with arguments.
Arguments are a set of decorators that utilise ``argparse`` to simplify the
process of accepting and validating input/flags for commands.

Severity: Minor
Found in src/pyapp/app/arguments.py - About 6 hrs to fix

    Function _handle_generics has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
    Open

        def _handle_generics(  # noqa: PLR0912
            origin, type_, positional: bool, kwargs: Dict[str, Any]
        ) -> type:
            """
            Handle generic types
    Severity: Minor
    Found in src/pyapp/app/arguments.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

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

        def __init__(  # noqa: PLR0913
    Severity: Major
    Found in src/pyapp/app/arguments.py - About 1 hr to fix

      Function from_parameter has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

          def from_parameter(cls, name: str, parameter: inspect.Parameter) -> "Argument":
              # pylint: disable=too-many-branches,too-many-statements
              """
              Generate an argument from a inspection parameter
      
      
      Severity: Minor
      Found in src/pyapp/app/arguments.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 _handle_types has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

          def _handle_types(
              type_, positional: bool, kwargs: Dict[str, Any]
          ) -> Optional[type]:
              """
              Handle types
      Severity: Minor
      Found in src/pyapp/app/arguments.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 arg has 8 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def arg(  # noqa: PLR0913
      Severity: Major
      Found in src/pyapp/app/arguments.py - About 1 hr to fix

        Function _extract_args has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

            def _extract_args(self, func):
                """Extract args from signature and turn into command line args."""
                sig = inspect.signature(func)
        
                # Backwards compatibility
        Severity: Minor
        Found in src/pyapp/app/arguments.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 command has 6 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            def command(
        Severity: Minor
        Found in src/pyapp/app/arguments.py - About 45 mins to fix

          Function command has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

              def command(
                  self,
                  handler: Handler = None,
                  *,
                  name: str = None,
          Severity: Minor
          Found in src/pyapp/app/arguments.py - About 35 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 too many return statements within this function.
          Open

                  return type_
          Severity: Major
          Found in src/pyapp/app/arguments.py - About 30 mins to fix

            Error: invalid syntax (<unknown>, line 294)</unknown>
            Open

                    elif action := TYPE_ACTIONS.get(type_):
            Severity: Minor
            Found in src/pyapp/app/arguments.py by radon

            We encountered an error attempting to analyze this line.

            There are no issues that match your filters.

            Category
            Status