wikimedia/mediawiki-extensions-DonationInterface

View on GitHub

Showing 256 of 275 total issues

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

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

                      public function getCleanTrackingData( $unset = false ) {
                          // define valid tracking fields
                          $tracking_fields = [
                              'amount',
                              'appeal',
                  Severity: Major
                  Found in gateway_common/DonationData.php - About 2 hrs to fix

                    File adyen_submit_payment.api.php has 251 lines of code (exceeds 250 allowed). Consider refactoring.
                    Open

                    <?php
                    use SmashPig\Core\DataStores\QueueWrapper;
                    use SmashPig\Core\SequenceGenerators;
                    use SmashPig\Core\UtcDate;
                    use SmashPig\PaymentData\FinalStatus;
                    Severity: Minor
                    Found in adyen_gateway/adyen_submit_payment.api.php - About 2 hrs to fix

                      Method getSupportedGateways has 50 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          private function getSupportedGateways(
                              string $country,
                              ?string $currency,
                              string $paymentMethod,
                              ?string $paymentSubmethod,
                      Severity: Minor
                      Found in special/GatewayChooser.php - About 2 hrs to fix

                        Method getLocalizedValidationErrorResult has 50 lines of code (exceeds 25 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 dlocal_gateway/dlocal.adapter.php - About 2 hrs to fix

                          Function setup has 49 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              function setup() {
                                  var component_type,
                                      config,
                                      containerName = 'component-container',
                                      oldShowErrors,
                          Severity: Minor
                          Found in adyen_gateway/forms/adyen.js - About 1 hr to fix

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

                                protected function handleCreatedPayment(
                                    CreatePaymentResponse $createPaymentResult, PaymentProvider $provider
                                ): PaymentResult {
                                    $transactionStatus = $createPaymentResult->getStatus();
                            
                            
                            Severity: Minor
                            Found in braintree_gateway/braintree.adapter.php - About 1 hr to fix

                              Function submitPayment has 48 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                  function submitPayment() {
                                      if ( !mw.donationInterface.validation.validateAmount() ) {
                                          return;
                                      }
                                      if ( !cardSelected ) {
                              Severity: Minor
                              Found in amazon_gateway/amazon.js - About 1 hr to fix

                                Function validateAmount has 48 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                window.validateAmount = function () {
                                    var error = true,
                                        amount = $( 'input[name="amount"]' ).val(), // get the amount
                                        currency = '',
                                        rates = mw.config.get( 'wgDonationInterfaceCurrencyRates' ),
                                Severity: Minor
                                Found in modules/validate_input.js - About 1 hr to fix

                                  Method getParamsFromURL has 48 lines of code (exceeds 25 allowed). Consider refactoring.
                                  Open

                                      private function getParamsFromURL(): array {
                                          // Get country code from request param, or, if it's not sent or is invalid, use
                                          // geoip lookup
                                          $country = $this->sanitizedValOrNull( 'country' );
                                  
                                  
                                  Severity: Minor
                                  Found in special/GatewayChooser.php - About 1 hr to fix

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

                                        private function getParamsFromURL(): array {
                                            // Get country code from request param, or, if it's not sent or is invalid, use
                                            // geoip lookup
                                            $country = $this->sanitizedValOrNull( 'country' );
                                    
                                    
                                    Severity: Minor
                                    Found in special/GatewayChooser.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 getLocalizedValidationErrorResult has a Cognitive Complexity of 15 (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 dlocal_gateway/dlocal.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

                                    Severity
                                    Category
                                    Status
                                    Source
                                    Language