fossasia/open-event-orga-server

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

Summary

Maintainability
F
4 days
Test Coverage

Function export_orders_csv has a Cognitive Complexity of 64 (exceeds 5 allowed). Consider refactoring.
Open

def export_orders_csv(orders):
    headers = [
        'Order#',
        'Order Date',
        'Status',
Severity: Minor
Found in app/api/helpers/csv_jobs_util.py - About 1 day 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 has a Cognitive Complexity of 50 (exceeds 5 allowed). Consider refactoring.
Open

def export_sessions_csv(sessions):
    headers = [
        'Session Title',
        'Session Starts At',
        'Session Ends At',
Severity: Minor
Found in app/api/helpers/csv_jobs_util.py - About 7 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_speakers_csv has a Cognitive Complexity of 41 (exceeds 5 allowed). Consider refactoring.
Open

def export_speakers_csv(speakers):
    headers = [
        'Speaker Name',
        'Speaker Email',
        'Speaker Session(s)',
Severity: Minor
Found in app/api/helpers/csv_jobs_util.py - About 6 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

File csv_jobs_util.py has 394 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import pytz

from app.api.admin_sales.utils import event_type, summary
from app.api.helpers.group_user_role import get_user_group_role
from app.models import db
Severity: Minor
Found in app/api/helpers/csv_jobs_util.py - About 5 hrs to fix

Function get_attendee_data has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

def get_attendee_data(attendee, custom_forms, attendee_form_dict):
    """Get attendee data from attendee object"""
    order_ticket_data = get_order_ticket_data(attendee, attendee.order, attendee.ticket)
    data = {
        **order_ticket_data,
Severity: Minor
Found in app/api/helpers/csv_jobs_util.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 get_order_ticket_data has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

def get_order_ticket_data(attendee, order, ticket):
    """Get order ticket data"""
    data = {}
    if not order:
        return {
Severity: Minor
Found in app/api/helpers/csv_jobs_util.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 export_sales_csv has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

def export_sales_csv(sales):
    headers = [
        'Event Name',
        'Owner Name',
        'Owner Email',
Severity: Minor
Found in app/api/helpers/csv_jobs_util.py - About 55 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 get_order_data has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

def get_order_data(order):
    """Get order data from order object"""
    if not order:
        return {
            'Tax ID': '',
Severity: Minor
Found in app/api/helpers/csv_jobs_util.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

Avoid deeply nested control flow statements.
Open

                    if access_code:
                        access_code_value = access_code.code
                        break

Severity: Major
Found in app/api/helpers/csv_jobs_util.py - About 45 mins to fix

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

def export_group_followers_csv(followers):
    headers = [
        'Public Profile Name',
        'Email',
        'Group Join Date',
Severity: Minor
Found in app/api/helpers/csv_jobs_util.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

There are no issues that match your filters.

Category
Status