ClusterLabs/hawk

View on GitHub
hawk/app/assets/javascripts/module/nodes.js

Summary

Maintainability
F
1 wk
Test Coverage

File nodes.js has 371 lines of code (exceeds 250 allowed). Consider refactoring.
Open

// Copyright (c) 2009-2015 Tim Serong <tserong@suse.com>
// See COPYING for license.

$(function() {
  var rowStyleFn = function(row, index) {
Severity: Minor
Found in hawk/app/assets/javascripts/module/nodes.js - About 4 hrs to fix

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

              formatter: function(value, row, index) {
                var operations = [];
                var dropdowns = [];
    
                var add_operation = function(dest, path, path_class, icon_class, text) {
    Severity: Major
    Found in hawk/app/assets/javascripts/module/nodes.js - About 2 hrs to fix

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

                formatter: function(value, row, index) {
                  var cib = $('body').data('content');
                  var icon = ['fa', 'fa-lg'];
                  var title = row.state;
                  switch(row.state) {
      Severity: Minor
      Found in hawk/app/assets/javascripts/module/nodes.js - About 1 hr to fix

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

                  formatter: function(value, row, index) {
                    if (row.host) {
                      return "";
                    }
                    if (row.maintenance) {
        Severity: Minor
        Found in hawk/app/assets/javascripts/module/nodes.js - About 1 hr to fix

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

                    formatter: function(value, row, index) {
                      if (row.host) {
                        return "";
                      }
                      if (row.standby) {
          Severity: Minor
          Found in hawk/app/assets/javascripts/module/nodes.js - About 1 hr to fix

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

                        var add_operation = function(dest, path, path_class, icon_class, text) {
            Severity: Minor
            Found in hawk/app/assets/javascripts/module/nodes.js - About 35 mins to fix

              Avoid too many return statements within this function.
              Open

                    return { classes: ["warning"] };
              Severity: Major
              Found in hawk/app/assets/javascripts/module/nodes.js - About 30 mins to fix

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

                        }, {
                          field: 'maintenance',
                          title: __('Maintenance'),
                          sortable: false,
                          clickToSelect: false,
                Severity: Major
                Found in hawk/app/assets/javascripts/module/nodes.js and 1 other location - About 2 days to fix
                hawk/app/assets/javascripts/module/nodes.js on lines 157..211

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

                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

                        }, {
                          field: 'standby',
                          title: __('Standby'),
                          sortable: false,
                          clickToSelect: false,
                Severity: Major
                Found in hawk/app/assets/javascripts/module/nodes.js and 1 other location - About 2 days to fix
                hawk/app/assets/javascripts/module/nodes.js on lines 102..157

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

                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

                  $('#nodes #middle table.nodes, #cib #middle table.nodes, #configs #middle table.nodes').on("click", ".dropdown-toggle", function(event){
                    var button = $(this);
                    var open = button.attr('aria-expanded');
                    var dropdown = button.siblings('.dropdown-menu');
                    if (open) {
                Severity: Major
                Found in hawk/app/assets/javascripts/module/nodes.js and 1 other location - About 7 hrs to fix
                hawk/app/assets/javascripts/module/resources.js on lines 768..777

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

                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 add_operation = function(dest, path, path_class, icon_class, text) {
                              if (dest == "menu") {
                                dropdowns.push([
                                  '<li>',
                                    '<a href="', path, '" class="', path_class, ' ">',
                Severity: Major
                Found in hawk/app/assets/javascripts/module/nodes.js and 1 other location - About 3 hrs to fix
                hawk/app/assets/javascripts/module/resources.js on lines 338..355

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

                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

                      ajax: function(params) {
                        var cib = $('body').data('content');
                        params.success(cib.nodes, "success", {});
                        params.complete({}, "success");
                      },
                Severity: Major
                Found in hawk/app/assets/javascripts/module/nodes.js and 1 other location - About 1 hr to fix
                hawk/app/assets/javascripts/module/resources.js on lines 551..555

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

                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