fossasia/open-event-orga-server

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

Summary

Maintainability
C
1 day
Test Coverage

File payment.py has 337 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import json

import omise
import paypalrestsdk
import requests
Severity: Minor
Found in app/api/helpers/payment.py - About 4 hrs to fix

Function get_credentials has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    def get_credentials(event=None):
        """
        If the event parameter is None, It returns the secret and publishable key of the Admin's Stripe account.
        Else, it returns the corresponding values for the event organizer's account.
        :param event:
Severity: Minor
Found in app/api/helpers/payment.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

Avoid too many return statements within this function.
Open

        return None
Severity: Major
Found in app/api/helpers/payment.py - About 30 mins to fix

Avoid too many return statements within this function.
Open

            return True, None
Severity: Major
Found in app/api/helpers/payment.py - About 30 mins to fix

Avoid too many return statements within this function.
Open

            return False, 'Payment Not Found'
Severity: Major
Found in app/api/helpers/payment.py - About 30 mins to fix

Avoid too many return statements within this function.
Open

                return False, 'Payment already been verified'
Severity: Major
Found in app/api/helpers/payment.py - About 30 mins to fix

Function verify_payment has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def verify_payment(payment_id, order):
        """
        Verify Paypal payment one more time for paying with Paypal in mobile client
        """
        PayPalPaymentsManager.configure_paypal()
Severity: Minor
Found in app/api/helpers/payment.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 configure_paypal has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def configure_paypal():
        """
        Configure the paypal sdk
        :return: Credentials
        """
Severity: Minor
Found in app/api/helpers/payment.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 get_payment_intent_stripe has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def get_payment_intent_stripe(order_invoice, currency=None, credentials=None):
        """
        Capture payments through stripe.
        :param order_invoice: Order to be charged for
        :param currency: Currency of the order amount.
Severity: Minor
Found in app/api/helpers/payment.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