fossasia/open-event-orga-server

View on GitHub
app/api/tickets.py

Summary

Maintainability
B
6 hrs
Test Coverage

File tickets.py has 292 lines of code (exceeds 250 allowed). Consider refactoring.
Open

from flask import Blueprint, jsonify
from flask_jwt_extended import current_user, verify_jwt_in_request
from flask_rest_jsonapi import ResourceDetail, ResourceList, ResourceRelationship
from flask_rest_jsonapi.exceptions import ObjectNotFound
from sqlalchemy.orm.exc import NoResultFound
Severity: Minor
Found in app/api/tickets.py - About 3 hrs to fix

Function query has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

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

    def before_create_object(self, data, view_kwargs):
        """
        before create method to check if paid ticket has a paymentMethod enabled
        :param data:
        :param view_kwargs:
Severity: Minor
Found in app/api/tickets.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 before_update_object has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def before_update_object(self, ticket, data, view_kwargs):
        """
        method to check if paid ticket has payment method before updating ticket object
        :param ticket:
        :param data:
Severity: Minor
Found in app/api/tickets.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

There are no issues that match your filters.

Category
Status