ryanmurakami/node-storenvy

View on GitHub
examples/clientTests.js

Summary

Maintainability
F
1 wk
Test Coverage

File clientTests.js has 340 lines of code (exceeds 250 allowed). Consider refactoring.
Open


function goodRes(obj) {
    return !obj.error && 
           obj.meta.code === 200 &&
           obj.data;
Severity: Minor
Found in examples/clientTests.js - About 4 hrs to fix

    tests has 22 functions (exceeds 20 allowed). Consider refactoring.
    Open

    var tests = {
        runAll: function(seClient) {
            tests.seClient = seClient;
            for (var func in tests) {
                if (func !== 'runAll' && typeof tests[func] === 'function') {
    Severity: Minor
    Found in examples/clientTests.js - About 2 hrs to fix

      Function updateProductTest has 30 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          updateProductTest: function(seClient) {
              var testName = 'the ultimatest beard shampoo',
                  testCents = '777',
                  testStatus = 'hidden',
                  updateCents = '666',
      Severity: Minor
      Found in examples/clientTests.js - About 1 hr to fix

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

            ordersTest: function(seClient) {
                seClient = seClient || tests.seClient;
                seClient.getOrders(function(err, data) { 
                    var obj = JSON.parse(data);
                    if (goodRes(obj) &&
        Severity: Major
        Found in examples/clientTests.js and 5 other locations - About 5 hrs to fix
        examples/clientTests.js on lines 148..162
        examples/clientTests.js on lines 231..245
        examples/clientTests.js on lines 263..277
        examples/clientTests.js on lines 299..313
        examples/clientTests.js on lines 348..362

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

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

            shippingClassesTest: function(seClient) {
                seClient = seClient || tests.seClient;
                seClient.getShippingClasses(function(err, data) { 
                    var obj = JSON.parse(data);
                    if (goodRes(obj) &&
        Severity: Major
        Found in examples/clientTests.js and 5 other locations - About 5 hrs to fix
        examples/clientTests.js on lines 97..111
        examples/clientTests.js on lines 148..162
        examples/clientTests.js on lines 231..245
        examples/clientTests.js on lines 263..277
        examples/clientTests.js on lines 348..362

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

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

            collectionsTest: function(seClient) {
                seClient = seClient || tests.seClient;
                seClient.getCollections(function(err, data) { 
                    var obj = JSON.parse(data);
                    if (goodRes(obj) &&
        Severity: Major
        Found in examples/clientTests.js and 5 other locations - About 5 hrs to fix
        examples/clientTests.js on lines 97..111
        examples/clientTests.js on lines 148..162
        examples/clientTests.js on lines 263..277
        examples/clientTests.js on lines 299..313
        examples/clientTests.js on lines 348..362

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

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

            productsTest: function(seClient) {
                seClient = seClient || tests.seClient;
                seClient.getProducts(function(err, data) { 
                    var obj = JSON.parse(data);
                    if (goodRes(obj) &&
        Severity: Major
        Found in examples/clientTests.js and 5 other locations - About 5 hrs to fix
        examples/clientTests.js on lines 97..111
        examples/clientTests.js on lines 231..245
        examples/clientTests.js on lines 263..277
        examples/clientTests.js on lines 299..313
        examples/clientTests.js on lines 348..362

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

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

            webhooksTest: function(seClient) {
                seClient = seClient || tests.seClient;
                seClient.getWebhooks(function(err, data) { 
                    var obj = JSON.parse(data);
                    if (goodRes(obj) &&
        Severity: Major
        Found in examples/clientTests.js and 5 other locations - About 5 hrs to fix
        examples/clientTests.js on lines 97..111
        examples/clientTests.js on lines 148..162
        examples/clientTests.js on lines 231..245
        examples/clientTests.js on lines 263..277
        examples/clientTests.js on lines 299..313

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

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

            shippingGroupsTest: function(seClient) {
                seClient = seClient || tests.seClient;
                seClient.getShippingGroups(function(err, data) { 
                    var obj = JSON.parse(data);
                    if (goodRes(obj) &&
        Severity: Major
        Found in examples/clientTests.js and 5 other locations - About 5 hrs to fix
        examples/clientTests.js on lines 97..111
        examples/clientTests.js on lines 148..162
        examples/clientTests.js on lines 231..245
        examples/clientTests.js on lines 299..313
        examples/clientTests.js on lines 348..362

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

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

            productTest: function(seClient, productId) {
                if (!productId) {
                    return;
                }
                seClient = seClient || tests.seClient;
        Severity: Major
        Found in examples/clientTests.js and 3 other locations - About 5 hrs to fix
        examples/clientTests.js on lines 247..261
        examples/clientTests.js on lines 315..329
        examples/clientTests.js on lines 364..378

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

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

            shippingClassTest: function(seClient, classId) {
                if (!classId) {
                    return;
                }
                seClient = seClient || tests.seClient;
        Severity: Major
        Found in examples/clientTests.js and 3 other locations - About 5 hrs to fix
        examples/clientTests.js on lines 164..178
        examples/clientTests.js on lines 247..261
        examples/clientTests.js on lines 364..378

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

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

            collectionTest: function(seClient, collectionId) {
                if (!collectionId) {
                    return;
                }
                seClient = seClient || tests.seClient;
        Severity: Major
        Found in examples/clientTests.js and 3 other locations - About 5 hrs to fix
        examples/clientTests.js on lines 164..178
        examples/clientTests.js on lines 315..329
        examples/clientTests.js on lines 364..378

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

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

            webhookTest: function(seClient, webhookId) {
                if (!webhookId) {
                    return;
                }
                seClient = seClient || tests.seClient;
        Severity: Major
        Found in examples/clientTests.js and 3 other locations - About 5 hrs to fix
        examples/clientTests.js on lines 164..178
        examples/clientTests.js on lines 247..261
        examples/clientTests.js on lines 315..329

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

        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

            storeTemplatesTest: function(seClient) {
                seClient = seClient || tests.seClient;
                seClient.getStoreTemplates(function(err, data) { 
                    var obj = JSON.parse(data);
                    if (goodRes(obj) &&
        Severity: Major
        Found in examples/clientTests.js and 2 other locations - About 4 hrs to fix
        examples/clientTests.js on lines 18..29
        examples/clientTests.js on lines 45..56

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

        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

            userTest: function(seClient) {
                seClient = seClient || tests.seClient;
                seClient.getUserInfo(function(err, data) { 
                    var obj = JSON.parse(data);
                    if (goodRes(obj) &&
        Severity: Major
        Found in examples/clientTests.js and 2 other locations - About 4 hrs to fix
        examples/clientTests.js on lines 45..56
        examples/clientTests.js on lines 58..69

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

        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

            storeVisitsTest: function(seClient) {
                seClient = seClient || tests.seClient;
                seClient.getStoreVisits(function(err, data) { 
                    var obj = JSON.parse(data);
                    if (goodRes(obj) &&
        Severity: Major
        Found in examples/clientTests.js and 2 other locations - About 4 hrs to fix
        examples/clientTests.js on lines 18..29
        examples/clientTests.js on lines 58..69

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

        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

                    if (goodRes(obj) &&
                        obj.data.id === groupId) {
                        console.log('Shipping Group Test passed.');
                    } else { 
                        console.log('Shipping Group Test failed with ' + JSON.stringify(obj));
        Severity: Major
        Found in examples/clientTests.js and 1 other location - About 1 hr to fix
        examples/clientTests.js on lines 120..125

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

        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

                    if (goodRes(obj) &&
                        obj.data.id === orderId) {
                        console.log('Order Test passed.');
                    } else { 
                        console.log('Order Test failed with ' + JSON.stringify(obj));
        Severity: Major
        Found in examples/clientTests.js and 1 other location - About 1 hr to fix
        examples/clientTests.js on lines 286..291

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

        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

                for (var func in tests) {
                    if (func !== 'runAll' && typeof tests[func] === 'function') {
                        tests[func]();
                    }
                }
        Severity: Minor
        Found in examples/clientTests.js and 1 other location - About 40 mins to fix
        examples/publicTests.js on lines 5..9

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

        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