kotti/views/util.py

Summary

Maintainability
C
1 day
Test Coverage

File util.py has 413 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import hashlib
from collections import defaultdict
from datetime import datetime
from urllib.parse import urlencode

Severity: Minor
Found in kotti/views/util.py - About 5 hrs to fix

    TemplateAPI has 27 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class TemplateAPI:
        """This implements the ``api`` object that's passed to all templates.
    
        Use dict-access as a shortcut to retrieve template macros from templates.
        """
    Severity: Minor
    Found in kotti/views/util.py - About 3 hrs to fix

      Function __getattr__ has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

          def __getattr__(self, key):
              for event_type in slot_events:
                  if event_type.name == key:
                      break
              else:
      Severity: Minor
      Found in kotti/views/util.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 __init__ has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def __init__(self, node, request, item_mapping, item_to_children, permission):
      Severity: Minor
      Found in kotti/views/util.py - About 35 mins to fix

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

            def render_view(self, name="", context=None, request=None, secure=True, bare=True):
        Severity: Minor
        Found in kotti/views/util.py - About 35 mins to fix

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

          def nodes_tree(request, context=None, permission="view"):
              item_mapping = {}
              item_to_children = defaultdict(lambda: [])
              for node in DBSession.query(Content).with_polymorphic(Content):
                  item_mapping[node.id] = node
          Severity: Minor
          Found in kotti/views/util.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

          There are no issues that match your filters.

          Category
          Status