BallStateCBER/datacenter-plugin-cakephp3

View on GitHub
webroot/js/tag_manager.js

Summary

Maintainability
F
3 days
Test Coverage

File tag_manager.js has 409 lines of code (exceeds 250 allowed). Consider refactoring.
Open

var TagManager = {
    /** A tree-shaped object provided to init() **/
    tags: [],

    /** A one-dimensional array populated by createTagList() */
Severity: Minor
Found in webroot/js/tag_manager.js - About 5 hrs to fix

    Function createTagTreeBranch has 66 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        createTagTreeBranch: function(data, container) {
            var list = $('<ul></ul>');
            for (var i = 0; i < data.length; i++) {
                var tagId = data[i].id;
                var tagName = data[i].name;
    Severity: Major
    Found in webroot/js/tag_manager.js - About 2 hrs to fix

      Function selectTag has 47 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          selectTag: function(tagId, tagName) {
              var selectedContainer = $('#selected_tags_container');
              if (! selectedContainer.is(':visible')) {
                  selectedContainer.slideDown(200);
              }
      Severity: Minor
      Found in webroot/js/tag_manager.js - About 1 hr to fix

        Function createTagTreeBranch has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
        Open

            createTagTreeBranch: function(data, container) {
                var list = $('<ul></ul>');
                for (var i = 0; i < data.length; i++) {
                    var tagId = data[i].id;
                    var tagName = data[i].name;
        Severity: Minor
        Found in webroot/js/tag_manager.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 unselectTag has 40 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            unselectTag: function(tagId, unselectLink) {
                var availableTagLinks = this.container.find('a[data-tag-id="' + tagId + '"]');
        
                // If available tag has not yet been loaded, then simply remove the selected tag
                if (availableTagLinks.length === 0) {
        Severity: Minor
        Found in webroot/js/tag_manager.js - About 1 hr to fix

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

              setupCustomTagInput: function(selector) {
                  if (! selector) {
                      selector = '#custom_tag_input';
                  }
                  $(selector).bind('keydown', function (event) {
          Severity: Minor
          Found in webroot/js/tag_manager.js - About 1 hr to fix

            Function init has 39 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                init: function (options) {
                    if (options.hasOwnProperty('container')) {
                        this.container = $(options.container);
                    } else {
                        this.container = $('#available_tags');
            Severity: Minor
            Found in webroot/js/tag_manager.js - About 1 hr to fix

              Function init has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
              Open

                  init: function (options) {
                      if (options.hasOwnProperty('container')) {
                          this.container = $(options.container);
                      } else {
                          this.container = $('#available_tags');
              Severity: Minor
              Found in webroot/js/tag_manager.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 setupAutosuggest has 34 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  setupAutosuggest: function(selector) {
                      $(selector).bind('keydown', function (event) {
                          if (event.keyCode === $.ui.keyCode.TAB && $(this).data('autocomplete').menu.active) {
                              event.preventDefault();
                          }
              Severity: Minor
              Found in webroot/js/tag_manager.js - About 1 hr to fix

                Function checkRequirements has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                Open

                    checkRequirements: function () {
                        var passes = true;
                        var msg = '';
                        if (! window.jQuery) {
                            this.showError('Error: The tag manager requires jQuery.');
                Severity: Minor
                Found in webroot/js/tag_manager.js - About 55 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 processTagList has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                    processTagList: function (data) {
                        for (var i = 0; i < data.length; i++) {
                            var tagId = data[i].id;
                            var tagName = data[i].name;
                            var children = data[i].children;
                Severity: Minor
                Found in webroot/js/tag_manager.js - About 25 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

                                (function(tagId) {
                                    tagLink.click(function (event) {
                                        event.preventDefault();
                                        var link = $(this);
                                        var tagName = link.html();
                Severity: Major
                Found in webroot/js/tag_manager.js and 1 other location - About 2 hrs to fix
                webroot/js/tag_manager.js on lines 218..226

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

                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

                            (function(tagId) {
                                tagLink.click(function (event) {
                                    event.preventDefault();
                                    var link = $(this);
                                    var tagName = link.html();
                Severity: Major
                Found in webroot/js/tag_manager.js and 1 other location - About 2 hrs to fix
                webroot/js/tag_manager.js on lines 142..150

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

                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 (event.keyCode === $.ui.keyCode.TAB && $(this).data('autocomplete').menu.active) {
                                event.preventDefault();
                            }
                Severity: Minor
                Found in webroot/js/tag_manager.js and 1 other location - About 35 mins to fix
                webroot/js/tag_manager.js on lines 408..410

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

                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 (event.keyCode === $.ui.keyCode.TAB && $(this).data('autocomplete').menu.active) {
                                event.preventDefault();
                            }
                Severity: Minor
                Found in webroot/js/tag_manager.js and 1 other location - About 35 mins to fix
                webroot/js/tag_manager.js on lines 452..454

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

                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