best-doctor/flake8-functions

View on GitHub

Showing 2 of 2 total issues

Function get_returns_amount_for has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

def get_returns_amount_for(func_def: AnyFuncdef) -> int:
    returns_amount = 0
    control_transfer_nodes = (ast.Return,)

    for body_item in func_def.body:
Severity: Minor
Found in flake8_functions/function_returns_amount.py - About 25 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 run has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def run(self) -> Generator[Tuple[int, int, str, type], None, None]:
        validators: List = [
            functools.partial(get_arguments_amount_error, max_parameters_amount=self.max_parameters_amount),
            functools.partial(get_length_errors, max_function_length=self.max_function_length),
            check_purity_of_functions,
Severity: Minor
Found in flake8_functions/checker.py - About 25 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

Severity
Category
Status
Source
Language