File views.py
has 380 lines of code (exceeds 250 allowed). Consider refactoring. Open
import json
import warnings
from datetime import date
from django.apps import apps
MetadataMixin
has 32 functions (exceeds 20 allowed). Consider refactoring. Open
class MetadataMixin(FullUrlMixin):
"""
Django CBV mixin to prepare metadata for the view context
"""
Function schema
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
def schema(self):
"""
Schema.org object description.
Items in the schema are converted in a format suitable of json encoding at this stage:
- 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 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
def __init__(self, **kwargs):
self.request = kwargs.get("request", None)
self.use_sites = kwargs.get("use_sites", get_setting("USE_SITES"))
self.title = kwargs.get("title")
self.og_title = kwargs.get("og_title")
Function keywords
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def keywords(self, keywords):
if keywords is None:
kws = get_setting("DEFAULT_KEYWORDS")
else:
if not hasattr(keywords, "__iter__"):
- 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 image_object
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def image_object(self, image):
try:
if image:
image["url"] = self._normalize_media_url(image.get("url", None))
if self.get_protocol() == "https":
- 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 get_domain
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def get_domain(self):
"""
Discover the current website domain
:py:class:`django.contrib.sites.models.Site`
- 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
Avoid too many return
statements within this function. Open
return {itemkey: process_item(itemvalue) for itemkey, itemvalue in item.items()}
Avoid too many return
statements within this function. Open
return item
Function _get_full_url
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def _get_full_url(self, url):
"""
Build the full URL (protocol and domain included) for the URL given as argument
:param url: absolute (domain-less) URL
- 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"