partkeepr/PartKeepr

View on GitHub
src/PartKeepr/FrontendBundle/Resources/public/js/Components/Importer/Importer.js

Summary

Maintainability
F
5 days
Test Coverage

File Importer.js has 480 lines of code (exceeds 250 allowed). Consider refactoring.
Open

Ext.define("PartKeepr.Importer.Importer", {
    extend: "Ext.panel.Panel",
    layout: 'border',
    bbar: [
        {

    Function validateConfigNode has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring.
    Open

        validateConfigNode: function (node)
        {
            var configuration = node.data.data.configuration;
            var recurse = false;
    
    

    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 appendFieldData has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
    Open

        appendFieldData: function (field, node)
        {
            var fieldData = {};
            fieldData.data = node.get("data");
    
    

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

        validateConfigNode: function (node)
        {
            var configuration = node.data.data.configuration;
            var recurse = false;
    
    

      Function appendFieldData has 50 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          appendFieldData: function (field, node)
          {
              var fieldData = {};
              fieldData.data = node.get("data");
      
      

        Function onFieldChange has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
        Open

            onFieldChange: function (selectionModel, selected)
            {
                if (selected.length == 1) {
                    if (selected[0].data.data.type == "field") {
                        this.down("#configurationCards").setActiveItem(this.down("#importerFieldConfiguration"));

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

            executeImport: function ()
            {
                //@todo Implement warning dialog
        
                Ext.Ajax.request({

          Function initComponent has 31 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              initComponent: function ()
              {
                  this.callParent(arguments);
          
                  this.importConfiguration = {};

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

                reconfigureGrid: function (data)
                {
                    var columns = [];
                    var fieldConfig = [];
                    var header = data[0];

              Avoid deeply nested control flow statements.
              Open

                                              if (configuration.copyFromField === "") {
                                                  this.appendError(node, i18n(
                                                      "The field is configured to copy a value from the source file, but no source file field was configured"));
                                              }

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

                                if (!node.parentNode.data.data.configuration.fields.hasOwnProperty(node.data.text)) {
                                    node.parentNode.data.data.configuration.fields[node.data.text] = {};
                                }
                src/PartKeepr/FrontendBundle/Resources/public/js/Components/Importer/Importer.js on lines 367..369
                src/PartKeepr/FrontendBundle/Resources/public/js/Components/Importer/Importer.js on lines 383..385

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

                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

                                if (!node.parentNode.data.data.configuration.manytoone.hasOwnProperty(node.data.text)) {
                                    node.parentNode.data.data.configuration.manytoone[node.data.text] = {};
                                }
                src/PartKeepr/FrontendBundle/Resources/public/js/Components/Importer/Importer.js on lines 383..385
                src/PartKeepr/FrontendBundle/Resources/public/js/Components/Importer/Importer.js on lines 389..391

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

                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

                                if (!node.parentNode.data.data.configuration.onetomany.hasOwnProperty(node.data.text)) {
                                    node.parentNode.data.data.configuration.onetomany[node.data.text] = {};
                                }
                src/PartKeepr/FrontendBundle/Resources/public/js/Components/Importer/Importer.js on lines 367..369
                src/PartKeepr/FrontendBundle/Resources/public/js/Components/Importer/Importer.js on lines 389..391

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

                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 (selected[0].data.data.name === "") {
                                    this.down("#configurationCards").setActiveItem(this.down("#importerEntityConfiguration"));
                                    this.down("#importerEntityConfiguration").setModel(selected[0].data.data.reference);
                                } else {
                src/PartKeepr/FrontendBundle/Resources/public/js/Components/Importer/Importer.js on lines 320..323

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

                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

                                    } else {
                                        this.down("#configurationCards").setActiveItem(this.down("#importerManyToOneConfiguration"));
                                        this.down("#importerManyToOneConfiguration").setModel(selected[0].data.data.reference);
                                    }
                src/PartKeepr/FrontendBundle/Resources/public/js/Components/Importer/Importer.js on lines 314..317

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

                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

                        if (!node.parentNode.data.data.configuration.hasOwnProperty("fields")) {
                            node.parentNode.data.data.configuration.fields = {};
                        }
                src/PartKeepr/FrontendBundle/Resources/public/js/Components/Importer/Importer.js on lines 357..359
                src/PartKeepr/FrontendBundle/Resources/public/js/Components/Importer/Importer.js on lines 361..363

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

                        if (!node.parentNode.data.data.configuration.hasOwnProperty("manytoone")) {
                            node.parentNode.data.data.configuration.manytoone = {};
                        }
                src/PartKeepr/FrontendBundle/Resources/public/js/Components/Importer/Importer.js on lines 353..355
                src/PartKeepr/FrontendBundle/Resources/public/js/Components/Importer/Importer.js on lines 357..359

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

                        if (!node.parentNode.data.data.configuration.hasOwnProperty("onetomany")) {
                            node.parentNode.data.data.configuration.onetomany = {};
                        }
                src/PartKeepr/FrontendBundle/Resources/public/js/Components/Importer/Importer.js on lines 353..355
                src/PartKeepr/FrontendBundle/Resources/public/js/Components/Importer/Importer.js on lines 361..363

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

                    uploadCSVFile: function ()
                    {
                        var j = Ext.create("PartKeepr.FileUploadDialog");
                        j.on("fileUploaded", this.onFileUploaded, this);
                        j.show();
                src/PartKeepr/FrontendBundle/Resources/public/js/Components/Part/Editor/MetaPartEditor.js on lines 139..145
                src/PartKeepr/FrontendBundle/Resources/public/js/Components/Widgets/AttachmentGrid.js on lines 138..143

                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

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

                                fieldData.data.configuration = node.parentNode.data.data.configuration.onetomany[node.data.text];
                src/PartKeepr/FrontendBundle/Resources/public/js/Components/Importer/Importer.js on lines 370..370
                src/PartKeepr/FrontendBundle/Resources/public/js/Components/Importer/Importer.js on lines 392..392

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

                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

                                fieldData.data.configuration = node.parentNode.data.data.configuration.manytoone[node.data.text];
                src/PartKeepr/FrontendBundle/Resources/public/js/Components/Importer/Importer.js on lines 386..386
                src/PartKeepr/FrontendBundle/Resources/public/js/Components/Importer/Importer.js on lines 392..392

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

                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

                                fieldData.data.configuration = node.parentNode.data.data.configuration.fields[node.data.text];
                src/PartKeepr/FrontendBundle/Resources/public/js/Components/Importer/Importer.js on lines 370..370
                src/PartKeepr/FrontendBundle/Resources/public/js/Components/Importer/Importer.js on lines 386..386

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

                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