nephila/django-app-enabler

View on GitHub

Showing 9 of 9 total issues

Function _verify_settings has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
Open

def _verify_settings(imported: ModuleType, application_config: Dict[str, Any]) -> bool:
    """
    Check that addon config has been properly set in patched settings.

    :param ModuleType imported:  Update settings module
Severity: Minor
Found in app_enabler/enable.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

Function _update_list_setting has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
Open

def _update_list_setting(original_setting: List, configuration: Iterable):
    for config_value in configuration:
        # configuration items can be either strings (which are appended) or dictionaries which contains information
        # about the position of the item
        if isinstance(config_value, dict):
Severity: Minor
Found in app_enabler/patcher.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 update_setting has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
Open

def update_setting(project_setting: str, config: Dict[str, Any]):
    """
    Patch the settings module to include addon settings.

    Original file is overwritten. As file is patched using AST, original comments and file structure is lost.
Severity: Minor
Found in app_enabler/patcher.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 update_urlconf has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
Open

def update_urlconf(project_urls: str, config: Dict[str, Any]):
    """
    Patch the ``ROOT_URLCONF`` module to include addon url patterns.

    Original file is overwritten. As file is patched using AST, original comments and file structure is lost.
Severity: Minor
Found in app_enabler/patcher.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 towncrier_check has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

def towncrier_check(c):  # NOQA
    """Check towncrier files."""
    output = io.StringIO()
    c.run("git branch -a --contains HEAD", out_stream=output)
    skipped_branch_prefix = ["pull/", "release/", "develop", "master", "HEAD"]
Severity: Minor
Found in tasks.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 apply_configuration_set has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

def apply_configuration_set(config_set: List[Path], verbose: bool = False):
    """
    Apply settings from the list of input files.

    :param list config_set: list of paths to addon configuration to load and apply
Severity: Minor
Found in app_enabler/enable.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 _verify_urlconf has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

def _verify_urlconf(imported: ModuleType, application_config: Dict[str, Any]) -> bool:
    """
    Check that addon urlconf has been properly added in patched urlconf.


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

def install(context: click.core.Context, package: str, pip_options: str):
    """
    Install the package in the current virtualenv and enable the corresponding application in the current project.

    \b
Severity: Minor
Found in app_enabler/cli.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

Avoid deeply nested control flow statements.
Open

                    if ast_position is None:
                        node.value.keys.append(_ast_get_object_from_value(dict_key))
                        node.value.values.append(_ast_get_object_from_value(dict_value))
                    else:
                        node.value.values[ast_position] = _ast_get_object_from_value(dict_value)
Severity: Major
Found in app_enabler/patcher.py - About 45 mins to fix
    Severity
    Category
    Status
    Source
    Language