wikimedia/mediawiki-extensions-DonationInterface

View on GitHub
adyen_gateway/adyen_checkout.adapter.php

Summary

Maintainability
D
2 days
Test Coverage

File adyen_checkout.adapter.php has 384 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

use Psr\Log\LogLevel;
use SmashPig\Core\PaymentError;
use SmashPig\Core\ValidationError;
Severity: Minor
Found in adyen_gateway/adyen_checkout.adapter.php - About 5 hrs to fix

    Method handleCreatedPayment has 65 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        protected function handleCreatedPayment(
            IPaymentProvider $provider, PaymentDetailResponse $authorizeResult
        ): PaymentResult {
            $transactionStatus = $authorizeResult->getStatus();
            $responseData = [
    Severity: Major
    Found in adyen_gateway/adyen_checkout.adapter.php - About 2 hrs to fix

      Function handleCreatedPayment has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
      Open

          protected function handleCreatedPayment(
              IPaymentProvider $provider, PaymentDetailResponse $authorizeResult
          ): PaymentResult {
              $transactionStatus = $authorizeResult->getStatus();
              $responseData = [
      Severity: Minor
      Found in adyen_gateway/adyen_checkout.adapter.php - About 2 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

      Method tuneForPaymentMethod has 51 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          protected function tuneForPaymentMethod() {
              switch ( $this->getPaymentMethod() ) {
                  case 'ach':
                      $this->transactions['authorize']['request'] =
                          array_merge( $this->transactions['authorize']['request'], [
      Severity: Major
      Found in adyen_gateway/adyen_checkout.adapter.php - About 2 hrs to fix

        Method doPayment has 41 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function doPayment() {
                $this->ensureUniqueOrderID();
                $this->session_addDonorData();
                $this->setCurrentTransaction( 'authorize' );
                Gateway_Extras_CustomFilters::onGatewayReady( $this );
        Severity: Minor
        Found in adyen_gateway/adyen_checkout.adapter.php - About 1 hr to fix

          Method getCheckoutConfiguration has 32 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function getCheckoutConfiguration() {
                  $provider = PaymentProviderFactory::getProviderForMethod(
                      $this->getPaymentMethod()
                  );
                  '@phan-var PaymentProvider $provider';
          Severity: Minor
          Found in adyen_gateway/adyen_checkout.adapter.php - About 1 hr to fix

            Method getFieldsToRemove has 28 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                protected function getFieldsToRemove( ?array $knownData = null ) {
                    $method = $knownData['payment_method'] ?? $this->getData_Unstaged_Escaped( 'payment_method' );
                    $submethod = $knownData['payment_submethod'] ?? $this->getData_Unstaged_Escaped( 'payment_submethod' );
                    if ( $method === 'apple' ) {
                        // For Apple Pay, do not require any of the following fields in forms,
            Severity: Minor
            Found in adyen_gateway/adyen_checkout.adapter.php - About 1 hr to fix

              Function tuneForPaymentMethod has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

                  protected function tuneForPaymentMethod() {
                      switch ( $this->getPaymentMethod() ) {
                          case 'ach':
                              $this->transactions['authorize']['request'] =
                                  array_merge( $this->transactions['authorize']['request'], [
              Severity: Minor
              Found in adyen_gateway/adyen_checkout.adapter.php - 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