wikimedia/mediawiki-extensions-DonationInterface

View on GitHub

Showing 311 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

      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

      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

      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

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

              protected function getLocalizedValidationErrorResult( array $validationErrors ): PaymentResult {
                  $localizedErrors = [];
                  foreach ( $validationErrors as $error ) {
                      $field = $error->getField();
                      $debugMessage = $error->getDebugMessage();
          Severity: Major
          Found in gravy_gateway/gravy.adapter.php and 1 other location - About 1 day to fix
          dlocal_gateway/dlocal.adapter.php on lines 265..317

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

          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

              protected function getLocalizedValidationErrorResult( array $validationErrors ): PaymentResult {
                  $localizedErrors = [];
                  foreach ( $validationErrors as $error ) {
                      $field = $error->getField();
                      $debugMessage = $error->getDebugMessage();
          Severity: Major
          Found in dlocal_gateway/dlocal.adapter.php and 1 other location - About 1 day to fix
          gravy_gateway/gravy.adapter.php on lines 377..429

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

          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 639..708

          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

                  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 666..708

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

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

              <?php
              
              use SmashPig\Core\ValidationError;
              
              class StreetNumberValidation implements ValidationHelper {
              Severity: Major
              Found in gateway_common/StreetNumberValidation.php and 1 other location - About 6 hrs to fix
              gateway_common/PostalCodeValidation.php on lines 1..38

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

              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
              
              use SmashPig\Core\ValidationError;
              
              class PostalCodeValidation implements ValidationHelper {
              Severity: Major
              Found in gateway_common/PostalCodeValidation.php and 1 other location - About 6 hrs to fix
              gateway_common/StreetNumberValidation.php on lines 1..38

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

              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

              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
                      Severity
                      Category
                      Status
                      Source
                      Language