failmap/admin

View on GitHub
websecmap/map/admin.py

Summary

Maintainability
C
1 day
Test Coverage

File admin.py has 466 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import logging
from copy import deepcopy
from datetime import datetime
from typing import Dict, Any

Severity: Minor
Found in websecmap/map/admin.py - About 7 hrs to fix

    Function save_model has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

        def save_model(self, request, obj, form, change):
            # allows to place a new item at the right position, moving certain items up.
            # if the display_order is zero, autoplace the item.
    
            if obj.display_order:
    Severity: Minor
    Found in websecmap/map/admin.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 add_configuration has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

    def add_configuration(country: str, organization_type: int):
    
        if models.Configuration.objects.all().filter(country=country, organization_type=organization_type).exists():
            log.debug("This configuration already exists, skipping.")
            return
    Severity: Minor
    Found in websecmap/map/admin.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 reorder has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        def reorder(self, request, queryset):
    
            first_order = None
    
            for configuration in queryset:
    Severity: Minor
    Found in websecmap/map/admin.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