idlesign/django-sitecats

View on GitHub
sitecats/toolbox.py

Summary

Maintainability
C
1 day
Test Coverage

File toolbox.py has 369 lines of code (exceeds 250 allowed). Consider refactoring.
Open

from inspect import getfullargspec
from collections import namedtuple
from typing import List, Callable, Union, Optional, Any, Tuple, Dict

from django.db.models import Model
Severity: Minor
Found in sitecats/toolbox.py - About 4 hrs to fix

    Function action_add has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
    Open

        def action_add(cls, request: HttpRequest, category_list: CategoryList) -> 'CategoryBase':
            """Handles `add` action from CategoryList editor.
            Returns CategoryModel object on success otherwise and exception from SitecatsException family is raised.
    
            Adds an actual category if a target object is not set for the list.
    Severity: Minor
    Found in sitecats/toolbox.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 enable_editor has 8 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        def enable_editor(
    Severity: Major
    Found in sitecats/toolbox.py - About 1 hr to fix

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

          def listen(self) -> Any:
              """Instructs handler to listen to Django request and handle
              CategoryList editor requests (if any).
      
              Returns None on success otherwise and exception from SitecatsException family is raised.
      Severity: Minor
      Found in sitecats/toolbox.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 register_lists has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          def register_lists(
                  self,
                  category_lists: List[CategoryList],
                  lists_init_kwargs: Dict[str, Any] = None,
                  editor_init_kwargs: Dict[str, Any] = None
      Severity: Minor
      Found in sitecats/toolbox.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 get_category_lists has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

      def get_category_lists(
              init_kwargs: dict = None,
              additional_parents_aliases: List[str] = None,
              obj: Model = None
      
      
      Severity: Minor
      Found in sitecats/toolbox.py - About 35 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