wikimedia/mediawiki-extensions-DonationInterface

View on GitHub

Showing 275 of 275 total issues

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

        function addCvvFieldEvents() {
            cvvField.addEventListener( 'change', function ( event ) {
                cvvFieldError = !!event.error;
                if ( event.error ) {
                    $( '#cvvErrorMsg' ).text( mw.msg( 'donate_interface-error-msg-invalid-cvv-format' ) );
Severity: Major
Found in dlocal_gateway/forms/dlocal.js and 1 other location - About 4 hrs to fix
dlocal_gateway/forms/dlocal.js on lines 117..130

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

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

        function addExpirationFieldEvents() {
            expirationField.addEventListener( 'change', function ( event ) {
                expirationFieldError = !!event.error;
                if ( event.error ) {
                    $( '#expirationErrorMsg' ).text( mw.msg( 'donate_interface-error-msg-card-too-old' ) );
Severity: Major
Found in dlocal_gateway/forms/dlocal.js and 1 other location - About 4 hrs to fix
dlocal_gateway/forms/dlocal.js on lines 132..145

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

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 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 330 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 dlocal.adapter.php has 324 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 dlocal_gateway/dlocal.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

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

            public static function validate( GatewayType $gateway, $data, $check_not_empty = [] ) {
                // return the array of errors that should be generated on validate.
                // just the same way you'd do it if you were a form passing the error array around.
        
                /**
        Severity: Minor
        Found in gateway_common/DataValidator.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

        Function validate_personal has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
        Open

        window.validate_personal = function () {
            var value, countryField, emailAdd, invalid, apos, dotpos, domain,
                errorsPresent = false,
                $formField,
                i,
        Severity: Minor
        Found in modules/validate_input.js - 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

        Function displayResultsForDebug has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
        Open

            protected function displayResultsForDebug( PaymentTransactionResponse $results = null ) {
                $results = !$results ? $this->adapter->getTransactionResponse() : $results;
        
                if ( $this->adapter->getGlobal( 'DisplayDebug' ) !== true ) {
                    return;
        Severity: Minor
        Found in gateway_common/GatewayPage.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

        Function getFormFields has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
        Open

            public function getFormFields( ?array $knownData = null ): array {
                if ( $knownData === null ) {
                    $knownData = $this->getData_Unstaged_Escaped();
                }
                $fields = [];
        Severity: Minor
        Found in gateway_common/gateway.adapter.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

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

            public function getScoreUtmMediumMap() {
                $score = 0;
        
                $medium = $this->getData_Unstaged_Escaped( 'utm_medium' );
                $mediumMap = $this->getGlobal( 'UtmMediumMap' );
        Severity: Major
        Found in gateway_common/gateway.adapter.php and 2 other locations - About 3 hrs to fix
        gateway_common/gateway.adapter.php on lines 2010..2035
        gateway_common/gateway.adapter.php on lines 2095..2120

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

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

            public function getScoreUtmSourceMap() {
                $score = 0;
        
                $source = $this->getData_Unstaged_Escaped( 'utm_source' );
                $sourceMap = $this->getGlobal( 'UtmSourceMap' );
        Severity: Major
        Found in gateway_common/gateway.adapter.php and 2 other locations - About 3 hrs to fix
        gateway_common/gateway.adapter.php on lines 2010..2035
        gateway_common/gateway.adapter.php on lines 2053..2078

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

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

            public function getScoreUtmCampaignMap() {
                $score = 0;
        
                $campaign = $this->getData_Unstaged_Escaped( 'utm_campaign' );
                $campaignMap = $this->getGlobal( 'UtmCampaignMap' );
        Severity: Major
        Found in gateway_common/gateway.adapter.php and 2 other locations - About 3 hrs to fix
        gateway_common/gateway.adapter.php on lines 2053..2078
        gateway_common/gateway.adapter.php on lines 2095..2120

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

        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

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

                if ( result.formData && Object.keys( result.formData ).length > 0 ) {
                    // FIXME: reconstructing the raw result from the API
                    // which has been normalized down to just these two
                    // fields. Should we just pass the raw Adyen API result
                    // back to the front end? Seems like we would only want
        Severity: Major
        Found in adyen_gateway/forms/adyen.js and 1 other location - About 3 hrs to fix
        dlocal_gateway/forms/dlocal.js on lines 9..19

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

        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

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

                if ( result.isFailed ) {
                    mw.donationInterface.validation.showErrors( {
                        general: mw.msg( 'donate_interface-error-msg-general' )
                    } );
                } else if ( mw.monthlyConvert && mw.monthlyConvert.canShowModal() ) {
        Severity: Major
        Found in dlocal_gateway/forms/dlocal.js and 1 other location - About 3 hrs to fix
        adyen_gateway/forms/adyen.js on lines 436..459

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

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

            function callDonateApi( successCallback, extraData, action ) {
                di.forms.disable();
                di.forms.clean();
                $( '#topError' ).html( '' );
                $( '#errorReference' )
        Severity: Major
        Found in modules/js/ext.donationInterface.forms.js - About 3 hrs to fix

          Function init has 79 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              mc.init = function () {
                  var presetAmount,
                      locale = $( '#language' ).val() + '-' + $( '#country' ).val();
                  originalAmount = +$( '#amount' ).val();
                  currency = $( '#currency' ).val();
          Severity: Major
          Found in modules/js/ext.donationInterface.monthlyConvert.js - About 3 hrs to fix

            Method execute has 78 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function execute() {
                    if ( RequestContext::getMain()->getUser()->pingLimiter( 'submitpayment' ) ) {
                        // Allow rate limiting by setting e.g. $wgRateLimits['submitpayment']['ip']
                        return;
                    }
            Severity: Major
            Found in adyen_gateway/adyen_submit_payment.api.php - About 3 hrs to fix

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

                  public static function validate( GatewayType $gateway, $data, $check_not_empty = [] ) {
                      // return the array of errors that should be generated on validate.
                      // just the same way you'd do it if you were a form passing the error array around.
              
                      /**
              Severity: Major
              Found in gateway_common/DataValidator.php - About 3 hrs to fix

                Function sift3Distance has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
                Open

                  sift3Distance: function(s1, s2) {
                    // sift3: http://siderite.blogspot.com/2007/04/super-fast-and-accurate-string-distance.html
                    if (s1 == null || s1.length === 0) {
                      if (s2 == null || s2.length === 0) {
                        return 0;
                Severity: Minor
                Found in modules/js/mailcheck.js - 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