ClusterLabs/hawk

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

Summary

Maintainability
D
2 days
Test Coverage

Function statusCircle has 58 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  $.fn.statusCircle = function(status, tooltip) {
    if (tooltip === undefined) {
      if (status == "ok") {
        tooltip = __("OK");
      } else if (status == "maintenance") {
Severity: Major
Found in hawk/app/assets/javascripts/module/basics.js - About 2 hrs to fix

    File basics.js has 256 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    // Copyright (c) 2009-2015 Tim Serong <tserong@suse.com>
    // See COPYING for license.
    
    $(function() {
      window.userIsNavigatingAway = false;
    Severity: Minor
    Found in hawk/app/assets/javascripts/module/basics.js - About 2 hrs to fix

      Function hawkAsyncConfirm has 42 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        $.hawkAsyncConfirm = function(message, on_ok) {
          if (!message) {
            message = _('Continue?');
          }
          var html = [
      Severity: Minor
      Found in hawk/app/assets/javascripts/module/basics.js - About 1 hr to fix

        Avoid too many return statements within this function.
        Open

                return '<i class="fa fa-refresh fa-pulse-opacity text"></i>';
        Severity: Major
        Found in hawk/app/assets/javascripts/module/basics.js - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

                  return '<i class="fa fa-question text"></i>';
          Severity: Major
          Found in hawk/app/assets/javascripts/module/basics.js - About 30 mins to fix

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

                  $.ajax({
                    dataType: 'json',
                    method: 'GET',
                    url: route,
                    success: function(data) {
            Severity: Major
            Found in hawk/app/assets/javascripts/module/basics.js and 1 other location - About 7 hrs to fix
            hawk/app/assets/javascripts/module/resources.js on lines 64..94

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

            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

                  } else {
                    $(this)
                      .addClass('collapsed')
                      .parents('fieldset')
                      .find('.content')
            Severity: Major
            Found in hawk/app/assets/javascripts/module/basics.js and 1 other location - About 1 hr to fix
            hawk/app/assets/javascripts/module/basics.js on lines 53..63

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

            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 ($(this).hasClass('collapsed')) {
                    $(this)
                      .removeClass('collapsed')
                      .parents('fieldset')
                      .find('.content')
            Severity: Major
            Found in hawk/app/assets/javascripts/module/basics.js and 1 other location - About 1 hr to fix
            hawk/app/assets/javascripts/module/basics.js on lines 63..73

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

            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

                  } else if (status == "errors") {
                    return '<i class="fa fa-exclamation-triangle text"></i>';
                  } else if (status == "maintenance") {
                    return '<i class="fa fa-wrench text"></i>';
                  } else if (status == "nostonith") {
            Severity: Major
            Found in hawk/app/assets/javascripts/module/basics.js and 1 other location - About 1 hr to fix
            hawk/app/assets/javascripts/module/status.js on lines 45..55

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

            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 statusClass = function() {
                  if (status == "ok") {
                    return "circle-success";
                  } else if (status == "errors") {
                    return "circle-danger";
            Severity: Major
            Found in hawk/app/assets/javascripts/module/basics.js and 1 other location - About 1 hr to fix
            hawk/app/assets/javascripts/module/status.js on lines 33..43

            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

            There are no issues that match your filters.

            Category
            Status