naoufal/react-native-apple-pay

View on GitHub

Showing 71 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

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

              <View style={{ marginVertical: 50 }}>
                <Text
                  style={{ color: this.state.style2 === 'white' ? 'red' : 'black' }}
                  onPress={() => this.setState({ style2: 'white' })}
                >
    Severity: Major
    Found in examples/native/App.js and 1 other location - About 1 day to fix
    examples/native/App.js on lines 83..104

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

    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

              <View style={{ marginVertical: 50 }}>
                <Text
                  style={{ color: this.state.style === 'white' ? 'red' : 'black' }}
                  onPress={() => this.setState({ style: 'white' })}
                >
    Severity: Major
    Found in examples/native/App.js and 1 other location - About 1 day to fix
    examples/native/App.js on lines 106..127

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

    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 3 locations. Consider refactoring.
    Open

    export function requestPayerName() {
      const details = {
        id: 'requestPayerName',
        displayItems: [
          {
    Severity: Major
    Found in examples/common/handlers/index.js and 2 other locations - About 4 hrs to fix
    examples/common/handlers/index.js on lines 186..204
    examples/common/handlers/index.js on lines 206..224

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

    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 3 locations. Consider refactoring.
    Open

    export function requestPayerPhone() {
      const details = {
        id: 'requestPayerPhone',
        displayItems: [
          {
    Severity: Major
    Found in examples/common/handlers/index.js and 2 other locations - About 4 hrs to fix
    examples/common/handlers/index.js on lines 166..184
    examples/common/handlers/index.js on lines 206..224

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

    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 3 locations. Consider refactoring.
    Open

    export function requestPayerEmail() {
      const details = {
        id: 'requestPayerEmail',
        displayItems: [
          {
    Severity: Major
    Found in examples/common/handlers/index.js and 2 other locations - About 4 hrs to fix
    examples/common/handlers/index.js on lines 166..184
    examples/common/handlers/index.js on lines 186..204

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

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

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

        let details = {
          id: 'noInternationalShipping',
          displayItems: [
            {
              label: 'Movie Ticket',
      Severity: Major
      Found in examples/common/handlers/index.js and 1 other location - About 3 hrs to fix
      examples/common/handlers/index.js on lines 351..368

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

      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

        let details = {
          id: 'dynamicShipping',
          displayItems: [
            {
              label: 'Movie Ticket',
      Severity: Major
      Found in examples/common/handlers/index.js and 1 other location - About 3 hrs to fix
      examples/common/handlers/index.js on lines 470..487

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

      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 3 locations. Consider refactoring.
      Open

      export function errorInvalidTotalAmount() {
        let details = {
          id: 'errorNoShippingOptions',
          displayItems: [
            {
      Severity: Major
      Found in examples/common/handlers/index.js and 2 other locations - About 3 hrs to fix
      examples/common/handlers/index.js on lines 538..555
      examples/common/handlers/index.js on lines 576..593

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

      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 3 locations. Consider refactoring.
      Open

      export function errorInvalidDisplayItemAmount() {
        let details = {
          id: 'errorNoShippingOptions',
          displayItems: [
            {
      Severity: Major
      Found in examples/common/handlers/index.js and 2 other locations - About 3 hrs to fix
      examples/common/handlers/index.js on lines 538..555
      examples/common/handlers/index.js on lines 557..574

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

      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 3 locations. Consider refactoring.
      Open

      export function errorNegativeTotal() {
        let details = {
          id: 'errorNegativeTotal',
          displayItems: [
            {
      Severity: Major
      Found in examples/common/handlers/index.js and 2 other locations - About 3 hrs to fix
      examples/common/handlers/index.js on lines 557..574
      examples/common/handlers/index.js on lines 576..593

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

      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

      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

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

          details.displayItems = details.displayItems.map(displayItem => {
            if (displayItem.label === 'Shipping') {
              return Object.assign({}, displayItem, {
                amount: {
                  currency: 'USD',
        Severity: Major
        Found in examples/common/handlers/index.js and 1 other location - About 3 hrs to fix
        examples/common/handlers/index.js on lines 302..315

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

        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

            details.displayItems = details.displayItems.map(displayItem => {
              if (displayItem.label === 'Shipping') {
                return Object.assign({}, displayItem, {
                  amount: {
                    currency: 'USD',
        Severity: Major
        Found in examples/common/handlers/index.js and 1 other location - About 3 hrs to fix
        examples/common/handlers/index.js on lines 423..436

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

        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

        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
                Severity
                Category
                Status
                Source
                Language