Showing 19 of 39 total issues
ConditionFactory
has 21 functions (exceeds 20 allowed). Consider refactoring. Open
class ConditionFactory:
DATE_CONDITION_BUILDERS = {
'today': 'build_today_condition',
'yesterday': 'build_yesterday_condition',
Function handle_aggregator
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def handle_aggregator(self, filters, Model, tz):
q_objects = Q()
for condition in filters['conditions']:
if "aggregator" in condition:
if condition['aggregator'] == 'or':
- 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_ids_from_request
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def get_ids_from_request(self, request, Model):
body = self.get_body(request.body)
if 'data' in body:
data = body['data']
- 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 _handle_smart_field_for_relation
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def _handle_smart_field_for_relation(self, queryset, relation_field, collection_name, params, many):
if many:
for item in queryset:
if getattr(item, relation_field["field"], None) is not None:
self.handle_smart_fields(
- 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 _rewrite_Q_with_field
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def _rewrite_Q_with_field(self, q, condition):
operator = condition['operator']
splitted_fields = condition['field'].split(":")
new_children = []
- 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 fill_csv_relationships
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def fill_csv_relationships(self, res, record, data, params):
pk_name = self.Model._meta.pk.name
for name, value in record['relationships'].items():
related_res = self.get_related_res(data, value)
field_name = params[f'fields[{name}]']
- 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 _handle_authent_error
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def _handle_authent_error(self, response):
if response.status_code == 404:
raise AuthenticationThirdPartyException(
MESSAGES['SERVER_TRANSACTION']['SECRET_NOT_FOUND']
)
- 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_date_range
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def get_date_range(
Function _handle_smart_field_for_relation
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def _handle_smart_field_for_relation(self, queryset, relation_field, collection_name, params, many):
Function enhance_queryset
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def enhance_queryset(self, queryset, Model, params, request, apply_pagination=True):
Function handle_smart_fields
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def handle_smart_fields(self, queryset, resource, params=None, many=False, follow_relations=True):
Function get_basic_expression
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def get_basic_expression(self, field, field_type, operator, value):
operators = INSENSITIVE_OPERATORS if isinstance(value, str) else OPERATORS
try:
lookup_field = f"{field}{operators[operator]}"
- 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_fields
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def get_fields(self, current_collection, qs):
current_name = current_collection['name']
qs_fields = qs.get('fields')
if not qs_fields:
return {
- 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_attribute
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def get_attribute(self, obj, attr, default):
value = super().get_attribute(obj, attr, default)
if value.__class__.__name__ == 'ManyRelatedManager':
value = value.all()
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 get_expression_smart_field
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def get_expression_smart_field(self, smart_fields, condition, resource):
operator = condition['operator']
splitted_fields = condition['field'].split(":")
value = condition['value']
- 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 handle_validators
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def handle_validators(validators, f):
if len(validators):
for validator in validators:
if hasattr(validator, 'code'):
f = handle_validator(validator, f)
- 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_action
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def _get_action(self, action_name):
for collection_schema in Collection._registry.values():
for action in collection_schema.actions:
if self.action_name_from_endpoint(action) == action_name:
return action
- 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 handle_smart_fields
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def handle_smart_fields(self, queryset, resource, params=None, many=False, follow_relations=True):
collection = Schema.get_collection(resource)
# Rather than calculate and then filter out smart fields, we want to ignore them entirely
smart_fields = self._get_smart_fields_for_request(collection, params)
- 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 populate_query_request_info
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def populate_query_request_info(self, permission_name, body, kwargs):
if permission_name in 'liveQueries':
kwargs['query_request_info'] = body['query']
elif permission_name in 'statsWithParameters':
if 'timezone' in body:
- 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"