wikimedia/mediawiki-extensions-DonationInterface

View on GitHub
paypal_ec_gateway/paypal_express.adapter.php

Summary

Maintainability
C
1 day
Test Coverage

Method processDonorReturn has 64 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function processDonorReturn( $requestValues ) {
        if (
            empty( $requestValues['token'] )
        ) {
            throw new ResponseProcessingException(
Severity: Major
Found in paypal_ec_gateway/paypal_express.adapter.php - About 2 hrs to fix

    Method defineTransactions has 45 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        protected function defineTransactions() {
            $this->transactions = [];
    
            // https://developer.paypal.com/docs/classic/api/merchant/SetExpressCheckout_API_Operation_NVP/
            $this->transactions['SetExpressCheckout'] = [
    Severity: Minor
    Found in paypal_ec_gateway/paypal_express.adapter.php - About 1 hr to fix

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

          public function processDonorReturn( $requestValues ) {
              if (
                  empty( $requestValues['token'] )
              ) {
                  throw new ResponseProcessingException(
      Severity: Minor
      Found in paypal_ec_gateway/paypal_express.adapter.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 doPayment has 29 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function doPayment() {
              $this->setValidationAction( ValidationAction::PROCESS, true );
              $this->logger->debug( 'Running onGatewayReady filters' );
              Gateway_Extras_CustomFilters::onGatewayReady( $this );
              if ( $this->getValidationAction() != ValidationAction::PROCESS ) {
      Severity: Minor
      Found in paypal_ec_gateway/paypal_express.adapter.php - About 1 hr to fix

        Avoid too many return statements within this method.
        Open

                        return $this->captureOneTimePayment( $provider );
        Severity: Major
        Found in paypal_ec_gateway/paypal_express.adapter.php - About 30 mins to fix

          Avoid too many return statements within this method.
          Open

                          return $this->createRecurringProfile( $provider );
          Severity: Major
          Found in paypal_ec_gateway/paypal_express.adapter.php - About 30 mins to fix

            Avoid too many return statements within this method.
            Open

                    return PaymentResult::fromResults(
                        new PaymentTransactionResponse(),
                        $this->getFinalStatus()
                    );
            Severity: Major
            Found in paypal_ec_gateway/paypal_express.adapter.php - About 30 mins to fix

              Function addDonorDetailsToSession has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                  protected function addDonorDetailsToSession( PaymentDetailResponse $detailResponse ): void {
                      $donorDetails = $detailResponse->getDonorDetails();
                      if ( $donorDetails !== null ) {
                          $responseData = [
                              'first_name' => $donorDetails->getFirstName(),
              Severity: Minor
              Found in paypal_ec_gateway/paypal_express.adapter.php - About 25 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

              There are no issues that match your filters.

              Category
              Status