fossasia/open-event-orga-server

View on GitHub
app/api/helpers/tasks.py

Summary

Maintainability
F
3 days
Test Coverage

File tasks.py has 834 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import base64
import csv
import logging
import os
import urllib.error
Severity: Major
Found in app/api/helpers/tasks.py - About 2 days to fix

Function create_print_badge_pdf has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring.
Open

def create_print_badge_pdf(self, attendee_id, list_field_show):
    """
    Create tickets and invoices for the holders of an order.
    @param self: create_print_badge_pdf
    @param attendee_id: attendee
Severity: Minor
Found in app/api/helpers/tasks.py - About 4 hrs to fix

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 export_attendees_csv_task has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

def export_attendees_csv_task(self, event_id):
    attendees = (
        db.session.query(TicketHolder)
        .filter_by(event_id=event_id)
        .order_by(desc(func.date(TicketHolder.created_at)))
Severity: Minor
Found in app/api/helpers/tasks.py - About 2 hrs to fix

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_task_sendgrid has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

def send_email_task_sendgrid(payload):
    message = Mail(
        from_email=From(payload['from'], payload['fromname']),
        to_emails=payload['to'],
        subject=payload['subject'],
Severity: Minor
Found in app/api/helpers/tasks.py - About 1 hr to fix

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_task_smtp has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

def send_email_task_smtp(payload):
    smtp_config = get_smtp_config()
    mailer_config = {'transport': {'use': 'smtp', **smtp_config}}

    mailer = Mailer(mailer_config)
Severity: Minor
Found in app/api/helpers/tasks.py - About 45 mins to fix

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 import_event_task has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

def import_event_task(self, email, file, source_type, creator_id):
Severity: Minor
Found in app/api/helpers/tasks.py - About 35 mins to fix

Function export_admin_sales_csv_task has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

def export_admin_sales_csv_task(self, status='all'):
    current_time = datetime.now(pytz.utc)
    if status not in [
        'all',
        'live',
Severity: Minor
Found in app/api/helpers/tasks.py - About 35 mins to fix

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 export_xcal_task has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

def export_xcal_task(self, event_id, temp=True):
    event = safe_query(Event, 'id', event_id, 'event_id')

    try:
        if temp:
Severity: Minor
Found in app/api/helpers/tasks.py - About 35 mins to fix

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 export_pentabarf_task has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

def export_pentabarf_task(self, event_id, temp=True):
    event = safe_query(Event, 'id', event_id, 'event_id')

    try:
        if temp:
Severity: Minor
Found in app/api/helpers/tasks.py - About 35 mins to fix

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 export_speakers_csv_task has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

def export_speakers_csv_task(self, event_id, status='all'):
    if status not in [
        'all',
        'pending',
        'accepted',
Severity: Minor
Found in app/api/helpers/tasks.py - About 35 mins to fix

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 export_event_task has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

def export_event_task(self, email, event_id, settings):
    event = safe_query(Event, 'id', event_id, 'event_id')
    smtp_encryption = get_settings()['smtp_encryption']
    try:
        logging.info('Exporting started')
Severity: Minor
Found in app/api/helpers/tasks.py - About 25 mins to fix

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 export_sessions_csv_task has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

def export_sessions_csv_task(self, event_id, status='all'):
    if status not in [
        'all',
        'pending',
        'accepted',
Severity: Minor
Found in app/api/helpers/tasks.py - About 25 mins to fix

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

There are no issues that match your filters.

Category
Status