kuasha/cosmos

View on GitHub
samples/adminpanel/app/bower_components/angular-ui-select/dist/select.js

Summary

Maintainability
F
6 days
Test Coverage

File select.js has 953 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/*!
 * ui-select
 * http://github.com/angular-ui/ui-select
 * Version: 0.9.1 - 2014-12-03T16:41:44.798Z
 * License: MIT

    Function link has 228 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

          link: function(scope, element, attrs, ctrls, transcludeFn) {
            var $select = ctrls[0];
            var ngModel = ctrls[1];
    
            var searchInput = element.querySelectorAll('input.ui-select-search');

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

          ctrl.parseRepeatAttr = function(repeatAttr, groupByExp) {
            function updateGroups(items) {
              ctrl.groups = [];
              angular.forEach(items, function(item) {
                var groupFn = $scope.$eval(groupByExp);

        Function select has 44 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            ctrl.select = function(item, skipFocusser, $event) {
              if (item === undefined || !item._uiSelectChoiceDisabled) {
        
                if ( ! ctrl.items && ! ctrl.search ) return;
        
        

          Function _handleMatchSelection has 42 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              function _handleMatchSelection(key){
                var caretPosition = _getCaretPosition(_searchInput[0]),
                    length = ctrl.selected.length,
                    // none  = -1,
                    first = 0,

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

                  compile: function(tElement, tAttrs) {
            
                    if (!tAttrs.repeat) throw uiSelectMinErr('repeat', "Expected 'repeat' expression.");
            
                    return function link(scope, element, attrs, $select, transcludeFn) {

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

                      return function link(scope, element, attrs, $select, transcludeFn) {
              
                        // var repeat = RepeatParser.parse(attrs.repeat);
                        var groupByExp = attrs.groupBy;
              
              

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

                    function _handleDropDownSelection(key) {
                      var processed = true;
                      switch (key) {
                        case KEY.DOWN:
                          if (!ctrl.open && ctrl.multiple) ctrl.activate(false, true); //In case its the search input in 'multiple' mode

                  Function getNewActiveMatchIndex has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                        function getNewActiveMatchIndex(){
                          switch(key){
                            case KEY.LEFT:
                              // Select previous/first item
                              if(~ctrl.activeMatchIndex) return prev;

                    Avoid deeply nested control flow statements.
                    Open

                                  if ( ctrl.activeIndex === 0 ) {
                                    // ctrl.tagging pushes items to ctrl.items, so we only have empty val
                                    // for `item` if it is a detected duplicate
                                    if ( item === undefined ) return;
                                    // create new item on the fly
                    Severity: Major
                    Found in samples/adminpanel/app/bower_components/angular-ui-select/dist/select.js - About 45 mins to fix

                      Avoid deeply nested control flow statements.
                      Open

                                      if ( ctrl.search.length > 0 ) {
                                        ctrl.select(null, true);
                                        _searchInput.triggerHandler('tagged');
                                      }
                      Severity: Major
                      Found in samples/adminpanel/app/bower_components/angular-ui-select/dist/select.js - About 45 mins to fix

                        Avoid deeply nested control flow statements.
                        Open

                                      if ( ctrl.activeIndex < 0 ) {
                                        item = ctrl.tagging.fct !== undefined ? ctrl.tagging.fct(ctrl.search) : ctrl.search;
                                        if ( angular.equals( ctrl.items[0], item ) ) {
                                          return;
                                        }
                        Severity: Major
                        Found in samples/adminpanel/app/bower_components/angular-ui-select/dist/select.js - About 45 mins to fix

                          Consider simplifying this complex logical expression.
                          Open

                                      if (e.which === KEY.TAB || KEY.isControl(e) || KEY.isFunctionKey(e) || e.which === KEY.ESC || e.which == KEY.ENTER || e.which === KEY.BACKSPACE) {
                                        return;
                                      }
                          Severity: Major
                          Found in samples/adminpanel/app/bower_components/angular-ui-select/dist/select.js - About 40 mins to fix

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

                                  link: function(scope, element, attrs, ctrls, transcludeFn) {
                            Severity: Minor
                            Found in samples/adminpanel/app/bower_components/angular-ui-select/dist/select.js - About 35 mins to fix

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

                                    link: function (scope, element, attrs, ctrl, transclude) {
                              Severity: Minor
                              Found in samples/adminpanel/app/bower_components/angular-ui-select/dist/select.js - About 35 mins to fix

                                Avoid too many return statements within this function.
                                Open

                                            return;
                                Severity: Major
                                Found in samples/adminpanel/app/bower_components/angular-ui-select/dist/select.js - About 30 mins to fix

                                  Avoid too many return statements within this function.
                                  Open

                                              else return false;
                                  Severity: Major
                                  Found in samples/adminpanel/app/bower_components/angular-ui-select/dist/select.js - About 30 mins to fix

                                    Avoid too many return statements within this function.
                                    Open

                                                return;
                                    Severity: Major
                                    Found in samples/adminpanel/app/bower_components/angular-ui-select/dist/select.js - About 30 mins to fix

                                      Avoid too many return statements within this function.
                                      Open

                                                    return curr;
                                      Severity: Major
                                      Found in samples/adminpanel/app/bower_components/angular-ui-select/dist/select.js - About 30 mins to fix

                                        Avoid too many return statements within this function.
                                        Open

                                                      return prev;
                                        Severity: Major
                                        Found in samples/adminpanel/app/bower_components/angular-ui-select/dist/select.js - About 30 mins to fix

                                          Avoid too many return statements within this function.
                                          Open

                                                      else return last;
                                          Severity: Major
                                          Found in samples/adminpanel/app/bower_components/angular-ui-select/dist/select.js - About 30 mins to fix

                                            Avoid too many return statements within this function.
                                            Open

                                                      return inputValue;
                                            Severity: Major
                                            Found in samples/adminpanel/app/bower_components/angular-ui-select/dist/select.js - About 30 mins to fix

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

                                                      if (e.which === KEY.TAB || KEY.isControl(e) || KEY.isFunctionKey(e) || e.which === KEY.ESC || KEY.isVerticalMovement(e.which) ) {
                                              samples/adminpanel/app/bower_components/angular-ui-select/dist/select.js on lines 983..983

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

                                              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 (e.which === KEY.TAB || KEY.isControl(e) || KEY.isFunctionKey(e) || e.which === KEY.ESC || e.which == KEY.ENTER || e.which === KEY.BACKSPACE) {
                                              samples/adminpanel/app/bower_components/angular-ui-select/dist/select.js on lines 658..658

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

                                              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 ( item !== undefined && items.length > 0 && tagItem ) {
                                                          hasTag = true;
                                                          items = items.slice(1,items.length);
                                                          stashArr = stashArr.slice(1,stashArr.length);
                                                        }
                                              samples/adminpanel/app/bower_components/angular-ui-select/dist/select.js on lines 682..686

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

                                              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 ( items.length > 0 && tagItem ) {
                                                          hasTag = true;
                                                          items = items.slice(1,items.length);
                                                          stashArr = stashArr.slice(1,stashArr.length);
                                                        }
                                              samples/adminpanel/app/bower_components/angular-ui-select/dist/select.js on lines 704..708

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

                                              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