Showing 18 of 38 total issues
Function send_mixin
has a Cognitive Complexity of 69 (exceeds 5 allowed). Consider refactoring. Open
def send_mixin(send_method: str, typology: Optional[int], subject: str, body: str, recipients: Dict[str, List[int]],
presend: Optional[Any], **kwargs) -> Tuple[Dict[str, Any], int]:
"""
Function to send the message
- 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
has a Cognitive Complexity of 46 (exceeds 5 allowed). Consider refactoring. Open
def get(self, request, *args, **kwargs):
"""
Funzione che ritorna un JSON con i record del ContentType passato come parametro.
Se nella richiesta viene passata una lista di ID e nel file `settings.py` è abilitato l'utilizzo dei filtri
- 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 check_state
has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring. Open
def check_state(order_id, times=1, interval=60 * 5):
def _state(_gateway, _order_id):
from django_webix_sender.models import MessageRecipient, MessageSent
# ### Funzione per aggiornare lo stato dei log degli sms
- 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
File views.py
has 305 lines of code (exceeds 250 allowed). Consider refactoring. Open
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
import json
Function get_context_data
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def get_context_data(self, **kwargs):
context = super(InvoiceManagement, self).get_context_data(**kwargs)
_send_methods = {}
for i in CONF['send_methods']:
- 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 send_sms
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def send_sms(recipients, body, message_sent):
if 'django_webix_sender' not in settings.INSTALLED_APPS:
raise Exception("Django Webix Sender is not in INSTALLED_APPS")
from django_webix_sender.models import MessageRecipient, MessageSent
- 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 send_email
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def send_email(recipients, subject, body, message_sent):
# Controllo correttezza parametri
if not isinstance(recipients, dict) or \
'valids' not in recipients or not isinstance(recipients['valids'], list) or \
'duplicates' not in recipients or not isinstance(recipients['duplicates'], list) 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
Consider simplifying this complex logical expression. Open
if not isinstance(recipients, dict) or \
'valids' not in recipients or not isinstance(recipients['valids'], list) or \
'duplicates' not in recipients or not isinstance(recipients['duplicates'], list) or \
'invalids' not in recipients or not isinstance(recipients['invalids'], list):
raise Exception("`recipients` must be a dict")
Consider simplifying this complex logical expression. Open
if not isinstance(recipients, dict) or \
'valids' not in recipients or not isinstance(recipients['valids'], list) or \
'duplicates' not in recipients or not isinstance(recipients['duplicates'], list) or \
'invalids' not in recipients or not isinstance(recipients['invalids'], list):
raise Exception("`recipients` must be a dict")
Function send_mixin
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
def send_mixin(send_method: str, typology: Optional[int], subject: str, body: str, recipients: Dict[str, List[int]],
Function send
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def send(self, recipients, message, message_type='basic', parametric=False, **kwargs):
"""Sends an SMS"""
if message_type == 'classic':
message_type = 'TI'
- 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 deeply nested control flow statements. Open
for field in i.split('__'):
if _value is None:
break
_value = getattr(_value, field)
try:
Function send
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def send(self, recipients, message, message_type='basic', parametric=False, **kwargs):
Function field_type
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def field_type(context, model, field_name):
app_label, model = model.split(".")
model_class = apps.get_model(app_label=app_label, model_name=model)
field = None
for name in field_name.split('__'):
- 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_verbose_field_name
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def get_verbose_field_name(context, model, field_name):
""" Returns verbose_name for a field. """
app_label, model = model.split(".")
model_class = apps.get_model(app_label=app_label, model_name=model)
- 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 JsonResponse({})
Avoid too many return
statements within this function. Open
return {'status': _('Invalid send method')}, 400
Function ready
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def ready(self):
from django_webix_sender.settings import CONF
from django_webix_sender.utils import my_import
if CONF is None:
- 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"