wikimedia/mediawiki-extensions-DonationInterface

View on GitHub

Showing 275 of 275 total issues

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 getRecurDetails has 59 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public static function getRecurDetails( $checksum, $contact_id ) {
        global $wgDonationInterfaceCiviproxyURLBase;

        $client = new GuzzleHttp\Client();
        $params = [
Severity: Major
Found in extras/civiproxy/CiviproxyConnect.php - About 2 hrs to fix

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

        public function validate( GatewayType $adapter, $normalized, &$errors ) {
            if (
                !isset( $normalized['amount'] ) ||
                !isset( $normalized['currency'] )
            ) {
    Severity: Major
    Found in gateway_common/Amount.php - About 2 hrs to fix

      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

        GatewayPage has 22 functions (exceeds 20 allowed). Consider refactoring.
        Open

        abstract class GatewayPage extends UnlistedSpecialPage {
            /**
             * flag for setting Monthly Convert modal on template
             * @var bool
             */
        Severity: Minor
        Found in gateway_common/GatewayPage.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 filter has 57 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                private function filter() {
                    $user_ip = $this->gateway_adapter->getData_Unstaged_Escaped( 'user_ip' );
            
                    // Determine IP status before doing anything complex
                    $wl = DataValidator::ip_is_listed( $user_ip, $this->gateway_adapter->getGlobal( 'IPAllowList' ) );
            Severity: Major
            Found in extras/session_velocity/session_velocity.body.php - About 2 hrs to fix

              File EmailPreferences.php has 261 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              <?php
              
              use SmashPig\Core\DataStores\QueueWrapper;
              
              class EmailPreferences extends UnlistedSpecialPage {
              Severity: Minor
              Found in special/EmailPreferences.php - About 2 hrs to fix

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

                    public function chooseGatewayByPriority( $supportedGateways, $params ) {
                        $rules = $this->getConfig()->get( 'DonationInterfaceGatewayPriorityRules' );
                
                        foreach ( $rules as $rule ) {
                            // Do our $params match all the conditions for this rule?
                Severity: Major
                Found in special/GatewayChooser.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

                    File GatewayChooser.php has 258 lines of code (exceeds 250 allowed). Consider refactoring.
                    Open

                    <?php
                    
                    /**
                     * GatewayChooser acts as a gateway-agnostic landing page.
                     * When passed a country, currency, and payment method combination, it determines the
                    Severity: Minor
                    Found in special/GatewayChooser.php - About 2 hrs to fix

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

                          public function doRecurringConversion(): PaymentResult {
                              $sessionData = $this->session_getData( 'Donor' );
                              if (
                                  empty( $sessionData['recurring_payment_token'] ) ||
                                  empty( $sessionData['gateway_txn_id'] )
                      Severity: Major
                      Found in gateway_common/RecurringConversionTrait.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

                          Method addFormFields has 53 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              protected function addFormFields( &$data ) {
                                  // If any of these are required, show the address block
                                  $address_fields = [
                                      'city',
                                      'state_province',
                          Severity: Major
                          Found in gateway_forms/Mustache.php - About 2 hrs to fix

                            Method getTemplateParams has 53 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                                protected function getTemplateParams() {
                                    global $wgDonationInterfaceEmailFormHelpEmail, $wgDonationInterfaceRecurringDonateURL;
                            
                                    $paramList = [
                                        'campaign',
                            Severity: Major
                            Found in email_forms/EmailForm.php - About 2 hrs to fix

                              Function getLocalizedValidationErrorResult has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
                              Open

                                  protected function getLocalizedValidationErrorResult( array $validationErrors ): PaymentResult {
                                      $localizedErrors = [];
                                      foreach ( $validationErrors as $error ) {
                                          $field = $error->getField();
                                          $debugMessage = $error->getDebugMessage();
                              Severity: Minor
                              Found in braintree_gateway/braintree.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 addSubmethods has 51 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                  protected function addSubmethods( &$data ) {
                                      if ( !$this->gatewayPage->showSubmethodButtons() ) {
                                          $data['show_submethods'] = false;
                                          return;
                                      }
                              Severity: Major
                              Found in gateway_forms/Mustache.php - About 2 hrs to fix

                                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 displayResultsForDebug has 51 lines of code (exceeds 25 allowed). Consider refactoring.
                                  Open

                                      protected function displayResultsForDebug( PaymentTransactionResponse $results = null ) {
                                          $results = !$results ? $this->adapter->getTransactionResponse() : $results;
                                  
                                          if ( $this->adapter->getGlobal( 'DisplayDebug' ) !== true ) {
                                              return;
                                  Severity: Major
                                  Found in gateway_common/GatewayPage.php - About 2 hrs to fix
                                    Severity
                                    Category
                                    Status
                                    Source
                                    Language