SEIAROTg/autobean

View on GitHub
autobean/utils/plugin_lib.py

Summary

Maintainability
C
7 hrs
Test Coverage
A
95%

Function _get_args has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

def _get_args(
        values: list[grammar.ValueType],
        handler: _CustomHandler,
) -> Optional[list[Any]]:
    queue = values[::-1]
Severity: Minor
Found in autobean/utils/plugin_lib.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 _get_arg has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

def _get_arg(annotation: Any, queue: list[grammar.ValueType]) -> Optional[Any]:
    if not queue:
        return None
    value = queue.pop()
    if get_origin(annotation) is Union:
Severity: Minor
Found in autobean/utils/plugin_lib.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 _process_entry has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    def _process_entry(self, entry: Directive) -> Iterator[Directive]:
        if isinstance(entry, Custom) and (handlers := self._CUSTOM_HANDLERS.get(entry.type)):
            for chandler in handlers:
                if (args := _get_args(entry.values or [], chandler)) is not None:
                    with _wrap_plugin_exception(entry, self._error_logger):
Severity: Minor
Found in autobean/utils/plugin_lib.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 plugin has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

def plugin(
        name: str,
        *,
        param_type: Any = None,
        custom_scope: Optional[str] = None,
Severity: Minor
Found in autobean/utils/plugin_lib.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 too many return statements within this function.
Open

    return None
Severity: Major
Found in autobean/utils/plugin_lib.py - About 30 mins to fix

    Avoid too many return statements within this function.
    Open

                return
    Severity: Major
    Found in autobean/utils/plugin_lib.py - About 30 mins to fix

      There are no issues that match your filters.

      Category
      Status