wikimedia/mediawiki-extensions-DonationInterface

View on GitHub
gateway_common/gateway.adapter.php

Summary

Maintainability
F
2 wks
Test Coverage

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

<?php

/**
 * Wikimedia Foundation
 *
Severity: Major
Found in gateway_common/gateway.adapter.php - About 4 days to fix

    GatewayAdapter has 133 functions (exceeds 20 allowed). Consider refactoring.
    Open

    abstract class GatewayAdapter implements GatewayType {
        /**
         * Don't change these strings without fixing cross-repo usages.
         */
        const REDIRECT_PREFACE = 'Redirecting for transaction: ';
    Severity: Major
    Found in gateway_common/gateway.adapter.php - About 2 days to fix

      Function buildOrderIDSources has a Cognitive Complexity of 40 (exceeds 5 allowed). Consider refactoring.
      Open

          public function buildOrderIDSources() {
              static $built = false;
      
              if ( $built && isset( $this->order_id_candidates ) ) { // once per request is plenty
                  return;
      Severity: Minor
      Found in gateway_common/gateway.adapter.php - About 6 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

      Function getFormFields has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
      Open

          public function getFormFields( ?array $knownData = null ): array {
              if ( $knownData === null ) {
                  $knownData = $this->getData_Unstaged_Escaped();
              }
              $fields = [];
      Severity: Minor
      Found in gateway_common/gateway.adapter.php - About 3 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

      Function session_resetOnSwitch has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
      Open

          protected function session_resetOnSwitch() {
              $oldData = $this->session_getData( 'Donor' );
              if ( !is_array( $oldData ) ) {
                  return;
              }
      Severity: Minor
      Found in gateway_common/gateway.adapter.php - About 3 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

      Function getDonationRules has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
      Open

          public function getDonationRules(): array {
              $rules = $this->config['donation_rules'];
              foreach ( $rules as $rule ) {
                  // Do our $params match all the conditions for this rule?
                  $ruleMatches = true;
      Severity: Minor
      Found in gateway_common/gateway.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

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

          public function calculateKeyMashScore( $stringToCheck ) {
              $letters = str_split( strtolower( $stringToCheck ) );
              $rules = $this->getGlobal( 'NameFilterRules' );
              $score = 0;
      
      
      Severity: Minor
      Found in gateway_common/gateway.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

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

          protected function getQueueDonationMessage(): array {
              $gatewayTxnId = $this->getData_Unstaged_Escaped( 'gateway_txn_id' );
              if ( $gatewayTxnId === null ) {
                  $gatewayTxnId = false;
              }
      Severity: Minor
      Found in gateway_common/gateway.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 buildOrderIDSources has 59 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function buildOrderIDSources() {
              static $built = false;
      
              if ( $built && isset( $this->order_id_candidates ) ) { // once per request is plenty
                  return;
      Severity: Major
      Found in gateway_common/gateway.adapter.php - About 2 hrs to fix

        Method getFormFields has 58 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function getFormFields( ?array $knownData = null ): array {
                if ( $knownData === null ) {
                    $knownData = $this->getData_Unstaged_Escaped();
                }
                $fields = [];
        Severity: Major
        Found in gateway_common/gateway.adapter.php - About 2 hrs to fix

          Method getQueueDonationMessage has 56 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              protected function getQueueDonationMessage(): array {
                  $gatewayTxnId = $this->getData_Unstaged_Escaped( 'gateway_txn_id' );
                  if ( $gatewayTxnId === null ) {
                      $gatewayTxnId = false;
                  }
          Severity: Major
          Found in gateway_common/gateway.adapter.php - About 2 hrs to fix

            Method fallbackToDefaultCurrency has 54 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                protected function fallbackToDefaultCurrency() {
                    $defaultCurrency = null;
                    if ( $this->getGlobal( 'FallbackCurrencyByCountry' ) ) {
                        $country = $this->dataObj->getVal( 'country' );
                        if ( $country !== null ) {
            Severity: Major
            Found in gateway_common/gateway.adapter.php - About 2 hrs to fix

              Function session_resetForNewAttempt has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
              Open

                  public function session_resetForNewAttempt( $force = false ) {
                      $reset = $force;
                      if ( $this->session_getData( 'numAttempt' ) > 3 ) {
                          $reset = true;
                          WmfFramework::setSessionValue( 'numAttempt', 0 );
              Severity: Minor
              Found in gateway_common/gateway.adapter.php - 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

              Method session_resetOnSwitch has 47 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  protected function session_resetOnSwitch() {
                      $oldData = $this->session_getData( 'Donor' );
                      if ( !is_array( $oldData ) ) {
                          return;
                      }
              Severity: Minor
              Found in gateway_common/gateway.adapter.php - About 1 hr to fix

                Method session_resetForNewAttempt has 47 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public function session_resetForNewAttempt( $force = false ) {
                        $reset = $force;
                        if ( $this->session_getData( 'numAttempt' ) > 3 ) {
                            $reset = true;
                            WmfFramework::setSessionValue( 'numAttempt', 0 );
                Severity: Minor
                Found in gateway_common/gateway.adapter.php - About 1 hr to fix

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

                      protected function fallbackToDefaultCurrency() {
                          $defaultCurrency = null;
                          if ( $this->getGlobal( 'FallbackCurrencyByCountry' ) ) {
                              $country = $this->dataObj->getVal( 'country' );
                              if ( $country !== null ) {
                  Severity: Minor
                  Found in gateway_common/gateway.adapter.php - 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 validateDataConstraintsMet has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                  Open

                      protected function validateDataConstraintsMet( $field, $value ) {
                          $met = true;
                  
                          if ( is_array( $this->dataConstraints ) && array_key_exists( $field, $this->dataConstraints ) ) {
                              $type = $this->dataConstraints[$field]['type'];
                  Severity: Minor
                  Found in gateway_common/gateway.adapter.php - 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

                  Method normalizeOrderID has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      public function normalizeOrderID( $override = null, $dataObj = null ) {
                          $selected = false;
                          $source = null;
                          $value = null;
                          if ( $override !== null && $this->validateDataConstraintsMet( 'order_id', $override ) ) {
                  Severity: Minor
                  Found in gateway_common/gateway.adapter.php - About 1 hr to fix

                    Method showMonthlyConvert has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        public function showMonthlyConvert() {
                            $monthlyConvertAmounts = $this->getMonthlyConvertAmounts();
                            if ( $monthlyConvertAmounts !== null ) {
                                $mcMinimumAmount = $monthlyConvertAmounts[0][0];
                                // check if amount is up to monthly convert minimum amount for specified currency
                    Severity: Minor
                    Found in gateway_common/gateway.adapter.php - About 1 hr to fix

                      Method __construct has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          public function __construct( $options = [] ) {
                              $defaults = [
                                  'external_data' => null,
                                  'variant' => null,
                              ];
                      Severity: Minor
                      Found in gateway_common/gateway.adapter.php - About 1 hr to fix

                        Method getTransactionSpecificValue has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            public function getTransactionSpecificValue( $gateway_field_name ) {
                                if ( !$this->transactions ) {
                                    $msg = self::getGatewayName() . ': Transactions structure is empty! No transaction can be constructed.';
                                    $this->logger->critical( $msg );
                                    throw new LogicException( $msg );
                        Severity: Minor
                        Found in gateway_common/gateway.adapter.php - About 1 hr to fix

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

                              public function finalizeInternalStatus( $status ) {
                                  /**
                                   * Handle session stuff!
                                   * -Behavior-
                                   * * Always, always increment numAttempt.
                          Severity: Minor
                          Found in gateway_common/gateway.adapter.php - About 1 hr to fix

                            Method validate has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                                public function validate() {
                                    $normalized = $this->dataObj->getData();
                            
                                    if ( $this->transaction_option( 'check_required' ) ) {
                                        // The fields returned by getRequiredFields only make sense
                            Severity: Minor
                            Found in gateway_common/gateway.adapter.php - About 1 hr to fix

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

                                  public function showMonthlyConvert() {
                                      $monthlyConvertAmounts = $this->getMonthlyConvertAmounts();
                                      if ( $monthlyConvertAmounts !== null ) {
                                          $mcMinimumAmount = $monthlyConvertAmounts[0][0];
                                          // check if amount is up to monthly convert minimum amount for specified currency
                              Severity: Minor
                              Found in gateway_common/gateway.adapter.php - 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 getAvailableSubmethods has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                              Open

                                  public function getAvailableSubmethods() {
                                      $method = $this->getPaymentMethod();
                                      $isRecurring = $this->getData_Unstaged_Escaped( 'recurring' );
                                      $country = $this->getData_Unstaged_Escaped( 'country' );
                                      $methodSupportsRecurring = $method ? $this->getPaymentMethodMeta( $method )['recurring'] : false;
                              Severity: Minor
                              Found in gateway_common/gateway.adapter.php - 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 getTransactionSpecificValue has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                              Open

                                  public function getTransactionSpecificValue( $gateway_field_name ) {
                                      if ( !$this->transactions ) {
                                          $msg = self::getGatewayName() . ': Transactions structure is empty! No transaction can be constructed.';
                                          $this->logger->critical( $msg );
                                          throw new LogicException( $msg );
                              Severity: Minor
                              Found in gateway_common/gateway.adapter.php - 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 validate has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                              Open

                                  public function validate() {
                                      $normalized = $this->dataObj->getData();
                              
                                      if ( $this->transaction_option( 'check_required' ) ) {
                                          // The fields returned by getRequiredFields only make sense
                              Severity: Minor
                              Found in gateway_common/gateway.adapter.php - 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 normalizeOrderID has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                              Open

                                  public function normalizeOrderID( $override = null, $dataObj = null ) {
                                      $selected = false;
                                      $source = null;
                                      $value = null;
                                      if ( $override !== null && $this->validateDataConstraintsMet( 'order_id', $override ) ) {
                              Severity: Minor
                              Found in gateway_common/gateway.adapter.php - 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 trimFieldToConstraints has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                              Open

                                  protected function trimFieldToConstraints( $value, $field ) {
                                      // Trim all values if they are a string
                                      $value = is_string( $value ) ? trim( $value ) : $value;
                              
                                      if ( isset( $this->dataConstraints[$field] ) && is_string( $value ) ) {
                              Severity: Minor
                              Found in gateway_common/gateway.adapter.php - About 35 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 finalizeInternalStatus has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                              Open

                                  public function finalizeInternalStatus( $status ) {
                                      /**
                                       * Handle session stuff!
                                       * -Behavior-
                                       * * Always, always increment numAttempt.
                              Severity: Minor
                              Found in gateway_common/gateway.adapter.php - About 35 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 method.
                              Open

                                          return false;
                              Severity: Major
                              Found in gateway_common/gateway.adapter.php - About 30 mins to fix

                                Avoid too many return statements within this method.
                                Open

                                        return !$isRecurring && $isMonthlyConvert;
                                Severity: Major
                                Found in gateway_common/gateway.adapter.php - About 30 mins to fix

                                  Avoid too many return statements within this method.
                                  Open

                                              return $convertAmounts['USD'];
                                  Severity: Major
                                  Found in gateway_common/gateway.adapter.php - About 30 mins to fix

                                    Avoid too many return statements within this method.
                                    Open

                                            return null;
                                    Severity: Major
                                    Found in gateway_common/gateway.adapter.php - About 30 mins to fix

                                      Avoid too many return statements within this method.
                                      Open

                                                      return '';
                                      Severity: Major
                                      Found in gateway_common/gateway.adapter.php - About 30 mins to fix

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

                                            public function getScoreUtmCampaignMap() {
                                                $score = 0;
                                        
                                                $campaign = $this->getData_Unstaged_Escaped( 'utm_campaign' );
                                                $campaignMap = $this->getGlobal( 'UtmCampaignMap' );
                                        Severity: Minor
                                        Found in gateway_common/gateway.adapter.php - 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 getScoreUtmSourceMap has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                        Open

                                            public function getScoreUtmSourceMap() {
                                                $score = 0;
                                        
                                                $source = $this->getData_Unstaged_Escaped( 'utm_source' );
                                                $sourceMap = $this->getGlobal( 'UtmSourceMap' );
                                        Severity: Minor
                                        Found in gateway_common/gateway.adapter.php - 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 getErrorMap has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                        Open

                                            public function getErrorMap( $code, $options = [] ) {
                                                $defaults = [
                                                    'translate' => false,
                                                ];
                                                $options = array_merge( $defaults, $options );
                                        Severity: Minor
                                        Found in gateway_common/gateway.adapter.php - 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 getScoreUtmMediumMap has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                        Open

                                            public function getScoreUtmMediumMap() {
                                                $score = 0;
                                        
                                                $medium = $this->getData_Unstaged_Escaped( 'utm_medium' );
                                                $mediumMap = $this->getGlobal( 'UtmMediumMap' );
                                        Severity: Minor
                                        Found in gateway_common/gateway.adapter.php - 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 getPaymentSubmethodMeta has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                        Open

                                            public function getPaymentSubmethodMeta( $payment_submethod = null, $payment_method = null ) {
                                                if ( $payment_submethod === null ) {
                                                    $payment_submethod = $this->getPaymentSubmethod();
                                                }
                                        
                                        
                                        Severity: Minor
                                        Found in gateway_common/gateway.adapter.php - 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

                                        Similar blocks of code found in 3 locations. Consider refactoring.
                                        Open

                                            public function getScoreUtmMediumMap() {
                                                $score = 0;
                                        
                                                $medium = $this->getData_Unstaged_Escaped( 'utm_medium' );
                                                $mediumMap = $this->getGlobal( 'UtmMediumMap' );
                                        Severity: Major
                                        Found in gateway_common/gateway.adapter.php and 2 other locations - About 3 hrs to fix
                                        gateway_common/gateway.adapter.php on lines 2010..2035
                                        gateway_common/gateway.adapter.php on lines 2095..2120

                                        Duplicated Code

                                        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                        Tuning

                                        This issue has a mass of 150.

                                        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                        Refactorings

                                        Further Reading

                                        Similar blocks of code found in 3 locations. Consider refactoring.
                                        Open

                                            public function getScoreUtmSourceMap() {
                                                $score = 0;
                                        
                                                $source = $this->getData_Unstaged_Escaped( 'utm_source' );
                                                $sourceMap = $this->getGlobal( 'UtmSourceMap' );
                                        Severity: Major
                                        Found in gateway_common/gateway.adapter.php and 2 other locations - About 3 hrs to fix
                                        gateway_common/gateway.adapter.php on lines 2010..2035
                                        gateway_common/gateway.adapter.php on lines 2053..2078

                                        Duplicated Code

                                        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                        Tuning

                                        This issue has a mass of 150.

                                        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                        Refactorings

                                        Further Reading

                                        Similar blocks of code found in 3 locations. Consider refactoring.
                                        Open

                                            public function getScoreUtmCampaignMap() {
                                                $score = 0;
                                        
                                                $campaign = $this->getData_Unstaged_Escaped( 'utm_campaign' );
                                                $campaignMap = $this->getGlobal( 'UtmCampaignMap' );
                                        Severity: Major
                                        Found in gateway_common/gateway.adapter.php and 2 other locations - About 3 hrs to fix
                                        gateway_common/gateway.adapter.php on lines 2053..2078
                                        gateway_common/gateway.adapter.php on lines 2095..2120

                                        Duplicated Code

                                        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                        Tuning

                                        This issue has a mass of 150.

                                        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                        Refactorings

                                        Further Reading

                                        There are no issues that match your filters.

                                        Category
                                        Status