File views.py
has 380 lines of code (exceeds 250 allowed). Consider refactoring. Open
import logging
import requests
from django.contrib import messages
from django.contrib.auth.mixins import PermissionRequiredMixin
- Create a ticketCreate a ticket
Function get_queryset
has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring. Open
def get_queryset(self, **kwargs):
form_opts = self.request.GET.copy()
# if relevance sort is requested but there is no keyword search
# term present, clear it out and fallback to default sort
if not self.form_class().has_keyword_query(form_opts):
- Read upRead up
- Create a ticketCreate a ticket
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_queryset
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def get_queryset(self):
# get default queryset and filter by source id
source_qs = (
super().get_queryset().filter(source_id=self.kwargs.get("source_id"))
)
- Read upRead up
- Create a ticketCreate a ticket
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_context_data
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
digwork = context["object"]
# if suppressed, don't do any further processing
- Read upRead up
- Create a ticketCreate a ticket
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"