crowbar/crowbar-core

View on GitHub
crowbar_framework/vendor/assets/javascripts/jquery/nodeList.js

Summary

Maintainability
F
3 days
Test Coverage

Function insertNode has 172 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  NodeList.prototype.insertNode = function(role, id, alias, admin, platform, platform_version, cluster, remotes, initial) {
    var self = this;
    var $role = $(self.dataBag.roleTarget.format(role));

    if (self.constraints) {
Severity: Major
Found in crowbar_framework/vendor/assets/javascripts/jquery/nodeList.js - About 6 hrs to fix

File nodeList.js has 444 lines of code (exceeds 250 allowed). Consider refactoring.
Open

;(function($, doc, win) {
  'use strict';

  function NodeList(el) {
    this.$root = $(el);
Severity: Minor
Found in crowbar_framework/vendor/assets/javascripts/jquery/nodeList.js - About 6 hrs to fix

Function equalOrMatchVersion has 57 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  NodeList.prototype.equalOrMatchVersion = function(value, maybe_regexp) {
    var to_version = function(version) {
      var match = /^(\d+)\.(\d+)\.(\d+)$/.exec(version);
      if (match) {
        return [parseInt(match[1]), parseInt(match[2]), parseInt(match[3])];
Severity: Major
Found in crowbar_framework/vendor/assets/javascripts/jquery/nodeList.js - About 2 hrs to fix

Function retrieveAllocated has 51 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  NodeList.prototype.retrieveAllocated = function() {
    var self = this;

    $.each(self.json.elements, function(role, nodes) {
      var $role = $(self.dataBag.roleTarget.format(role));
Severity: Major
Found in crowbar_framework/vendor/assets/javascripts/jquery/nodeList.js - About 2 hrs to fix

Function registerEvents has 47 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  NodeList.prototype.registerEvents = function() {
    var self = this;

    $('.dropzone .delete').live('click', function(event) {
      event.preventDefault();
Severity: Minor
Found in crowbar_framework/vendor/assets/javascripts/jquery/nodeList.js - About 1 hr to fix

Function insertNode has 9 arguments (exceeds 4 allowed). Consider refactoring.
Open

  NodeList.prototype.insertNode = function(role, id, alias, admin, platform, platform_version, cluster, remotes, initial) {
Severity: Major
Found in crowbar_framework/vendor/assets/javascripts/jquery/nodeList.js - About 1 hr to fix

Avoid too many return statements within this function.
Open

    return true;
Severity: Major
Found in crowbar_framework/vendor/assets/javascripts/jquery/nodeList.js - About 30 mins to fix

Avoid too many return statements within this function.
Open

          return self.errorMessage(
            'barclamp.node_selector.conflicting_roles'.localize().format(
              alias,
              role,
              constraints.conflicts_with.join(', ')
Severity: Major
Found in crowbar_framework/vendor/assets/javascripts/jquery/nodeList.js - About 30 mins to fix

Avoid too many return statements within this function.
Open

              return self.errorMessage(
                'barclamp.node_selector.max_count'.localize().format(
                  alias,
                  role
                )
Severity: Major
Found in crowbar_framework/vendor/assets/javascripts/jquery/nodeList.js - About 30 mins to fix

Avoid too many return statements within this function.
Open

            return self.errorMessage(
              'barclamp.node_selector.platform'.localize().format(
                alias,
                role
              )
Severity: Major
Found in crowbar_framework/vendor/assets/javascripts/jquery/nodeList.js - About 30 mins to fix

Avoid too many return statements within this function.
Open

            return self.errorMessage(
              'barclamp.node_selector.exclude_platform'.localize().format(
                alias,
                role
              )
Severity: Major
Found in crowbar_framework/vendor/assets/javascripts/jquery/nodeList.js - About 30 mins to fix

Avoid too many return statements within this function.
Open

          return self.errorMessage(
            'barclamp.node_selector.unique'.localize().format(
              alias,
              role
            )
Severity: Major
Found in crowbar_framework/vendor/assets/javascripts/jquery/nodeList.js - About 30 mins to fix

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

      if (constraints.remotes == undefined || !constraints.remotes) {
        if (remotes) {
          return self.errorMessage(
            'barclamp.node_selector.no_remotes'.localize().format(
              alias,
crowbar_framework/vendor/assets/javascripts/jquery/nodeList.js on lines 279..288
crowbar_framework/vendor/assets/javascripts/jquery/nodeList.js on lines 290..299

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

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 3 locations. Consider refactoring.
Open

      if (constraints.cluster == undefined || !constraints.cluster) {
        if (cluster) {
          return self.errorMessage(
            'barclamp.node_selector.no_cluster'.localize().format(
              alias,
crowbar_framework/vendor/assets/javascripts/jquery/nodeList.js on lines 279..288
crowbar_framework/vendor/assets/javascripts/jquery/nodeList.js on lines 301..310

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

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 3 locations. Consider refactoring.
Open

      if (constraints.admin == undefined || !constraints.admin) {
        if (admin) {
          return self.errorMessage(
            'barclamp.node_selector.no_admin'.localize().format(
              alias,
crowbar_framework/vendor/assets/javascripts/jquery/nodeList.js on lines 290..299
crowbar_framework/vendor/assets/javascripts/jquery/nodeList.js on lines 301..310

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

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

    win.setTimeout(
      function() {
        message.slideUp(500, function() {
          $(this).remove();
        });
Severity: Minor
Found in crowbar_framework/vendor/assets/javascripts/jquery/nodeList.js and 1 other location - About 40 mins to fix
crowbar_framework/vendor/assets/javascripts/jquery/messages.js on lines 24..31

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

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 platforms = $.map(constraints.platform, function(c_version, c_platform) {
            return (platform === c_platform) && self.equalOrMatchVersion(platform_version, c_version);
          });
Severity: Minor
Found in crowbar_framework/vendor/assets/javascripts/jquery/nodeList.js and 1 other location - About 35 mins to fix
crowbar_framework/vendor/assets/javascripts/jquery/nodeList.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 47.

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 platforms = $.map(constraints.exclude_platform, function(c_version, c_platform) {
            return (platform === c_platform) && self.equalOrMatchVersion(platform_version, c_version);
          });
Severity: Minor
Found in crowbar_framework/vendor/assets/javascripts/jquery/nodeList.js and 1 other location - About 35 mins to fix
crowbar_framework/vendor/assets/javascripts/jquery/nodeList.js on lines 379..381

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

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