wikimedia/mediawiki-extensions-DonationInterface

View on GitHub

Showing 256 of 275 total issues

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

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

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

              protected function session_resetOnSwitch() {
                  $oldData = $this->session_getData( 'Donor' );
                  if ( !is_array( $oldData ) ) {
                      return;
                  }
          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

          DataValidator has 26 functions (exceeds 20 allowed). Consider refactoring.
          Open

          class DataValidator {
          
              /**
               * getErrorToken, intended to be used by classes that exist relatively close
               * to the form classes, returns the error token (defined on the forms) that
          Severity: Minor
          Found in gateway_common/DataValidator.php - About 3 hrs to fix

            Function processDonorReturn has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
            Open

                public function processDonorReturn( $requestValues ) {
                    // FIXME: make sure we're processing the order ID we expect!
                    /** @var HostedCheckoutProvider $provider */
                    $provider = $this->getPaymentProvider();
                    '@phan-var HostedCheckoutProvider $provider';
            Severity: Minor
            Found in ingenico_gateway/ingenico.adapter.php - About 2 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

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

                public function execute( $par ) {
                    // FIXME: Deprecate "language" param.
                    $language = $this->getRequest()->getVal( 'language' );
                    $this->showError = $this->getRequest()->getBool( 'showError' );
            
            
            Severity: Major
            Found in gateway_common/GatewayPage.php - About 2 hrs to fix

              Function addSubmethods has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
              Open

                  protected function addSubmethods( &$data ) {
                      if ( !$this->gatewayPage->showSubmethodButtons() ) {
                          $data['show_submethods'] = false;
                          return;
                      }
              Severity: Minor
              Found in gateway_forms/Mustache.php - About 2 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 getDonationRules has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
              Open

                  public function getDonationRules(): array {
                      $rules = $this->config['donation_rules'];
                      foreach ( $rules as $rule ) {
                          // Do our $params match all the conditions for this rule?
                          $ruleMatches = true;
              Severity: Minor
              Found in gateway_common/gateway.adapter.php - About 2 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 amazon.js has 281 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              /*global amazon:true, OffAmazonPayments:true*/
              ( function ( $, mw ) {
                  var clientId = mw.config.get( 'wgAmazonGatewayClientID' ),
                      sellerId = mw.config.get( 'wgAmazonGatewaySellerID' ),
                      sandbox = mw.config.get( 'wgAmazonGatewaySandbox' ),
              Severity: Minor
              Found in amazon_gateway/amazon.js - About 2 hrs to fix

                Method handleCreatedPayment has 65 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    protected function handleCreatedPayment(
                        IPaymentProvider $provider, PaymentDetailResponse $authorizeResult
                    ): PaymentResult {
                        $transactionStatus = $authorizeResult->getStatus();
                        $responseData = [
                Severity: Major
                Found in adyen_gateway/adyen_checkout.adapter.php - About 2 hrs to fix

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

                      public function execute() {
                          $this->gateway = 'amazon';
                          DonationInterface::setSmashPigProvider( 'amazon' );
                          $output = $this->getResult();
                          $recurring = $this->getParameter( 'recurring' );
                  Severity: Major
                  Found in amazon_gateway/amazon.api.php - About 2 hrs to fix

                    Method handleResultRequest has 65 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        protected function handleResultRequest() {
                            // no longer letting people in without these things. If this is
                            // preventing you from doing something, you almost certainly want to be
                            // somewhere else.
                            $deadSession = false;
                    Severity: Major
                    Found in gateway_common/ResultSwitcher.php - About 2 hrs to fix

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

                          public function validate( GatewayType $unused, $normalized, &$errors ) {
                              if (
                                  !isset( $normalized['country'] ) ||
                                  !isset( $normalized[self::$key] )
                              ) {
                      Severity: Minor
                      Found in gateway_common/FiscalNumber.php - About 2 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