cookiecutter/cookiecutter

View on GitHub
cookiecutter/prompt.py

Summary

Maintainability
C
1 day
Test Coverage
A
100%

Function prompt_for_config has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
Open

def prompt_for_config(
    context: dict[str, Any], no_input: bool = False
) -> OrderedDict[str, Any]:
    """Prompt user to enter a new config.

Severity: Minor
Found in cookiecutter/prompt.py - About 4 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 prompt.py has 330 lines of code (exceeds 250 allowed). Consider refactoring.
Open

"""Functions for prompting the user for project info."""

from __future__ import annotations

import json
Severity: Minor
Found in cookiecutter/prompt.py - About 3 hrs to fix

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

def read_user_choice(var_name: str, options: list, prompts=None, prefix: str = ""):
    """Prompt the user to choose from several options for the given variable.

    The first item will be returned if no input happens.

Severity: Minor
Found in cookiecutter/prompt.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 prompt_and_delete has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

def prompt_and_delete(path: Path | str, no_input: bool = False) -> bool:
    """
    Ask user if it's okay to delete the previously-downloaded file/directory.

    If yes, delete it. If no, checks to see if the old version should be
Severity: Minor
Found in cookiecutter/prompt.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 prompt_choice_for_config has 7 arguments (exceeds 4 allowed). Consider refactoring.
Open

def prompt_choice_for_config(
Severity: Major
Found in cookiecutter/prompt.py - About 50 mins to fix

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

def render_variable(
    env: Environment,
    raw: _Raw,
    cookiecutter_dict: dict[str, Any],
) -> str:
Severity: Minor
Found in cookiecutter/prompt.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

There are no issues that match your filters.

Category
Status