kotti/views/util.py
File util.py
has 413 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
import hashlib
from collections import defaultdict
from datetime import datetime
from urllib.parse import urlencode
TemplateAPI
has 27 functions (exceeds 20 allowed). Consider refactoring. Open
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.
"""
Function __getattr__
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
Open
def __getattr__(self, key):
for event_type in slot_events:
if event_type.name == key:
break
else:
- Read upRead up
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
Open
def __init__(self, node, request, item_mapping, item_to_children, permission):
Function render_view
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
def render_view(self, name="", context=None, request=None, secure=True, bare=True):
Function nodes_tree
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
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
- Read upRead up
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"