ClusterLabs/hawk

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

Summary

Maintainability
F
5 days
Test Coverage

File reports.js has 526 lines of code (exceeds 250 allowed). Consider refactoring.
Open

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

$(function() {
  var time_format_string = 'YYYY-MM-DD HH:mm:ss ZZ';
Severity: Major
Found in hawk/app/assets/javascripts/module/reports.js - About 1 day to fix

    Function build_tabs has 163 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      var build_tabs = function() {
        $('#reports #report-running').addClass('hidden');
        $('#reports #report-tabs').removeClass('hidden');
    
        var controls = $("#reports #report-controls");
    Severity: Major
    Found in hawk/app/assets/javascripts/module/reports.js - About 6 hrs to fix

      Function afterDisplay has 143 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        function afterDisplay(self) {
          var data = $('#reports #transition-data');
          var report = data.data('report');
          var transitions = $.parseJSON(data.text());
      
      
      Severity: Major
      Found in hawk/app/assets/javascripts/module/reports.js - About 5 hrs to fix

        Function click .delete has 39 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

                    'click .delete': function (e, value, row, index) {
                      e.preventDefault();
                      var $self = $(this);
        
                      $.hawkAsyncConfirm(i18n.translate('Are you sure you wish to delete %s?').fetch(row.name), function() {
        Severity: Minor
        Found in hawk/app/assets/javascripts/module/reports.js - About 1 hr to fix

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

                    formatter: function(value, row, index) {
                      var operations = []
          
                      operations.push([
                        '<a href="',
          Severity: Minor
          Found in hawk/app/assets/javascripts/module/reports.js - About 1 hr to fix

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

                    $.ajax({
                      url: target.data('url'),
                      success: function(data) {
                        if (data) {
                          if (!target.hasClass("loaded")) {
            Severity: Major
            Found in hawk/app/assets/javascripts/module/reports.js and 1 other location - About 6 hrs to fix
            hawk/app/assets/javascripts/module/reports.js on lines 541..563

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

            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

                  $.ajax({
                    url: target.data('url'),
                    success: function(data) {
                      if (data) {
                        if (!target.hasClass("loaded")) {
            Severity: Major
            Found in hawk/app/assets/javascripts/module/reports.js and 1 other location - About 6 hrs to fix
            hawk/app/assets/javascripts/module/reports.js on lines 500..521

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

            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 (data.error) {
                    $.growl({ message: data.error },{ type: 'danger' });
                  } else {
                    if (running_timeout !== null) {
                      clearInterval(running_timeout);
            Severity: Major
            Found in hawk/app/assets/javascripts/module/reports.js and 1 other location - About 2 hrs to fix
            hawk/app/assets/javascripts/module/reports.js on lines 24..34

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

            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 (state.running) {
                      // repeat...
                    } else {
                      if (running_timeout !== null) {
                        clearInterval(running_timeout);
            Severity: Major
            Found in hawk/app/assets/javascripts/module/reports.js and 1 other location - About 2 hrs to fix
            hawk/app/assets/javascripts/module/reports.js on lines 41..51

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

            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

                    $('#reports #middle .panel-heading .btn-primary').each(function(index, link) {
                      var $link = $(link)
            
                      $link.attr(
                        'href',
            Severity: Major
            Found in hawk/app/assets/javascripts/module/reports.js and 1 other location - About 1 hr to fix
            hawk/app/assets/javascripts/module/reports.js on lines 528..535

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

            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

                  $('#reports #middle .iterator a').each(function(index, link) {
                    var $link = $(link)
            
                    $link.attr(
                      'href',
            Severity: Major
            Found in hawk/app/assets/javascripts/module/reports.js and 1 other location - About 1 hr to fix
            hawk/app/assets/javascripts/module/reports.js on lines 487..494

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

            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