wp-pay-gateways/adyen

View on GitHub

Showing 97 of 97 total issues

Function paymentResult has 36 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    const paymentResult = response => {
        switch ( response.resultCode ) {
            case 'Authorised':
                // The payment was successful.
                dropin.setStatus( 'success', { message: pronamicPayAdyenCheckout.paymentAuthorised } );
Severity: Minor
Found in js/src/checkout-drop-in.js - About 1 hr to fix

    Method field_private_key has 34 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function field_private_key( $field ) {
            if ( ! \array_key_exists( 'meta_key', $field ) ) {
                return;
            }
    
    
    Severity: Minor
    Found in src/Integration.php - About 1 hr to fix

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

          const handle_error = error => {
              // Check syntax error name.
              if ( 'SyntaxError' === error.name ) {
                  error.message = pronamicPayAdyenCheckout.syntaxError;
              }
      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 65..75

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

      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

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

        var handle_error = function handle_error(error) {
          // Check syntax error name.
          if ('SyntaxError' === error.name) {
            error.message = pronamicPayAdyenCheckout.syntaxError;
          } // Show error message.
      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 63..71

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

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

          public static function from_object( $object ) {
              $validator = new Validator();
      
              $validator->validate(
                  $object,
      Severity: Minor
      Found in src/PaymentResponse.php - About 1 hr to fix

        Method send_request has 32 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            private function send_request( $method, $request ) {
                // Request.
                $url = $this->config->get_api_url( $method );
        
                $response = Http::request(
        Severity: Minor
        Found in src/Client.php - About 1 hr to fix

          Method get_issuers has 32 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function get_issuers() {
                  $issuers = array();
          
                  $payment_methods_response = $this->client->get_payment_methods( new PaymentMethodsRequest( $this->config->get_merchant_account() ) );
          
          
          Severity: Minor
          Found in src/AbstractGateway.php - About 1 hr to fix

            Method from_object has 32 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public static function from_object( $object ) {
                    $validator = new \JsonSchema\Validator();
            
                    $validator->validate(
                        $object,
            Severity: Minor
            Found in src/ActionInformation.php - About 1 hr to fix

              Method create_payment has 30 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public function create_payment( Payment $payment, PaymentMethod $payment_method, $data = null ) {
                      $amount = AmountTransformer::transform( $payment->get_total_amount() );
              
                      // Payment request.
                      $payment_request = new PaymentRequest(
              Severity: Minor
              Found in src/DropInGateway.php - About 1 hr to fix

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

                    public function get_json() {
                        $properties = array(
                            'enhancedSchemeData.customerReference'      => $this->esd_customer_reference,
                            'enhancedSchemeData.destinationCountryCode' => $this->esd_destination_country_code,
                            'enhancedSchemeData.destinationPostalCode'  => $this->esd_destination_postal_code,
                Severity: Minor
                Found in src/AdditionalData.php - About 1 hr to fix

                  Function getPaymentMethodsConfiguration has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      const getPaymentMethodsConfiguration = () => {
                          /**
                           * Complement Apple Pay configuration with `onValidateMerchant`
                           * callback when using your own Apple Pay certificate.
                           * 
                  Severity: Minor
                  Found in js/src/checkout-drop-in.js - About 1 hr to fix

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

                        public static function from_object( $object ) {
                            $browser_information = new self();
                    
                            // phpcs:disable WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase -- Adyen JSON object.
                    
                    
                    Severity: Minor
                    Found in src/BrowserInformation.php - About 1 hr to fix

                      Method get_json has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          public function get_json() {
                              $metadata = $this->get_metadata();
                      
                              $properties = Util::filter_null(
                                  array(
                      Severity: Minor
                      Found in src/AbstractPaymentRequest.php - About 1 hr to fix

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

                                onSubmit: ( state ) => {
                                    // Set loading status to prevent duplicate submits.
                                    dropin.setStatus( 'loading' );
                        
                                    send_request(
                        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 135..139

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

                        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

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

                            onSubmit: function onSubmit(state) {
                              // Set loading status to prevent duplicate submits.
                              dropin.setStatus('loading');
                              send_request(pronamicPayAdyenCheckout.paymentsUrl, state.data).then(validate_response).then(process_response).catch(handle_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 137..148

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

                        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

                        Function update_payment has a Cognitive Complexity of 10 (exceeds 5 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

                        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_notifications has a Cognitive Complexity of 10 (exceeds 5 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

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

                            public function rest_api_init() {
                                register_rest_route(
                                    Integration::REST_ROUTE_NAMESPACE,
                                    '/payments/result/(?P<config_id>\d+)',
                                    array(
                        Severity: Minor
                        Found in src/PaymentsResultController.php - About 1 hr to fix

                          Method admin_init has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              public function admin_init() {
                                  add_settings_section(
                                      'pronamic_pay_adyen_notification_authentication',
                                      /* translators: Translate 'notification' the same as in the Adyen dashboard. */
                                      _x( 'Adyen Notification Authentication', 'Adyen', 'pronamic_ideal' ),
                          Severity: Minor
                          Found in src/Integration.php - About 1 hr to fix

                            Method transform has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                                public static function transform( Pay_Address $address ) {
                                    $country = $address->get_country();
                            
                                    if ( null === $country ) {
                                        return null;
                            Severity: Minor
                            Found in src/AddressTransformer.php - About 1 hr to fix
                              Severity
                              Category
                              Status
                              Source
                              Language