wikimedia/mediawiki-extensions-DonationInterface

View on GitHub

Showing 275 of 275 total issues

Method setAdapterAndValidate has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    protected function setAdapterAndValidate() {
        $this->ensureState();

        DonationInterface::setSmashPigProvider( $this->gateway );

Severity: Minor
Found in gateway_common/DonationApiBase.php - About 1 hr to fix

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

                    if ( cvvFieldHasErrors ) {
                        if ( cvvFieldEmpty ) {
                            errors.cvv = mw.msg( 'donate_interface-error-msg-cvv' );
                        } else {
                            errors.cvv = mw.msg( 'donate_interface-error-msg-invalid-cvv-format' );
    Severity: Major
    Found in dlocal_gateway/forms/dlocal.js and 1 other location - About 1 hr to fix
    dlocal_gateway/forms/dlocal.js on lines 171..177

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

    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 ( expFieldHasErrors ) {
                        if ( expirationFieldEmpty ) {
                            errors.expiration = mw.msg( 'donate_interface-error-msg-expiration' );
                        } else {
                            errors.expiration = mw.msg( 'donate_interface-error-msg-card-too-old' );
    Severity: Major
    Found in dlocal_gateway/forms/dlocal.js and 1 other location - About 1 hr to fix
    dlocal_gateway/forms/dlocal.js on lines 164..170

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

    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

    Method handleOptIn has 26 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        protected function handleOptIn( &$data ) {
            // Since this value can be 1, 0, or unset, we need to make
            // special conditionals for the mustache logic
            if ( !isset( $data['opt_in'] ) || $data['opt_in'] === '' ) {
                return;
    Severity: Minor
    Found in gateway_forms/Mustache.php - About 1 hr to fix

      Function submit has 26 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          di.forms.submit = function () {
              var paymentMethod = $( '#payment_method' ).val(),
                  isIframe = di.forms.isIframe();
              if ( !isIframe && paymentMethod !== 'cc' ) {
                  return oldSubmit();
      Severity: Minor
      Found in ingenico_gateway/forms/js/ingenico.js - About 1 hr to fix

        Method getNoCacheAction has 26 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            protected function getNoCacheAction() {
                $url = $this->gatewayPage->getRequest()->getFullRequestURL();
                $url_parts = wfParseUrl( $url );
                if ( isset( $url_parts['query'] ) ) {
                    $query_array = wfCgiToArray( $url_parts['query'] );
        Severity: Minor
        Found in gateway_forms/Form.php - About 1 hr to fix

          Function onerror has 26 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              window.onerror = function ( message, file, line, col, error ) {
                  var i, postdata;
                  for ( i = 0; i < ignorePatterns.length; i++ ) {
                      if ( ignoreRegexes.length <= i ) {
                          // turn patterns into regexes the first time through
          Severity: Minor
          Found in modules/js/ext.donationInterface.errorLog.js - About 1 hr to fix

            Method post_process has 26 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                protected function post_process() {
                    // if the trxn has been outright rejected, log it
                    if ( $this->gateway_adapter->getValidationAction() == ValidationAction::REJECT ) {
                        $this->log(
                            $this->gateway_adapter->getData_Unstaged_Escaped( 'contribution_tracking_id' ), 'Rejected'
            Severity: Minor
            Found in extras/conversion_log/conversion_log.body.php - About 1 hr to fix

              Method onBeforePageDisplay has 26 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public static function onBeforePageDisplay( $outputPage, $skin ) {
                      if ( self::isEndowment() ) {
                          // FIXME: need to keep generated CSS in sync with
                          // @see ResourceLoaderSkinModule::getStyles
                          // html body is prepended to give us more-specific selectors
              Severity: Minor
              Found in gateway_common/EndowmentHooks.php - About 1 hr to fix

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

                    public function validate() {
                        $normalized = $this->dataObj->getData();
                
                        if ( $this->transaction_option( 'check_required' ) ) {
                            // The fields returned by getRequiredFields only make sense
                Severity: Minor
                Found in gateway_common/gateway.adapter.php - About 1 hr to fix

                  Method createForGateway has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      public static function createForGateway( $gateway, $variant, Config $mwConfig ) {
                          $extensionBaseDir = $mwConfig->get( 'ExtensionDirectory' ) . DIRECTORY_SEPARATOR
                              . 'DonationInterface';
                          /** The following conditional can be deleted when we get rid of WmfFramework */
                          if ( !is_dir( $extensionBaseDir ) ) {
                  Severity: Minor
                  Found in gateway_common/ConfigurationReader.php - About 1 hr to fix

                    Function canBypassMinFraud has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                    Open

                        protected function canBypassMinFraud() {
                            // if the data bits data_hash and action are not set, we need to hit minFraud
                            $localdata = $this->gateway_adapter->getData_Unstaged_Escaped();
                            if ( !isset( $localdata['data_hash'] ) || !strlen(
                                    $localdata['data_hash']
                    Severity: Minor
                    Found in extras/custom_filters/filters/minfraud/minfraud.body.php - About 55 mins 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 execute has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                    Open

                        public function execute( $subpage ) {
                            $this->setHeaders();
                            $this->addStylesScriptsAndViewport();
                    
                            $params = $this->getRequest()->getValues();
                    Severity: Minor
                    Found in special/RecurUpgrade.php - About 55 mins 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 getNoCacheAction has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                    Open

                        protected function getNoCacheAction() {
                            $url = $this->gatewayPage->getRequest()->getFullRequestURL();
                            $url_parts = wfParseUrl( $url );
                            if ( isset( $url_parts['query'] ) ) {
                                $query_array = wfCgiToArray( $url_parts['query'] );
                    Severity: Minor
                    Found in gateway_forms/Form.php - About 55 mins 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 stage has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                    Open

                        public function stage( GatewayType $adapter, $normalized, &$stagedData ) {
                            if ( !isset( $normalized['language'] ) ) {
                                return;
                            }
                            $language = $normalized['language'];
                    Severity: Minor
                    Found in gateway_common/DonorLanguage.php - About 55 mins 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 handleCreatedPayment has a Cognitive Complexity of 9 (exceeds 5 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 55 mins 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 value_appears_in has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                    Open

                        public static function value_appears_in( $needle, $haystack ) {
                            $needle = ( is_array( $needle ) ) ? $needle : [ $needle ];
                            $haystack = ( is_array( $haystack ) ) ? $haystack : [ $haystack ];
                    
                            $plusCheck = array_key_exists( '+', $haystack );
                    Severity: Minor
                    Found in gateway_common/DataValidator.php - About 55 mins 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 normalizeOrderID has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                    Open

                        public function normalizeOrderID( $override = null, $dataObj = null ) {
                            $selected = false;
                            $source = null;
                            $value = null;
                            if ( $override !== null && $this->validateDataConstraintsMet( 'order_id', $override ) ) {
                    Severity: Minor
                    Found in gateway_common/gateway.adapter.php - About 55 mins 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 9 (exceeds 5 allowed). Consider refactoring.
                    Open

                        public function validate() {
                            $normalized = $this->dataObj->getData();
                    
                            if ( $this->transaction_option( 'check_required' ) ) {
                                // The fields returned by getRequiredFields only make sense
                    Severity: Minor
                    Found in gateway_common/gateway.adapter.php - About 55 mins 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 handleDonationRequest has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                    Open

                        protected function handleDonationRequest() {
                            $this->setHeaders();
                    
                            // TODO: This is where we should feed GPCS parameters into the gateway
                            // and DonationData, rather than harvest params in the adapter itself.
                    Severity: Minor
                    Found in gateway_common/GatewayPage.php - About 55 mins 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