fossasia/open-event-orga-server

View on GitHub
app/api/sessions.py

Summary

Maintainability
C
1 day
Test Coverage

File sessions.py has 379 lines of code (exceeds 250 allowed). Consider refactoring.
Open

from datetime import datetime
from typing import Dict, Optional

import pytz
from flask import Blueprint, g, jsonify, request
Severity: Minor
Found in app/api/sessions.py - About 5 hrs to fix

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

    def before_update_object(self, session, data, view_kwargs):
        """
        before update method to verify if session is locked before updating session object
        :param event:
        :param data:
Severity: Minor
Found in app/api/sessions.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 after_update_object has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

    def after_update_object(self, session, data, view_kwargs):
        """Send email if session accepted or rejected"""

        if data.get('send_email', None) and g.get('send_email'):
            notify_for_session(session)
Severity: Minor
Found in app/api/sessions.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 query has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def query(self, view_kwargs):
        """
        query method for SessionList class
        :param view_kwargs:
        :return:
Severity: Minor
Found in app/api/sessions.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 get_distinct_sort_fields has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

def get_distinct_sort_fields(schema, model, sort=True):
    """Due to the poor code of flask-rest-jsonapi, distinct query needed
    in sessions API to remove duplicate sessions can't be sorted on
    returning subquery, thus we need to add all sort fields in distinct
    group and repeat it in sort group as well"""
Severity: Minor
Found in app/api/sessions.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