RacoonsGroup/ttng

View on GitHub

Showing 61 of 61 total issues

File selectize.js has 2258 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/**
 * sifter.js
 * Copyright (c) 2013 Brian Reavis & contributors
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
Severity: Major
Found in app/assets/javascripts/libs/selectize.js - About 6 days to fix

    Function setup has 132 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

            setup: function() {
                var self      = this;
                var settings  = self.settings;
                var eventNS   = self.eventNS;
                var $window   = $(window);
    Severity: Major
    Found in app/assets/javascripts/libs/selectize.js - About 5 hrs to fix

      Function selectize has 105 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          $.fn.selectize = function(settings_user) {
              var defaults             = $.fn.selectize.defaults;
              var settings             = $.extend({}, defaults, settings_user);
              var attr_data            = settings.dataAttr;
              var field_label          = settings.labelField;
      Severity: Major
      Found in app/assets/javascripts/libs/selectize.js - About 4 hrs to fix

        Method initialize has 104 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def initialize(user)
            user ||= User.new
        
            if user.chief?
              can :manage, :all
        Severity: Major
        Found in app/models/ability.rb - About 4 hrs to fix

          Function refreshOptions has 94 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                  refreshOptions: function(triggerDropdown) {
                      var i, j, k, n, groups, groups_order, option, option_html, optgroup, optgroups, html, html_children, has_create_option;
                      var $active, $active_before, $create;
              
                      if (typeof triggerDropdown === 'undefined') {
          Severity: Major
          Found in app/assets/javascripts/libs/selectize.js - About 3 hrs to fix

            Method build_server_tree has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
            Open

              def build_server_tree(tree, options= {})
                result = ''
                tree   = Array.wrap tree
                opts   = {
                  # node and base node params
            Severity: Minor
            Found in app/helpers/the_sortable_tree_helper.rb - About 3 hrs 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 onKeyDown has 70 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                    onKeyDown: function(e) {
                        var isInput = e.target === this.$control_input[0];
                        var self = this;
                
                        if (self.isLocked) {
            Severity: Major
            Found in app/assets/javascripts/libs/selectize.js - About 2 hrs to fix

              Function getSortFunction has 65 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  Sifter.prototype.getSortFunction = function(search, options) {
                      var i, n, self, field, fields, fields_count, multiplier, multipliers, get_field, implicit_score, sort;
              
                      self   = this;
                      search = self.prepareSearch(search, options);
              Severity: Major
              Found in app/assets/javascripts/libs/selectize.js - About 2 hrs to fix

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

                (function(root, factory) {
                    if (typeof define === 'function' && define.amd) {
                        define('sifter', factory);
                    } else if (typeof exports === 'object') {
                        module.exports = factory();
                Severity: Major
                Found in app/assets/javascripts/libs/selectize.js and 1 other location - About 2 hrs to fix
                app/assets/javascripts/libs/selectize.js on lines 467..585

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

                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(root, factory) {
                    if (typeof define === 'function' && define.amd) {
                        define('microplugin', factory);
                    } else if (typeof exports === 'object') {
                        module.exports = factory();
                Severity: Major
                Found in app/assets/javascripts/libs/selectize.js and 1 other location - About 2 hrs to fix
                app/assets/javascripts/libs/selectize.js on lines 17..447

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

                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

                Function init_select has 61 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                        var init_select = function($input, settings_element) {
                            var i, n, tagName, $children, order = 0;
                            var options = settings_element.options;
                    
                            var readData = function($el) {
                Severity: Major
                Found in app/assets/javascripts/libs/selectize.js - About 2 hrs to fix

                  Function mixin has 60 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      MicroPlugin.mixin = function(Interface) {
                          Interface.plugins = {};
                  
                          /**
                           * Initializes the listed plugins (with options).
                  Severity: Major
                  Found in app/assets/javascripts/libs/selectize.js - About 2 hrs to fix

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

                            self.lock = (function() {
                                var original = self.lock;
                                return function() {
                                    var sortable = self.$control.data('sortable');
                                    if (sortable) sortable.disable();
                    Severity: Major
                    Found in app/assets/javascripts/libs/selectize.js and 1 other location - About 2 hrs to fix
                    app/assets/javascripts/libs/selectize.js on lines 3255..3262

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

                    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

                            self.unlock = (function() {
                                var original = self.unlock;
                                return function() {
                                    var sortable = self.$control.data('sortable');
                                    if (sortable) sortable.enable();
                    Severity: Major
                    Found in app/assets/javascripts/libs/selectize.js and 1 other location - About 2 hrs to fix
                    app/assets/javascripts/libs/selectize.js on lines 3246..3253

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

                    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

                    Function getScoreFunction has 59 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        Sifter.prototype.getScoreFunction = function(search, options) {
                            var self, fields, tokens, token_count;
                    
                            self        = this;
                            search      = self.prepareSearch(search, options);
                    Severity: Major
                    Found in app/assets/javascripts/libs/selectize.js - About 2 hrs to fix

                      Function Selectize has 55 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          var Selectize = function($input, settings) {
                              var key, i, n, dir, input, self = this;
                              input = $input[0];
                              input.selectize = self;
                          
                      Severity: Major
                      Found in app/assets/javascripts/libs/selectize.js - About 2 hrs to fix

                        Method main_navigation has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
                        Open

                          def main_navigation
                            render_navigation renderer: :bootstrap do |primary|
                              primary.dom_class = 'nav navbar-nav'
                              primary.selected_class = 'active'
                        
                        
                        Severity: Minor
                        Found in app/helpers/navigation_helper.rb - About 2 hrs 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

                        Method admin_navigation has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
                        Open

                          def admin_navigation
                            render_navigation renderer: :bootstrap do |primary|
                              primary.dom_class = 'nav navbar-nav'
                              primary.selected_class = 'active'
                              primary.item :key_1_1, t('navigation.home'), root_path, class: 'item', icon: 'home'
                        Severity: Minor
                        Found in app/helpers/navigation_helper.rb - About 2 hrs 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

                        Method build_server_tree has 49 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                          def build_server_tree(tree, options= {})
                            result = ''
                            tree   = Array.wrap tree
                            opts   = {
                              # node and base node params
                        Severity: Minor
                        Found in app/helpers/the_sortable_tree_helper.rb - About 1 hr to fix

                          Function setActiveItem has 48 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                                  setActiveItem: function($item, e) {
                                      var self = this;
                                      var eventName;
                                      var i, idx, begin, end, item, swap;
                                      var $last;
                          Severity: Minor
                          Found in app/assets/javascripts/libs/selectize.js - About 1 hr to fix
                            Severity
                            Category
                            Status
                            Source
                            Language