pagseguro/magento2

View on GitHub
Controller/Payment/Request.php

Summary

Maintainability
D
1 day
Test Coverage

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

    public function execute()
    {
        $lastRealOrder = $this->_checkoutSession->getLastRealOrder();

        if ($lastRealOrder->getPayment()===null) {
Severity: Major
Found in Controller/Payment/Request.php - About 5 hrs to fix

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

        public function execute()
        {
            $lastRealOrder = $this->_checkoutSession->getLastRealOrder();
    
            if ($lastRealOrder->getPayment()===null) {
    Severity: Minor
    Found in Controller/Payment/Request.php - About 5 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

    Consider simplifying this complex logical expression.
    Open

                    if (!isset($paymentData['additional_information']['credit_card_document'])
                        || ! isset($paymentData['additional_information']['hash'])
                        || ! isset($paymentData['additional_information']['credit_card_token'])
                        || ! isset($paymentData['additional_information']['credit_card_holder_name'])
                        || ! isset($paymentData['additional_information']['credit_card_holder_birthdate'])
    Severity: Major
    Found in Controller/Payment/Request.php - About 1 hr to fix

      Avoid too many return statements within this method.
      Open

                      return $this->_redirect(sprintf('%s%s', $this->baseUrl(), 'pagseguro/direct/success'));
      Severity: Major
      Found in Controller/Payment/Request.php - About 30 mins to fix

        Avoid too many return statements within this method.
        Open

                    return $this->_redirect($this->_payment->createPaymentRequest());
        Severity: Major
        Found in Controller/Payment/Request.php - About 30 mins to fix

          Avoid too many return statements within this method.
          Open

                      return $this->_redirect('pagseguro/payment/failure');
          Severity: Major
          Found in Controller/Payment/Request.php - About 30 mins to fix

            Avoid too many return statements within this method.
            Open

                            return $this->_redirect(sprintf('%s%s', $this->baseUrl(), 'pagseguro/payment/failure'));
            Severity: Major
            Found in Controller/Payment/Request.php - About 30 mins to fix

              There are no issues that match your filters.

              Category
              Status