akretion/payment-gateway

View on GitHub

Showing 4 of 8 total issues

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

    def capture(self, transaction, amount):
        paypal, experience_profile = self._get_connection()
        payment = paypalrestsdk.Payment.find(
            transaction.external_id, api=paypal)
        payer_id = payment.to_dict()['payer']\
Severity: Minor
Found in payment_gateway_paypal/services/payment_service.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 create_provider_transaction has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def create_provider_transaction(self, record, source=None, **kwargs):
        source_data = stripe.Source.retrieve(source, api_key=self._api_key)
        three_d_secure = self._need_three_d_secure(record, source_data)
        try:
            if three_d_secure:
Severity: Minor
Found in payment_gateway_stripe/services/payment_service.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 capture_transaction has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def capture_transaction(self):
        for sale in self:
            for transaction in sale.transaction_ids:
                if transaction.state == 'to_capture':
                    transaction.capture(sale.residual)
Severity: Minor
Found in payment_gateway/models/sale.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 write has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def write(self, vals):
        super(GatewayTransaction, self).write(vals)
        if vals['state'] == 'to_capture':
            for record in self:
                if record.capture_payment == 'immediately':
Severity: Minor
Found in payment_gateway/models/gateway_transaction.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

Severity
Category
Status
Source
Language