idlesign/django-sitecats

View on GitHub

Showing 16 of 16 total issues

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

        def get_linked_objects(
                cls,
                filter_kwargs: dict = None,
                id_only: bool = False,
                by_category: bool = False
    Severity: Minor
    Found in sitecats/models.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 get_categories has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
    Open

        def get_categories(
                self,
                parent_aliases: Optional[Union[str, List[str]]] = None,
                target_object: 'ModelWithCategory' = None,
                tied_only: bool = True
    Severity: Minor
    Found in sitecats/utils.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

    File models.py has 277 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    from collections import defaultdict
    from typing import Union, Dict, List, Any
    
    from django.conf import settings
    from django.contrib.contenttypes.fields import GenericForeignKey, GenericRelation
    Severity: Minor
    Found in sitecats/models.py - About 2 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 bootstrap_editors has 44 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          bootstrap_editors: function() {
              'use strict';
      
              var cl_list_entry = '.' + this.defaults.classes.list_entry,
                  cl_choice_box = '.' + this.defaults.classes.choice_box,
      Severity: Minor
      Found in sitecats/static/js/sitecats/sitecats.js - About 1 hr to fix

        Function make_cloud has 33 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            make_cloud: function(target_el_id, font_size_min, font_size_max, font_size_units) {
                'use strict';
        
                var ties_max,
                    ties_min,
        Severity: Minor
        Found in sitecats/static/js/sitecats/sitecats.js - About 1 hr to fix

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

                def _cache_init(self):
                    """Initializes local cache from Django cache if required."""
                    cache_ = cache.get(self.CACHE_ENTRY_NAME)
            
                    if cache_ is None:
            Severity: Minor
            Found in sitecats/utils.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 render has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

                def render(self, context):
                    resolve = lambda arg: arg.resolve(context) if isinstance(arg, FilterExpression) else arg
            
                    target_obj = resolve(self.target_obj)
            
            
            Severity: Minor
            Found in sitecats/templatetags/sitecats.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 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 enable_category_lists_editor has 6 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                def enable_category_lists_editor(
            Severity: Minor
            Found in sitecats/models.py - About 45 mins to fix

              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

              Function get_ties_for_categories_qs has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                  def get_ties_for_categories_qs(
                          cls,
                          categories: Union['CategoryBase', List['CategoryBase']],
                          user: 'User' = None,
                          status: int = None
              Severity: Minor
              Found in sitecats/models.py - About 25 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_children_for has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                  def get_children_for(self, parent_alias: str = None, only_with_aliases: bool = False) -> List['CategoryBase']:
                      """Returns a list with with categories under the given parent.
              
                      :param parent_alias: Parent category alias or None for categories under root
                      :param only_with_aliases: Flag to return only children with aliases
              Severity: Minor
              Found in sitecats/utils.py - About 25 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

              Severity
              Category
              Status
              Source
              Language