File mail.py
has 746 lines of code (exceeds 250 allowed). Consider refactoring. Open
import base64
import datetime
import logging
import os
from itertools import groupby
- Create a ticketCreate a ticket
Function send_email
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
def send_email(to, action, subject, html, attachments=None, bcc=None, reply_to=None):
"""
Sends email and records it in DB
"""
from .tasks import get_smtp_config, send_email_task_sendgrid, send_email_task_smtp
- 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 convert_to_user_locale
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def convert_to_user_locale(
email, date_time=None, date=None, time=None, tz=None, amount=None, currency=None
):
"""
Convert date and time and amount to user selected language
- 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 convert_to_user_locale
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
def convert_to_user_locale(
- Create a ticketCreate a ticket
Function send_email
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
def send_email(to, action, subject, html, attachments=None, bcc=None, reply_to=None):
- Create a ticketCreate a ticket
Function send_email_for_monthly_fee_payment
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
def send_email_for_monthly_fee_payment(
- Create a ticketCreate a ticket
Function send_email_to_attendees
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def send_email_to_attendees(order):
attachments = None
if current_app.config['ATTACH_ORDER_PDF']:
attachments = [order.ticket_pdf_path, order.invoice_pdf_path]
- 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 send_email_with_action
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def send_email_with_action(user, action, template_name, bcc=None, **kwargs):
- Create a ticketCreate a ticket
Avoid too many return
statements within this function. Open
return None
- Create a ticketCreate a ticket