naoufal/react-native-apple-pay

View on GitHub

Showing 35 of 71 total issues

File index.js has 636 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import { Platform } from 'react-native';
import { getShippingOptions } from '../services/shipping';

// helpers
function addStringAmounts(...prices) {
Severity: Major
Found in examples/common/handlers/index.js - About 1 day to fix

    Function render has 99 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      render() {
        return (
          <View
            style={{
              margin: 30,
    Severity: Major
    Found in examples/native/App.js - About 3 hrs to fix

      File index.js has 316 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      // @flow
      'use strict';
      
      // Types
      import type {
      Severity: Minor
      Found in js/PaymentRequest/index.js - About 3 hrs to fix

        File ReactNativePaymentsModule.java has 284 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        package com.reactnativepayments;
        
        import android.view.WindowManager;
        
        import android.app.Activity;

          Function staticShipping has 67 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          export function staticShipping() {
            let details = {
              id: 'staticShipping',
              displayItems: [
                {
          Severity: Major
          Found in examples/common/handlers/index.js - About 2 hrs to fix

            Method onActivityResult has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
            Open

                    @Override
                    public void onActivityResult(Activity activity, int requestCode, int resultCode, Intent data) {
                        // retrieve the error code, if available
                        int errorCode = -1;
                        if (data != null) {

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

                    @Override
                    public void onActivityResult(Activity activity, int requestCode, int resultCode, Intent data) {
                        // retrieve the error code, if available
                        int errorCode = -1;
                        if (data != null) {

              Function dynamicShipping has 43 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              export function dynamicShipping() {
                let details = {
                  id: 'dynamicShipping',
                  displayItems: [
                    {
              Severity: Minor
              Found in examples/common/handlers/index.js - About 1 hr to fix

                Function noInternationalShipping has 42 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                export function noInternationalShipping() {
                  let details = {
                    id: 'noInternationalShipping',
                    displayItems: [
                      {
                Severity: Minor
                Found in examples/common/handlers/index.js - About 1 hr to fix

                  Function constructor has 40 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    constructor(
                      methodData: Array<PaymentMethodData> = [],
                      details?: PaymentDetailsInit = [],
                      options?: PaymentOptions = {}
                    ) {
                  Severity: Minor
                  Found in js/PaymentRequest/index.js - About 1 hr to fix

                    Function errorInvalidShippingOptionsAmount has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    export function errorInvalidShippingOptionsAmount() {
                      let details = {
                        id: 'errorInvalidShippingOptionsAmount',
                        displayItems: [
                          {
                    Severity: Minor
                    Found in examples/common/handlers/index.js - About 1 hr to fix

                      Function _handleDetailsChange has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                        _handleDetailsChange(value: PaymentDetailsBase) {
                          const target = this.target;
                      
                          validateTotal(value.total, DOMException);
                          validateDisplayItems(value.displayItems, DOMException);
                      Severity: Minor
                      Found in js/PaymentRequest/PaymentRequestUpdateEvent.js - About 1 hr to fix

                        Function validateShippingOptions has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                        export function validateShippingOptions(details, errorType = Error): void {
                          if (details.shippingOptions === undefined) {
                            return undefined;
                          }
                        
                        
                        Severity: Minor
                        Found in js/PaymentRequest/helpers/index.js - About 1 hr to fix

                          Function render has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                          Open

                            render() {
                              return (
                                <View
                                  style={{
                                    margin: 30,
                          Severity: Minor
                          Found in examples/native/App.js - 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 errorDuplicateShippingOptionsId has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                          export function errorDuplicateShippingOptionsId() {
                            let details = {
                              id: 'errorDuplicateShippingOptionsId',
                              displayItems: [
                                {
                          Severity: Minor
                          Found in examples/common/handlers/index.js - About 1 hr to fix

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

                            function updateDetailsWithMutation(
                              paymentRequest,
                              details,
                              nextShippingOptions
                            ) {
                            Severity: Minor
                            Found in examples/common/handlers/index.js - About 1 hr to fix

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

                                _getPlatformDetailsIOS(details: PaymentDetailsIOSRaw): PaymentDetailsIOS {
                                  const {
                                    paymentData: serializedPaymentData,
                                    billingContact: serializedBillingContact,
                                    shippingContact: serializedShippingContact,
                              Severity: Minor
                              Found in js/PaymentRequest/index.js - About 1 hr to fix

                                Function twoItemsPlusTax has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                export function twoItemsPlusTax() {
                                  const displayItems = [
                                    {
                                      label: 'Movie Ticket',
                                      amount: { currency: 'USD', value: 15.0 }
                                Severity: Minor
                                Found in examples/common/handlers/index.js - About 1 hr to fix

                                  Function hasGatewayConfig has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                                  Open

                                  export function hasGatewayConfig(platformMethodData = {}) {
                                    if (!platformMethodData) {
                                      return false;
                                    }
                                  
                                  
                                  Severity: Minor
                                  Found in js/PaymentRequest/helpers/index.js - About 1 hr to fix

                                    Function updateWith has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                                    Open

                                      async updateWith(
                                        PaymentDetailsModifierOrPromise:
                                          | PaymentDetailsUpdate
                                          | ((
                                              PaymentDetailsModifier,
                                    Severity: Minor
                                    Found in js/PaymentRequest/PaymentRequestUpdateEvent.js - About 1 hr to fix
                                      Severity
                                      Category
                                      Status
                                      Source
                                      Language