wp-pay-gateways/adyen

View on GitHub

Showing 97 of 97 total issues

Method __construct has 62 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function __construct( $country, $street = null, $house_number_or_name = null, $postal_code = null, $city = null, $state_or_province = null ) {
        /*
         * The two-character country code of the address.
         *
         * The permitted country codes are defined in ISO-3166-1 alpha-2 (e.g. 'NL').
Severity: Major
Found in src/Address.php - About 2 hrs to fix

    Method start has 60 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function start( Payment $payment ) {
            // Amount.
            $amount = AmountTransformer::transform( $payment->get_total_amount() );
    
            // Payment method type.
    Severity: Major
    Found in src/WebSdkGateway.php - About 2 hrs to fix

      Method field_certificate has 56 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function field_certificate( $field ) {
              if ( ! \array_key_exists( 'meta_key', $field ) ) {
                  return;
              }
      
      
      Severity: Major
      Found in src/Integration.php - About 2 hrs to fix

        BrowserInformation has 21 functions (exceeds 20 allowed). Consider refactoring.
        Open

        class BrowserInformation implements \JsonSerializable {
            /**
             * The accept header value of the shopper's browser.
             *
             * @link https://docs.adyen.com/api-explorer/#/PaymentSetupAndVerificationService/v51/payments__reqParam_browserInfo-acceptHeader
        Severity: Minor
        Found in src/BrowserInformation.php - About 2 hrs to fix

          Method update_status has 52 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function update_status( Payment $payment ) {
                  // Process payload on return.
                  if ( filter_has_var( INPUT_GET, 'payload' ) ) {
                      $payload = filter_input( INPUT_GET, 'payload', FILTER_SANITIZE_STRING );
          
          
          Severity: Major
          Found in src/DropInGateway.php - About 2 hrs to fix

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

                public function rest_api_adyen_payments_result( WP_REST_Request $request ) {
                    $config_id = $request->get_param( 'config_id' );
            
                    if ( null === $config_id ) {
                        return new WP_Error(
            Severity: Major
            Found in src/PaymentsResultController.php - About 2 hrs to fix

              Function field_certificate has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
              Open

                  public function field_certificate( $field ) {
                      if ( ! \array_key_exists( 'meta_key', $field ) ) {
                          return;
                      }
              
              
              Severity: Minor
              Found in src/Integration.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 rest_api_adyen_payments has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
              Open

                  public function rest_api_adyen_payments( WP_REST_Request $request ) {
                      $payment_id = $request->get_param( 'payment_id' );
              
                      // Payment ID.
                      if ( null === $payment_id ) {
              Severity: Minor
              Found in src/PaymentsController.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 get_checkout_payment_methods_configuration has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
              Open

                  public function get_checkout_payment_methods_configuration( $payment_method_types, Payment $payment ) {
                      $configuration = array();
              
                      /*
                       * Apple Pay.
              Severity: Minor
              Found in src/DropInGateway.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 rest_api_applepay_merchant_validation has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
              Open

                  public function rest_api_applepay_merchant_validation( WP_REST_Request $request ) {
                      $payment_id = $request->get_param( 'payment_id' );
              
                      // Payment ID.
                      if ( null === $payment_id ) {
              Severity: Minor
              Found in src/PaymentsController.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 save_post has 46 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public function save_post( $post_id ) {
                      // Files.
                      $files = array(
                          '_pronamic_gateway_adyen_apple_pay_merchant_id_certificate_file' => '_pronamic_gateway_adyen_apple_pay_merchant_id_certificate',
                          '_pronamic_gateway_adyen_apple_pay_merchant_id_private_key_file' => '_pronamic_gateway_adyen_apple_pay_merchant_id_private_key',
              Severity: Minor
              Found in src/Integration.php - About 1 hr to fix

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

                    public function rest_api_init() {
                        // Register REST route `/payments//{payment_id}`.
                        register_rest_route(
                            Integration::REST_ROUTE_NAMESPACE,
                            '/payments/(?P<payment_id>\d+)',
                Severity: Minor
                Found in src/PaymentsController.php - About 1 hr to fix

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

                      public static function update_payment( Payment $payment, PaymentResponse $response ) {
                          // Add note.
                          $note = sprintf(
                              '<p>%s</p>',
                              sprintf(
                  Severity: Minor
                  Found in src/PaymentResponseHelper.php - About 1 hr to fix

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

                        public function payment_redirect( Payment $payment ) {
                            // Check payment ID.
                            $payment_id = $payment->get_id();
                    
                            if ( null === $payment_id ) {
                    Severity: Minor
                    Found in src/DropInGateway.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

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

                          case 'Error':
                            // Inform the shopper that there was an error processing their payment.
                    
                            /*
                             * You'll receive a `refusalReason` in the same response, indicating the cause of the error.
                    Severity: Major
                    Found in js/dist/checkout-drop-in.js and 1 other location - About 1 hr to fix
                    js/src/checkout-drop-in.js on lines 179..193

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

                    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

                                case 'Error':
                                    // Inform the shopper that there was an error processing their payment.
                    
                                    /*
                                     * You'll receive a `refusalReason` in the same response, indicating the cause of the error.
                    Severity: Major
                    Found in js/src/checkout-drop-in.js and 1 other location - About 1 hr to fix
                    js/dist/checkout-drop-in.js on lines 165..179

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

                    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 rest_api_adyen_notifications has 41 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        public function rest_api_adyen_notifications( WP_REST_Request $request ) {
                            $json = $request->get_body();
                    
                            $data = json_decode( $json );
                    
                    
                    Severity: Minor
                    Found in src/NotificationsController.php - About 1 hr to fix

                      Method payment_redirect has 40 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          public function payment_redirect( Payment $payment ) {
                              $sdk_version     = $payment->get_meta( 'adyen_sdk_version' );
                              $payment_session = $payment->get_meta( 'adyen_payment_session' );
                      
                              if ( empty( $sdk_version ) || empty( $payment_session ) ) {
                      Severity: Minor
                      Found in src/WebSdkGateway.php - About 1 hr to fix

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

                            public function __construct( $country, $street = null, $house_number_or_name = null, $postal_code = null, $city = null, $state_or_province = null ) {
                                /*
                                 * The two-character country code of the address.
                                 *
                                 * The permitted country codes are defined in ISO-3166-1 alpha-2 (e.g. 'NL').
                        Severity: Minor
                        Found in src/Address.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 paymentResult has 37 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                          var paymentResult = function paymentResult(response) {
                            switch (response.resultCode) {
                              case 'Authorised':
                                // The payment was successful.
                                dropin.setStatus('success', {
                        Severity: Minor
                        Found in js/dist/checkout-drop-in.js - About 1 hr to fix
                          Severity
                          Category
                          Status
                          Source
                          Language