mangroveorg/datawinners

View on GitHub
datawinners/media/javascript/dropdown_check_list/dropdownchecklist.custom.js

Summary

Maintainability
F
6 days
Test Coverage

File dropdownchecklist.custom.js has 733 lines of code (exceeds 250 allowed). Consider refactoring.
Open

;(function($) {
    /*
     * ui.dropdownchecklist
     *
     * Copyright (c) 2008-2010 Adrian Tosca, Copyright (c) 2010-2011 Ittrium LLC

    Function _createDropItem has 100 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

            _createDropItem: function(index, tabIndex, value, code, data, number, text, optCss, checked, disabled, indent) {
                var self = this, options = this.options, sourceSelect = this.sourceSelect, controlWrapper = this.controlWrapper;
                var data = data || "";
                // the item contains a div that contains a checkbox input and a lable for the text
                // the div

      Function _toggleDropContainer has 86 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

              _toggleDropContainer: function( makeOpen ) {
                  var self = this;
                  // hides the last shown drop container
                  var hide = function(instance) {
                      if ((instance != null) && instance.dropWrapper.isOpen ){

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

                _appendControl: function() {
                    var self = this, sourceSelect = this.sourceSelect, options = this.options;
        
                    // the control is wrapped in a basic container
                    // inline-block at this level seems to give us better size control

          Function _syncSelected has 63 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                  _syncSelected: function(senderCheckbox) {
                      var self = this, options = this.options, sourceSelect = this.sourceSelect, dropWrapper = this.dropWrapper;
                      var selectOptions = sourceSelect.get(0).options;
                      var allCheckboxes = dropWrapper.find("input.active");
                      if (options.firstItemChecksAll == 'exclusive') {

            Function show has 51 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                        var show = function(instance) {
                            if ( !instance.dropWrapper.isOpen ) {
                                instance.dropWrapper.isOpen = true;
                                $.ui.dropdownchecklist.gLastOpened = instance;
            
            

              Function _createDropItem has 11 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                      _createDropItem: function(index, tabIndex, value, code, data, number, text, optCss, checked, disabled, indent) {

                Function _setSize has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                        _setSize: function(dropCalculatedSize) {
                            var options = this.options, dropWrapper = this.dropWrapper, controlWrapper = this.controlWrapper;
                
                            // use the width from config options if set, otherwise set the same width as the drop container
                            var controlWidth = dropCalculatedSize.width;

                  Function _init has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                          _init: function() {
                              var self = this, options = this.options;
                              if ( $.ui.dropdownchecklist.gIDCounter == null) {
                                  $.ui.dropdownchecklist.gIDCounter = 1;
                              }

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

                            _formatText: function(selectOptions, firstItemChecksAll, firstOption) {
                                var text;
                                if ( $.isFunction(this.options.textFormatFunction) ) {
                                    // let the callback do the formatting, but do not allow it to fail
                                    try {

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

                              refresh: function() {
                                  var self = this, sourceSelect = this.sourceSelect, dropWrapper = this.dropWrapper;
                      
                                  var allCheckBoxes = dropWrapper.find("input");
                                  var allGroups = dropWrapper.find(".ui-dropdownchecklist-group");

                        Avoid deeply nested control flow statements.
                        Open

                                                    if (!checked) { allChecked = false; }

                          Function _appendOption has 5 arguments (exceeds 4 allowed). Consider refactoring.
                          Open

                                  _appendOption: function(option, container, index, indent, forceDisabled) {

                            Function _appendOptions has 5 arguments (exceeds 4 allowed). Consider refactoring.
                            Open

                                    _appendOptions: function(parent, container, parentIndex, indent, forceDisabled) {

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

                                                  if ( anIcon.length > 0 ) {
                                                      anIcon.removeClass( (config.icon.toClose != null) ? config.icon.toClose : "ui-icon-triangle-1-s");
                                                      anIcon.addClass( (config.icon.toOpen != null) ? config.icon.toOpen : "ui-icon-triangle-1-e");
                                                  }
                              datawinners/media/javascript/dropdown_check_list/dropdownchecklist.custom.js on lines 759..762

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

                              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 ( anIcon.length > 0 ) {
                                                      anIcon.removeClass( (config.icon.toOpen != null) ? config.icon.toOpen : "ui-icon-triangle-1-e");
                                                      anIcon.addClass( (config.icon.toClose != null) ? config.icon.toClose : "ui-icon-triangle-1-s");
                                                  }
                              datawinners/media/javascript/dropdown_check_list/dropdownchecklist.custom.js on lines 689..692

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

                              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

                                                  allCheckboxes.each(function(index) {
                                                      if (index > 0) {
                                                          var checked = $(this).attr("checked");
                                                          if (!checked) { allChecked = false; }
                                                      } else {
                              datawinners/media/javascript/dropdown_check_list/dropdownchecklist.custom.js on lines 545..552

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

                              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

                                                  allCheckboxes.each(function(index) {
                                                      if (index > 0) {
                                                          var checked = $(this).attr("checked");
                                                          if (!checked) { allChecked = false; }
                                                      } else {
                              datawinners/media/javascript/dropdown_check_list/dropdownchecklist.custom.js on lines 572..579

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

                              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 {
                                              item.attr("disabled",false);
                                              item.removeClass("inactive");
                                              item.addClass("active");
                                              aParent.removeClass("ui-state-disabled");
                              datawinners/media/javascript/dropdown_check_list/dropdownchecklist.custom.js on lines 896..901

                              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

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

                                          if ( disabled ) {
                                              item.attr("disabled",true);
                                              item.removeClass("active");
                                              item.addClass("inactive");
                                              aParent.addClass("ui-state-disabled");
                              datawinners/media/javascript/dropdown_check_list/dropdownchecklist.custom.js on lines 901..906

                              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

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

                                          var ids =  $.map(dropWrapper.find(':checkbox:checked'), function(checkbox){
                                              return $(checkbox).attr('id');
                                          });
                              datawinners/media/javascript/dropdown_check_list/dropdownchecklist.custom.js on lines 235..237

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

                              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

                                          var data = $.map(dropWrapper.find(':checkbox:checked'), function(checkbox){
                                              return $(checkbox).attr('data');
                                          });
                              datawinners/media/javascript/dropdown_check_list/dropdownchecklist.custom.js on lines 232..234

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

                              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

                                      _refreshGroup: function(group,disabled) {
                                          if ( disabled ) {
                                              group.addClass("ui-state-disabled");
                                          } else {
                                              group.removeClass("ui-state-disabled");
                              datawinners/media/javascript/home/dashboard.js on lines 23..29

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

                              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