wikimedia/mediawiki-extensions-DonationInterface

View on GitHub
gateway_common/GatewayPage.php

Summary

Maintainability
D
2 days
Test Coverage

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

    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

    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

      GatewayPage has 22 functions (exceeds 20 allowed). Consider refactoring.
      Open

      abstract class GatewayPage extends UnlistedSpecialPage {
          /**
           * flag for setting Monthly Convert modal on template
           * @var bool
           */
      Severity: Minor
      Found in gateway_common/GatewayPage.php - About 2 hrs to fix

        Method displayResultsForDebug has 51 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            protected function displayResultsForDebug( ?PaymentTransactionResponse $results = null ) {
                $results = !$results ? $this->adapter->getTransactionResponse() : $results;
        
                if ( $this->adapter->getGlobal( 'DisplayDebug' ) !== true ) {
                    return;
        Severity: Major
        Found in gateway_common/GatewayPage.php - About 2 hrs to fix

          Function setClientVariables has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
          Open

              public function setClientVariables( &$vars ) {
                  $language = $this->adapter->getData_Unstaged_Escaped( 'language' );
                  $country = $this->adapter->getData_Unstaged_Escaped( 'country' );
                  $vars['wgDonationInterfaceAmountRules'] = $this->adapter->getDonationRules();
                  $vars['wgDonationInterfaceLogDebug'] = $this->adapter->getGlobal( 'LogDebug' );
          Severity: Minor
          Found in gateway_common/GatewayPage.php - About 1 hr 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 setClientVariables has 37 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function setClientVariables( &$vars ) {
                  $language = $this->adapter->getData_Unstaged_Escaped( 'language' );
                  $country = $this->adapter->getData_Unstaged_Escaped( 'country' );
                  $vars['wgDonationInterfaceAmountRules'] = $this->adapter->getDonationRules();
                  $vars['wgDonationInterfaceLogDebug'] = $this->adapter->getGlobal( 'LogDebug' );
          Severity: Minor
          Found in gateway_common/GatewayPage.php - About 1 hr to fix

            Method renderResponse has 29 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                protected function renderResponse( PaymentResult $result ) {
                    if ( $result->isFailed() ) {
                        $this->logger->info( 'Displaying fail page for failed PaymentResult' );
                        $this->displayFailPage();
                        return;
            Severity: Minor
            Found in gateway_common/GatewayPage.php - About 1 hr to fix

              Function execute has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
              Open

                  public function execute( $par ) {
                      // FIXME: Deprecate "language" param.
                      $language = $this->getRequest()->getVal( 'language' );
                      $this->showError = $this->getRequest()->getBool( 'showError' );
              
              
              Severity: Minor
              Found in gateway_common/GatewayPage.php - About 1 hr 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

              Avoid too many return statements within this method.
              Open

                          return;
              Severity: Major
              Found in gateway_common/GatewayPage.php - About 30 mins to fix

                Avoid too many return statements within this method.
                Open

                            return;
                Severity: Major
                Found in gateway_common/GatewayPage.php - About 30 mins to fix

                  There are no issues that match your filters.

                  Category
                  Status