htdocs/assets/js/util.js

Summary

Maintainability
F
5 days
Test Coverage

File util.js has 474 lines of code (exceeds 250 allowed). Consider refactoring.
Open

"use strict";
define(function(require) {
    var $ = require('jquery'),
        _ = require('underscore'),
        URI = require('uri'),
Severity: Minor
Found in htdocs/assets/js/util.js - About 7 hrs to fix

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

        var initAssigneeSelect = function(elems, users, groups, search, options) {
            options = options || {};
    
            var assignee_search = function(q) {
                var term = q.term.toLowerCase();
    Severity: Minor
    Found in htdocs/assets/js/util.js - About 1 hr to fix

      Function serializeForm has 38 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          var serializeForm = function(f, ignore_blank, ignore_checks) {
              var data = {};
              var inps = f.find(':input').filter(function() {
                  var hf = $(this).closest('.hidden-form');
                  if(hf.length === 0) return true;
      Severity: Minor
      Found in htdocs/assets/js/util.js - About 1 hr to fix

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

            var initUserSelect = function(elems, users, search, options) {
                options = options || {};
        
                var user_search = function(q) {
                    var term = q.term.toLowerCase();
        Severity: Minor
        Found in htdocs/assets/js/util.js - About 1 hr to fix

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

              function formatTime(mins) {
                  var weeks = 0;
                  var days = 0;
                  var hours = 0;
                  mins = parseInt(mins, 10);
          Severity: Minor
          Found in htdocs/assets/js/util.js - About 1 hr to fix

            Function initTimeSelect has 28 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                var initTimeSelect = function(elems, options) {
                    options = options || {};
            
                    var fmt = options.format || formatTime;
                    var intvs = [1, 5, 10, 15, 30, 60, 90, 120, 180, 360, 720, 1440, 2880, 4320, 10080, 20160];
            Severity: Minor
            Found in htdocs/assets/js/util.js - About 1 hr to fix

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

                  var initSearchSelect = function(elems, searches, search, options) {
                      options = options || {};
              
                      var search_search = function(q) {
                          var term = q.term.toLowerCase();
              Severity: Minor
              Found in htdocs/assets/js/util.js - About 1 hr to fix

                Function getAssigneeName has 6 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                    var getAssigneeName = function(assignee_type, assignee, users, groups, def_ret, prefix) {
                Severity: Minor
                Found in htdocs/assets/js/util.js - About 45 mins to fix

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

                      var initAssigneeSelect = function(elems, users, groups, search, options) {
                  Severity: Minor
                  Found in htdocs/assets/js/util.js - About 35 mins to fix

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

                        var initFilterSelect = function(elems, filters, options) {
                            options = options || {};
                    
                            var filter_search = function(q) {
                                var term = q.term.toLowerCase();
                    Severity: Major
                    Found in htdocs/assets/js/util.js and 1 other location - About 7 hrs to fix
                    htdocs/assets/js/util.js on lines 418..439

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

                    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 initTargetSelect = function(elems, targets, options) {
                            options = options || {};
                    
                            var target_search = function(q) {
                                var term = q.term.toLowerCase();
                    Severity: Major
                    Found in htdocs/assets/js/util.js and 1 other location - About 7 hrs to fix
                    htdocs/assets/js/util.js on lines 395..415

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

                    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

                                groups.each(function(model) {
                                    if(model.get('name').toString().toLowerCase().indexOf(term) !== -1) {
                                        results.push({id: '1,' + model.id, text: 'Group: ' + model.get('name')});
                                    }
                                });
                    Severity: Major
                    Found in htdocs/assets/js/util.js and 1 other location - About 3 hrs to fix
                    htdocs/assets/js/util.js on lines 347..351

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

                    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

                                users.each(function(model) {
                                    if(model.get('real_name').toString().toLowerCase().indexOf(term) !== -1) {
                                        results.push({id: '0,' + model.id, text: 'User: ' + model.get('real_name')});
                                    }
                                });
                    Severity: Major
                    Found in htdocs/assets/js/util.js and 1 other location - About 3 hrs to fix
                    htdocs/assets/js/util.js on lines 352..356

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

                    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 results = _.map(
                                    searches.filter(function(model) {
                                        return model.get('name').toString().toLowerCase().indexOf(term) !== -1;
                                    }),
                                    function(model) {
                    Severity: Major
                    Found in htdocs/assets/js/util.js and 1 other location - About 3 hrs to fix
                    htdocs/assets/js/util.js on lines 305..312

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

                    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

                                results = results.concat(_.map(
                                    users.filter(function(model) {
                                        return model.get('real_name').toString().toLowerCase().indexOf(term) !== -1;
                                    }),
                                    function(model) {
                    Severity: Major
                    Found in htdocs/assets/js/util.js and 1 other location - About 3 hrs to fix
                    htdocs/assets/js/util.js on lines 213..220

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

                    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