catarse/catarse.js

View on GitHub
legacy/src/vms/common-payment-vm.js

Summary

Maintainability
F
3 days
Test Coverage

File common-payment-vm.js has 340 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import m from 'mithril';
import prop from 'mithril/stream';
import _ from 'underscore';
import projectVM from '../vms/project-vm';
import addressVM from '../vms/address-vm';
Severity: Minor
Found in legacy/src/vms/common-payment-vm.js - About 4 hrs to fix

    Function sendCreditCardPayment has 77 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    const sendCreditCardPayment = (selectedCreditCard, fields, commonData, addVM) => {
    
        if (!fields) {
            return false;
        }
    Severity: Major
    Found in legacy/src/vms/common-payment-vm.js - About 3 hrs to fix

      Function sendSlipPayment has 56 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      const sendSlipPayment = (fields, commonData) => {
          fields.isLoading(true);
          m.redraw();
      
          const customer = fields.fields;
      Severity: Major
      Found in legacy/src/vms/common-payment-vm.js - About 2 hrs to fix

        Function trialsToGetPaymentInfo has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

        const trialsToGetPaymentInfo = (p, catalog_payment_id, retries) => {
            if (retries > 0) {
                paymentInfo(catalog_payment_id).then((infoR) => {
                    if (_.isNull(infoR.gateway_payment_method) || _.isUndefined(infoR.gateway_payment_method)) {
                        if (!_.isNull(infoR.gateway_errors)) {
        Severity: Minor
        Found in legacy/src/vms/common-payment-vm.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 sendSlipPayment has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

        const sendSlipPayment = (fields, commonData) => {
            fields.isLoading(true);
            m.redraw();
        
            const customer = fields.fields;
        Severity: Minor
        Found in legacy/src/vms/common-payment-vm.js - About 45 mins 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 kondutoExecute has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

        const kondutoExecute = function () {
            const customerID = h.getUserCommonID();
        
            if (customerID) {
                var period = 300;
        Severity: Minor
        Found in legacy/src/vms/common-payment-vm.js - About 45 mins 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 requestInfo has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

        const requestInfo = (promise, paymentId, defaultPaymentMethod, isEdit) => {
            if (retries <= 0) {
                return promise.resolve(resolvePayment(defaultPaymentMethod, false, paymentId, isEdit));
            }
        
        
        Severity: Minor
        Found in legacy/src/vms/common-payment-vm.js - About 45 mins 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 getPaymentInfoUntilNoError has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

        const getPaymentInfoUntilNoError = (paymentMethod, isEdit) => ({ id, catalog_payment_id }) => {
            const p = new Promise((resolve, reject) => {
                const paymentId = isEdit ? catalog_payment_id : id;
        
                if (paymentId) {
        Severity: Minor
        Found in legacy/src/vms/common-payment-vm.js - About 35 mins 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

        const kondutoExecute = function () {
            const customerID = h.getUserCommonID();
        
            if (customerID) {
                var period = 300;
        Severity: Major
        Found in legacy/src/vms/common-payment-vm.js and 1 other location - About 6 hrs to fix
        legacy/src/vms/payment-vm.js on lines 248..266

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

        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

        const sendSubscriptionUpgrade = data => commonSubscriptionUpgrade.postWithToken(
            { data },
            null,
            (h.isDevEnv() ? { 'X-forwarded-For': '127.0.0.1' } : {})
        )
        Severity: Major
        Found in legacy/src/vms/common-payment-vm.js and 1 other location - About 2 hrs to fix
        legacy/src/vms/common-payment-vm.js on lines 78..83

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

        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

        const paymentInfo = paymentId => commonPaymentInfo
            .postWithToken({ id: paymentId }, null, (h.isDevEnv() ? { 'X-forwarded-For': '127.0.0.1' } : {}))
            .catch((error) => {
                h.captureException(error);
                throw error;
        Severity: Major
        Found in legacy/src/vms/common-payment-vm.js and 1 other location - About 2 hrs to fix
        legacy/src/vms/common-payment-vm.js on lines 22..30

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

        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

                            if (commonData.subscription_id) {
                                sendSubscriptionUpgrade(payload).then(resolve).catch(reject);
                            } else {
                                sendPaymentRequest(payload).then(resolve).catch(reject);
                            }
        Severity: Major
        Found in legacy/src/vms/common-payment-vm.js and 1 other location - About 1 hr to fix
        legacy/src/vms/common-payment-vm.js on lines 334..338

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

        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

                    if (commonData.subscription_id) {
                        sendSubscriptionUpgrade(payload).then(resolve).catch(reject);
                    } else {
                        sendPaymentRequest(payload).then(resolve).catch(reject);
                    }
        Severity: Major
        Found in legacy/src/vms/common-payment-vm.js and 1 other location - About 1 hr to fix
        legacy/src/vms/common-payment-vm.js on lines 265..269

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

        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

        const updateUser = user => m.request({
            method: 'PUT',
            url: `/users/${user.id}.json`,
            data: {
                user
        Severity: Major
        Found in legacy/src/vms/common-payment-vm.js and 1 other location - About 1 hr to fix
        legacy/src/c/user-about-edit.js on lines 118..131

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

        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

            window.pagarme.client.connect({ encryption_key: encryptionKey })
                .then(client => client.security.encrypt(card))
                .then((cardHash) => {
                    const payload = {
                        subscription: true,
        Severity: Minor
        Found in legacy/src/vms/common-payment-vm.js and 1 other location - About 50 mins to fix
        legacy/src/vms/payment-vm.js on lines 299..311

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

        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

        There are no issues that match your filters.

        Category
        Status