ClusterLabs/hawk

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

Summary

Maintainability
F
5 days
Test Coverage

File statustable.js has 544 lines of code (exceeds 250 allowed). Consider refactoring.
Open

// Copyright (c) 2015-2016 Kristoffer Gronlund <kgronlund@suse.com>
// Copyright (c) 2016 Ayoub Belarbi <abelarbi@suse.com>
// See COPYING for license.

// This module is a table-based visualization for cluster status (Using JsRender). To use this module:
Severity: Major
Found in hawk/app/assets/javascripts/module/statustable.js - About 1 day to fix

    Function clusterRefresh has 84 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        clusterRefresh: function() {
            var that = this;
            that.ajaxQuery({
                url: that.baseUrl() + "/cib/live?format=json",
                type: "GET",
    Severity: Major
    Found in hawk/app/assets/javascripts/module/statustable.js - About 3 hrs to fix

      statusTable has 28 functions (exceeds 20 allowed). Consider refactoring.
      Open

      var statusTable = {
          tableData: [], // An Array that contains JSON data fetched from the cib, see cacheData()
          // List of options(passed to init function) and their types:
          // clusterId: string,
          // clusterType: string,
      Severity: Minor
      Found in hawk/app/assets/javascripts/module/statustable.js - About 3 hrs to fix

        Function clusterConnectionError has 73 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            clusterConnectionError: function(xhr, status, error, cb) {
                var that = this;
                if (window.userIsNavigatingAway)
                    return;
                var msg = "";
        Severity: Major
        Found in hawk/app/assets/javascripts/module/statustable.js - About 2 hrs to fix

          Function clusterConnectionError has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
          Open

              clusterConnectionError: function(xhr, status, error, cb) {
                  var that = this;
                  if (window.userIsNavigatingAway)
                      return;
                  var msg = "";
          Severity: Minor
          Found in hawk/app/assets/javascripts/module/statustable.js - 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

          Function basicCreateBody has 54 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              basicCreateBody: function() {
                  var s_hostname = __('Hostname');
                  var s_username = __('Username');
                  var s_password = __('Password');
                  var s_connect = __('Connect');
          Severity: Major
          Found in hawk/app/assets/javascripts/module/statustable.js - About 2 hrs to fix

            Function startRemoteConnect has 41 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                startRemoteConnect: function() {
                    var that = this;
                    this.updateClusterTab("refresh");
            
                    var username = that.username || "hacluster";
            Severity: Minor
            Found in hawk/app/assets/javascripts/module/statustable.js - About 1 hr to fix

              Function clusterRefresh has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
              Open

                  clusterRefresh: function() {
                      var that = this;
                      that.ajaxQuery({
                          url: that.baseUrl() + "/cib/live?format=json",
                          type: "GET",
              Severity: Minor
              Found in hawk/app/assets/javascripts/module/statustable.js - About 1 hr 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 success has 37 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                          success: function(data) {
                              $.each(data.nodes, function(node, node_values) {
                                  if (node_values.remote === false || node_values.host) {
                                      if ($.inArray(that.reconnections, node_values.uname) === -1) {
                                          that.reconnections.push(node_values.uname);
              Severity: Minor
              Found in hawk/app/assets/javascripts/module/statustable.js - About 1 hr to fix

                Function error has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                            error: function(xhr, status, error) {
                                // var tag_header = $('#inner-' + that.clusterId + " .panel-heading");
                                var tag_body = $('#inner-' + that.clusterId + " .panel-body");
                                if (that.host !== null && that.password === null) {
                                    // tag_header.html(that.basicCreateheader());
                Severity: Minor
                Found in hawk/app/assets/javascripts/module/statustable.js - About 1 hr to fix

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

                      displayClusterStatus: function() {
                  
                          var tag = this.inner_section.find("div.panel-body");
                  
                          if (this.tableData.meta.status == "maintenance" || this.tableData.meta.status == "nostonith") {
                  Severity: Minor
                  Found in hawk/app/assets/javascripts/module/statustable.js - About 1 hr to fix

                    Function startRemoteConnect has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                    Open

                        startRemoteConnect: function() {
                            var that = this;
                            this.updateClusterTab("refresh");
                    
                            var username = that.username || "hacluster";
                    Severity: Minor
                    Found in hawk/app/assets/javascripts/module/statustable.js - About 1 hr 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 gettext_translate has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        gettext_translate: function(type, options) {
                            typeof(options) === "undefined" ? options = {}: options;
                            var text = "";
                            switch (type) {
                                case 'error':
                    Severity: Minor
                    Found in hawk/app/assets/javascripts/module/statustable.js - About 1 hr to fix

                      Function updateClusterTab has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                      Open

                          updateClusterTab: function(state) {
                            var tab_id = "#" + this.clusterId + '-indicator';
                            if (state == "connected") {
                              if (this.tableData.meta.status == "ok") {
                                $(tab_id).attr({class: "tab-cluster-status status-success", title: "Status: Ok"}).html('');
                      Severity: Minor
                      Found in hawk/app/assets/javascripts/module/statustable.js - About 55 mins 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 displayClusterStatus has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                      Open

                          displayClusterStatus: function() {
                      
                              var tag = this.inner_section.find("div.panel-body");
                      
                              if (this.tableData.meta.status == "maintenance" || this.tableData.meta.status == "nostonith") {
                      Severity: Minor
                      Found in hawk/app/assets/javascripts/module/statustable.js - About 35 mins 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

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

                                      tag.find("button.btn").click(function() {
                                          var username = tag.find("input[name=username]").val();
                                          var password = tag.find("input[name=password]").val();
                                          tag.find('.btn-success').attr('disabled', true);
                                          tag.find('input').attr('disabled', true);
                      Severity: Major
                      Found in hawk/app/assets/javascripts/module/statustable.js and 1 other location - About 4 hrs to fix
                      hawk/app/assets/javascripts/module/statustable.js on lines 364..372

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

                      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

                                          btn.click(function() {
                                              var username = tag_body.find("input[name=username]").val();
                                              var password = tag_body.find("input[name=password]").val();
                                              tag_body.find('.btn-success').attr('disabled', true);
                                              tag_body.find('input').attr('disabled', true);
                      Severity: Major
                      Found in hawk/app/assets/javascripts/module/statustable.js and 1 other location - About 4 hrs to fix
                      hawk/app/assets/javascripts/module/statustable.js on lines 201..209

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

                      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 (json && json.errors) {
                                          var merged = [];
                                          merged = merged.concat.apply(merged, json.errors);
                                          msg += merged.join(", ");
                                      } else if (xhr.status >= 10000) {
                      Severity: Minor
                      Found in hawk/app/assets/javascripts/module/statustable.js and 1 other location - About 50 mins to fix
                      hawk/app/assets/javascripts/module/statustable.js on lines 139..143

                      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 (json && json.errors) {
                                          var merged = [];
                                          merged = merged.concat.apply(merged, json.errors);
                                          msg += merged.join(", ");
                                      }
                      Severity: Minor
                      Found in hawk/app/assets/javascripts/module/statustable.js and 1 other location - About 50 mins to fix
                      hawk/app/assets/javascripts/module/statustable.js on lines 146..156

                      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