wikimedia/mediawiki-extensions-DonationInterface

View on GitHub

Showing 275 of 311 total issues

File gateway.adapter.php has 1616 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

      File DonationData.php has 723 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      <?php
      use SmashPig\Core\DataStores\QueueWrapper;
      use SmashPig\Core\SequenceGenerators;
      use SmashPig\PaymentData\ReferenceData\CurrencyRates;
      use SmashPig\PaymentData\ReferenceData\NationalCurrencies;
      Severity: Major
      Found in gateway_common/DonationData.php - About 1 day to fix

        Method getFallbacks has 331 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            protected function getFallbacks() {
                return [
                    'aae' => 'sq',
                    'aao' => 'ar',
                    'aat' => 'sq',
        Severity: Major
        Found in ingenico_gateway/IngenicoLocale.php - About 1 day to fix

          File adyen.js has 559 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          /* global AdyenCheckout, Promise */
          ( function ( $, mw ) {
              // promise objects are for Apple Pay - see comments below
              var checkout, onSubmit, authPromise, submitPromise,
                  configFromServer = mw.config.get( 'adyenConfiguration' ),
          Severity: Major
          Found in adyen_gateway/forms/adyen.js - About 1 day to fix

            File Mustache.php has 438 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            <?php
            
            use LightnCandy\LightnCandy;
            use MediaWiki\Extension\CLDR\CountryNames;
            use MediaWiki\MediaWikiServices;
            Severity: Minor
            Found in gateway_forms/Mustache.php - About 6 hrs to fix

              Function setupCardForm has 158 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  function setupCardForm() {
                      var dlocalInstance = dlocal( mw.config.get( 'wgDlocalSmartFieldApiKey' ) ),
                          fields = dlocalInstance.fields( {
                              locale: mapLang( $( '#language' ).val() ),
                              country: country
              Severity: Major
              Found in dlocal_gateway/forms/dlocal.js - About 6 hrs to fix

                Function chooseGatewayByPriority has a Cognitive Complexity of 41 (exceeds 5 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: Minor
                Found in special/GatewayChooser.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 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

                DonationData has 44 functions (exceeds 20 allowed). Consider refactoring.
                Open

                class DonationData implements LogPrefixProvider {
                    /** @var array */
                    protected $normalized = [];
                    /** @var array */
                    protected $dataSources = [];
                Severity: Minor
                Found in gateway_common/DonationData.php - About 6 hrs to fix

                  File adyen_checkout.adapter.php has 387 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

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

                    <?php
                    /**
                     * Wikimedia Foundation
                     *
                     * LICENSE
                    Severity: Minor
                    Found in gateway_common/GatewayPage.php - About 5 hrs to fix

                      Function getComponentConfig has 126 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          function getComponentConfig( type, checkoutConfig ) {
                              var config = {};
                              switch ( type ) {
                                  case 'card':
                                      // Note: Debug messages are only sent and logged server-side if
                      Severity: Major
                      Found in adyen_gateway/forms/adyen.js - About 5 hrs to fix

                        Function validate_personal has 125 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                        window.validate_personal = function () {
                            var value, countryField, emailAdd, invalid, apos, dotpos, domain,
                                errorsPresent = false,
                                $formField,
                                i,
                        Severity: Major
                        Found in modules/validate_input.js - About 5 hrs to fix

                          File DataValidator.php has 372 lines of code (exceeds 250 allowed). Consider refactoring.
                          Open

                          <?php
                          
                          use SmashPig\Core\ValidationError;
                          
                          /**
                          Severity: Minor
                          Found in gateway_common/DataValidator.php - About 4 hrs to fix

                            Function getSupportedGateways has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
                            Open

                                private function getSupportedGateways(
                                    string $country,
                                    ?string $currency,
                                    string $paymentMethod,
                                    ?string $paymentSubmethod,
                            Severity: Minor
                            Found in special/GatewayChooser.php - About 4 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

                            File IngenicoLocale.php has 336 lines of code (exceeds 250 allowed). Consider refactoring.
                            Open

                            <?php
                            
                            /**
                             * Ingenico's connect API returns a 400 BAD REQUEST if the locale string
                             * doesn't match the xx_YY format. This class tries to find a decent ALPHA2
                            Severity: Minor
                            Found in ingenico_gateway/IngenicoLocale.php - About 4 hrs to fix

                              File dlocal.js has 324 lines of code (exceeds 250 allowed). Consider refactoring.
                              Open

                              /*global dlocal:true*/
                              ( function ( $, mw ) {
                                  var country = $( '#country' ).val(),
                                      extraData = {},
                                      isRecurring = !!$( '#recurring' ).val(),
                              Severity: Minor
                              Found in dlocal_gateway/forms/dlocal.js - About 3 hrs to fix

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

                                <?php
                                
                                use MediaWiki\MediaWikiServices;
                                use Psr\Log\LogLevel;
                                use SmashPig\Core\PaymentError;
                                Severity: Minor
                                Found in gravy_gateway/gravy.adapter.php - About 3 hrs to fix

                                  Function addFormFields has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
                                  Open

                                      protected function addFormFields( &$data ) {
                                          // If any of these are required, show the address block
                                          $address_fields = [
                                              'city',
                                              'state_province',
                                  Severity: Minor
                                  Found in gateway_forms/Mustache.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

                                  Severity
                                  Category
                                  Status
                                  Source
                                  Language