cookiecutter/cookiecutter

View on GitHub

Showing 30 of 32 total issues

Function unzip has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring.
Open

def unzip(
    zip_uri: str,
    is_url: bool,
    clone_to_dir: Path | str = ".",
    no_input: bool = False,
Severity: Minor
Found in cookiecutter/zipfile.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 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 generate.py has 346 lines of code (exceeds 250 allowed). Consider refactoring.
Open

"""Functions for generating a project from a project template."""

from __future__ import annotations

import fnmatch
Severity: Minor
Found in cookiecutter/generate.py - About 4 hrs to fix

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 apply_overwrites_to_context has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
Open

def apply_overwrites_to_context(
    context: dict[str, Any],
    overwrite_context: dict[str, Any],
    *,
    in_dictionary_variable: bool = False,
Severity: Minor
Found in cookiecutter/generate.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 clone has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
Open

def clone(
    repo_url: str,
    checkout: str | None = None,
    clone_to_dir: Path | str = ".",
    no_input: bool = False,
Severity: Minor
Found in cookiecutter/vcs.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 cookiecutter has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

def cookiecutter(
    template: str,
    checkout: str | None = None,
    no_input: bool = False,
    extra_context: dict[str, Any] | None = None,
Severity: Minor
Found in cookiecutter/main.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 slugify has 12 arguments (exceeds 4 allowed). Consider refactoring.
Open

        def slugify(
Severity: Major
Found in cookiecutter/extensions.py - About 1 hr 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 get_user_config has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

def get_user_config(
    config_file: str | None = None,
    default_config: bool | dict[str, Any] = False,
) -> dict[str, Any]:
    """Return the user config as a dict.
Severity: Minor
Found in cookiecutter/config.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_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 identify_repo has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

def identify_repo(repo_url: str) -> tuple[Literal["git", "hg"], str]:
    """Determine if `repo_url` should be treated as a URL to a git or hg repo.

    Repos can be identified by prepending "hg+" or "git+" to the repo URL.

Severity: Minor
Found in cookiecutter/vcs.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 determine_repo_dir has 7 arguments (exceeds 4 allowed). Consider refactoring.
Open

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

Function generate_files has 7 arguments (exceeds 4 allowed). Consider refactoring.
Open

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

Avoid deeply nested control flow statements.
Open

                    if chunk:  # filter out keep-alive new chunks
                        f.write(chunk)
    else:
Severity: Major
Found in cookiecutter/zipfile.py - About 45 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

Function run_hook_from_repo_dir has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

def run_hook_from_repo_dir(
Severity: Minor
Found in cookiecutter/hooks.py - About 35 mins to fix

Function render_and_create_dir has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

def render_and_create_dir(
Severity: Minor
Found in cookiecutter/generate.py - About 35 mins to fix

Function unzip has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

def unzip(
Severity: Minor
Found in cookiecutter/zipfile.py - About 35 mins to fix
Severity
Category
Status
Source
Language