ClusterLabs/hawk

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

Summary

Maintainability
F
4 days
Test Coverage

File primitives.js has 390 lines of code (exceeds 250 allowed). Consider refactoring.
Open

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

$(function() {
  // Some craziness to avoid duplicating this stuff for both
Severity: Minor
Found in hawk/app/assets/javascripts/module/primitives.js - About 5 hrs to fix

    Function render_attrlists has 130 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        var render_attrlists = function($template, $clazz, $provider, $type) {
          var new_resource = $('form#new_primitive, form#new_template').length > 0;
          var agent = null;
          if ($template.length > 0 && $template.val() != "") {
            agent = "@" + $template.val();
    Severity: Major
    Found in hawk/app/assets/javascripts/module/primitives.js - About 5 hrs to fix

      Function success has 91 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

                success: function(data) {
                  if (data == null || !("resource_agent" in data)) {
                    data = { resource_agent: {
                      shortdesc: agent,
                      longdesc: "",
      Severity: Major
      Found in hawk/app/assets/javascripts/module/primitives.js - About 3 hrs to fix

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

                    'click .delete': function (e, value, row, index) {
                      e.preventDefault();
                      var $self = $(this);
                      var answer = null;
        
        
        Severity: Minor
        Found in hawk/app/assets/javascripts/module/primitives.js - About 1 hr to fix

          Function formatter has 30 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/primitives.js - About 1 hr to fix

            Avoid deeply nested control flow statements.
            Open

                                if ($.type(root[lstname][elemname]) == "object") {
                                  return [root[lstname][elemname]];
                                } else {
                                  return root[lstname][elemname];
                                }
            Severity: Major
            Found in hawk/app/assets/javascripts/module/primitives.js - About 45 mins to fix

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

                  $(controller_type.sel_readonly).each(function() {
                    var $form = $(controller_type.form_selector);
                    var $template = $form.find(controller_type.template_selector);
                    var $clazz = $form.find(controller_type.clazz_selector);
                    var $provider = $form.find(controller_type.provider_selector);
              Severity: Major
              Found in hawk/app/assets/javascripts/module/primitives.js and 1 other location - About 3 hrs to fix
              hawk/app/assets/javascripts/module/primitives.js on lines 423..432

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

              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

                    .on('change', controller_type.selects, function(e) {
                      var $form = $(e.delegateTarget);
              
                      var $template = $form.find(controller_type.template_selector);
                      var $clazz = $form.find(controller_type.clazz_selector);
              Severity: Major
              Found in hawk/app/assets/javascripts/module/primitives.js and 1 other location - About 3 hrs to fix
              hawk/app/assets/javascripts/module/primitives.js on lines 437..444

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

              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 ($type.find('[data-clazz="' + $clazz.val() + '"][data-provider="' + $provider.val() + '"][value="' + $type.val() + '"]').length == 0) {
                        $type.val('');
                      }
              Severity: Major
              Found in hawk/app/assets/javascripts/module/primitives.js and 1 other location - About 2 hrs to fix
              hawk/app/assets/javascripts/module/primitives.js on lines 396..398

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

              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 ($type.find('[data-clazz="' + $clazz.val() + '"][data-provider="' + $provider.val() + '"][value="' + $type.val() + '"]').length == 0) {
                        $type.val('');
                      }
              Severity: Major
              Found in hawk/app/assets/javascripts/module/primitives.js and 1 other location - About 2 hrs to fix
              hawk/app/assets/javascripts/module/primitives.js on lines 419..421

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

              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

                      $type
                        .find('[data-clazz][data-provider]')
                        .show()
                        .not('[data-clazz="' + $clazz.val() + '"][data-provider="' + $provider.val() + '"]')
                        .hide()
              Severity: Major
              Found in hawk/app/assets/javascripts/module/primitives.js and 1 other location - About 1 hr to fix
              hawk/app/assets/javascripts/module/primitives.js on lines 412..417

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

              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

                      $type
                        .find('[data-clazz][data-provider]')
                        .show()
                        .not('[data-clazz="' + $clazz.val() + '"][data-provider="' + $provider.val() + '"]')
                        .hide()
              Severity: Major
              Found in hawk/app/assets/javascripts/module/primitives.js and 1 other location - About 1 hr to fix
              hawk/app/assets/javascripts/module/primitives.js on lines 389..394

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

              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

                  template: {
                    table_selector: '#templates #middle table.primitives, #configs #middle table.templates',
                    cib_primitives_path: Routes.cib_templates_path,
                    cib_primitive_path: Routes.cib_template_path,
                    edit_cib_primitive_path: Routes.edit_cib_template_path,
              Severity: Major
              Found in hawk/app/assets/javascripts/module/primitives.js and 1 other location - About 1 hr to fix
              hawk/app/assets/javascripts/module/primitives.js on lines 9..19

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

              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

                  primitive: {
                    table_selector: '#primitives #middle table.primitives, #configs #middle table.primitives',
                    cib_primitives_path: Routes.cib_primitives_path,
                    cib_primitive_path: Routes.cib_primitive_path,
                    edit_cib_primitive_path: Routes.edit_cib_primitive_path,
              Severity: Major
              Found in hawk/app/assets/javascripts/module/primitives.js and 1 other location - About 1 hr to fix
              hawk/app/assets/javascripts/module/primitives.js on lines 20..30

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

              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

                          $('[data-help-target]').each(function() {
                            $($(this).data('help-target')).hide();
                          });
              Severity: Minor
              Found in hawk/app/assets/javascripts/module/primitives.js and 1 other location - About 30 mins to fix
              hawk/app/assets/javascripts/module/help.js on lines 5..9

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

              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