htdocs/assets/js/views/alerts/alerts.js

Summary

Maintainability
D
2 days
Test Coverage

File alerts.js has 428 lines of code (exceeds 250 allowed). Consider refactoring.
Open

"use strict";
define(function(require) {
    var $ = require('jquery'),
        _ = require('underscore'),
        View = require('view'),
Severity: Minor
Found in htdocs/assets/js/views/alerts/alerts.js - About 6 hrs to fix

    Function initializeCollectionData has 70 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

            initializeCollectionData: function(params) {
                var frag = document.createDocumentFragment();
                this.destroyViews();
    
                var data = {};
    Severity: Major
    Found in htdocs/assets/js/views/alerts/alerts.js - About 2 hrs to fix

      Function update has 35 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

              update: function() {
                  var query = Util.parseQuery(window.location.href);
      
                  var processResults = this.cbRendered(function(resp) {
                      this.collections = [];
      Severity: Minor
      Found in htdocs/assets/js/views/alerts/alerts.js - About 1 hr to fix

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

                _render: function() {
                    NavbarView.prototype._render.call(this);
        
                    var default_search = this.App.Data.User.get('settings')['default'];
                    var query = Util.parseQuery(window.location.href);
        Severity: Minor
        Found in htdocs/assets/js/views/alerts/alerts.js - About 1 hr to fix

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

                      var processResults = this.cbRendered(function(resp) {
                          this.collections = [];
          
                          for(var i = 0; i < resp.length; ++i) {
                              var c = resp[i].count;
          Severity: Minor
          Found in htdocs/assets/js/views/alerts/alerts.js - About 1 hr to fix

            Avoid deeply nested control flow statements.
            Open

                                        for(var m in searches) {
                                            // Active
                                            var states = searches[m];
                                            for(var n in states) {
                                                var collection = states[n];
            Severity: Major
            Found in htdocs/assets/js/views/alerts/alerts.js - About 45 mins to fix

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

                          if(query.from) {
                              var from_moment = Moment.utc(query.from, TIME_FMT);
                              if(from_moment.isValid()) {
                                  query.from = from_moment.unix();
                              }
              Severity: Major
              Found in htdocs/assets/js/views/alerts/alerts.js and 1 other location - About 2 hrs to fix
              htdocs/assets/js/views/alerts/alerts.js on lines 243..250

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

              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(query.to) {
                              var to_moment = Moment.utc(query.to, TIME_FMT);
                              if(to_moment.isValid()) {
                                  query.to = to_moment.unix();
                              }
              Severity: Major
              Found in htdocs/assets/js/views/alerts/alerts.js and 1 other location - About 2 hrs to fix
              htdocs/assets/js/views/alerts/alerts.js on lines 235..242

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

              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('assignee' in query) {
                              var assignee = Util.parseAssignee(query.assignee);
                              query.assignee_type = assignee[0];
                              query.assignee = assignee[1];
                          }
              Severity: Major
              Found in htdocs/assets/js/views/alerts/alerts.js and 1 other location - About 1 hr to fix
              htdocs/assets/js/views/searches/searches.js on lines 83..87

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

              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 4 locations. Consider refactoring.
              Open

                      initialize: function(options) {
                          this.title = options.title;
                          this.query = options.query;
                          this.groups = options.groups;
                      },
              Severity: Major
              Found in htdocs/assets/js/views/alerts/alerts.js and 3 other locations - About 1 hr to fix
              htdocs/assets/js/views/alerts/alert.js on lines 153..157
              htdocs/assets/js/views/alerts/alertgroup.js on lines 38..42
              htdocs/assets/js/views/alerts/alertgroup.js on lines 124..128

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

              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

                      buttons: [
                          {name: 'Clear', type: 'default', action: 'clear', persist: true, clear: true},
                          {name: 'Search', type: 'primary', icon: 'search', action: 'search'},
                      ],
              Severity: Major
              Found in htdocs/assets/js/views/alerts/alerts.js and 1 other location - About 1 hr to fix
              htdocs/assets/js/views/searches/searches.js on lines 41..44

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

              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

                          this.loadCollections([this.App.Data.Users, this.App.Data.Groups, this.App.Data.Searches]);
              Severity: Minor
              Found in htdocs/assets/js/views/alerts/alerts.js and 1 other location - About 50 mins to fix
              htdocs/assets/js/views/alerts/alertsfeed.js on lines 148..148

              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

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

                          if(!_.isUndefined(from)) {
                              this.$('.time-a input[name=from]').val(from);
                              params.from = from;
                          }
              Severity: Minor
              Found in htdocs/assets/js/views/alerts/alerts.js and 1 other location - About 35 mins to fix
              htdocs/assets/js/views/alerts/alerts.js on lines 223..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 47.

              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(!_.isUndefined(to)) {
                              this.$('.time-b input[name=to]').val(to);
                              params.to = to;
                          }
              Severity: Minor
              Found in htdocs/assets/js/views/alerts/alerts.js and 1 other location - About 35 mins to fix
              htdocs/assets/js/views/alerts/alerts.js on lines 219..222

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

              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 4 locations. Consider refactoring.
              Open

                          Util.initAssigneeSelect(
                              this.registerElement('input[name=assignee]'),
                              this.App.Data.Users, this.App.Data.Groups, true
                          );
              Severity: Major
              Found in htdocs/assets/js/views/alerts/alerts.js and 3 other locations - About 35 mins to fix
              htdocs/assets/js/views/alerts/actions.js on lines 153..155
              htdocs/assets/js/views/searches/search.js on lines 583..586
              htdocs/assets/js/views/searches/searches.js on lines 61..64

              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