wikimedia/mediawiki-extensions-DonationInterface

View on GitHub

Showing 275 of 275 total issues

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

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

      <?php
      
      class Gateway_Extras_CustomFilters_Referrer extends Gateway_Extras {
      
          /**
      Severity: Major
      Found in extras/custom_filters/filters/referrer/referrer.body.php and 1 other location - About 1 day to fix
      extras/custom_filters/filters/source/source.body.php on lines 1..74

      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 356.

      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 2 locations. Consider refactoring.
      Open

      <?php
      
      class Gateway_Extras_CustomFilters_Source extends Gateway_Extras {
      
          /**
      Severity: Major
      Found in extras/custom_filters/filters/source/source.body.php and 1 other location - About 1 day to fix
      extras/custom_filters/filters/referrer/referrer.body.php on lines 1..75

      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 356.

      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

      File DonationData.php has 722 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

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

                  if ( component_type === GOOGLEPAY_COMPONENT_TYPE ) {
                      component.isAvailable().then( function () {
                          component.mount( '#' + containerName );
                      } ).catch( function () {
                          mw.donationInterface.validation.showErrors( {
          Severity: Major
          Found in adyen_gateway/forms/adyen.js and 1 other location - About 1 day to fix
          adyen_gateway/forms/adyen.js on lines 658..700

          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 245.

          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 2 locations. Consider refactoring.
          Open

                  } else if ( component_type === 'applepay' ) {
                      component.isAvailable().then( function () {
                          component.mount( '#' + containerName );
                      } ).catch( function () {
                          mw.donationInterface.validation.showErrors( {
          Severity: Major
          Found in adyen_gateway/forms/adyen.js and 1 other location - About 1 day to fix
          adyen_gateway/forms/adyen.js on lines 631..700

          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 245.

          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

          File adyen.js has 541 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 435 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            <?php
            
            use LightnCandy\LightnCandy;
            use MediaWiki\MediaWikiServices;
            use SmashPig\Core\PaymentError;
            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 {
                    protected $normalized = [];
                    protected $dataSources = [];
                    protected $gateway;
                    protected $gatewayID;
                Severity: Minor
                Found in gateway_common/DonationData.php - About 6 hrs to fix

                  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

                    File GatewayPage.php has 376 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 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 getComponentConfig has 121 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 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

                            Severity
                            Category
                            Status
                            Source
                            Language