Function to_python
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def to_python(self, value):
"""
Convert the input JSON value into python structures, raises
django.core.exceptions.ValidationError if the data can't be converted.
"""
- 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_slug_value
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def get_slug_value(self, model_instance):
value = super(UniqueSlugField, self).get_slug_value(model_instance)
filters = {
self.attname + '__gte': value,
self.attname + '__lte': value + '-9999'
- 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
def __init__(self, source_field=None, keep_existing=False, source_fallback=False, *args, **kwargs):
Function pre_save
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def pre_save(self, model_instance, add):
if getattr(model_instance, self.attname) and self.keep_existing or not self.get_source_value(model_instance):
return super(AutoSlugField, self).pre_save(model_instance, add)
value = self.get_slug_value(model_instance)
- 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"