crowbar/crowbar-core

View on GitHub

Showing 6,062 of 6,062 total issues

Function __module9__ has 462 lines of code (exceeds 25 allowed). Consider refactoring.
Open

var __module9__ = (function() {
  "use strict";
  var __exports__;
  /* Jison generated parser */
  var handlebars = (function(){
Severity: Major
Found in crowbar_framework/vendor/assets/javascripts/misc/handlebars.js - About 2 days to fix

Function handlebars has 458 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  var handlebars = (function(){
  var parser = {trace: function trace() { },
  yy: {},
  symbols_: {"error":2,"root":3,"statements":4,"EOF":5,"program":6,"simpleInverse":7,"statement":8,"openInverse":9,"closeBlock":10,"openBlock":11,"mustache":12,"partial":13,"CONTENT":14,"COMMENT":15,"OPEN_BLOCK":16,"inMustache":17,"CLOSE":18,"OPEN_INVERSE":19,"OPEN_ENDBLOCK":20,"path":21,"OPEN":22,"OPEN_UNESCAPED":23,"CLOSE_UNESCAPED":24,"OPEN_PARTIAL":25,"partialName":26,"partial_option0":27,"inMustache_repetition0":28,"inMustache_option0":29,"dataName":30,"param":31,"STRING":32,"INTEGER":33,"BOOLEAN":34,"hash":35,"hash_repetition_plus0":36,"hashSegment":37,"ID":38,"EQUALS":39,"DATA":40,"pathSegments":41,"SEP":42,"$accept":0,"$end":1},
  terminals_: {2:"error",5:"EOF",14:"CONTENT",15:"COMMENT",16:"OPEN_BLOCK",18:"CLOSE",19:"OPEN_INVERSE",20:"OPEN_ENDBLOCK",22:"OPEN",23:"OPEN_UNESCAPED",24:"CLOSE_UNESCAPED",25:"OPEN_PARTIAL",32:"STRING",33:"INTEGER",34:"BOOLEAN",38:"ID",39:"EQUALS",40:"DATA",42:"SEP"},
Severity: Major
Found in crowbar_framework/vendor/assets/javascripts/misc/handlebars.js - About 2 days to fix

Function setup has 413 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    function setup($) {
        $.fn._fadeIn = $.fn.fadeIn;

        var noOp = $.noop || function() {};

Severity: Major
Found in crowbar_framework/vendor/assets/javascripts/jquery/blockui.js - About 2 days to fix

Class ServiceObject has 98 methods (exceeds 20 allowed). Consider refactoring.
Open

class ServiceObject
  include CrowbarPacemakerProxy

  FORBIDDEN_PROPOSAL_NAMES=["template","nodes","commit","status"]

Severity: Major
Found in crowbar_framework/app/models/service_object.rb - About 1 day to fix

Function __module10__ has 363 lines of code (exceeds 25 allowed). Consider refactoring.
Open

var __module10__ = (function(__dependency1__, __dependency2__, __dependency3__, __dependency4__) {
  "use strict";
  var __exports__ = {};
  var Exception = __dependency1__;
  var parse = __dependency2__.parse;
Severity: Major
Found in crowbar_framework/vendor/assets/javascripts/misc/handlebars.js - About 1 day to fix

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

  $("[data-droppable=true]").droppable({
    hoverClass: 'targeted',
    drop: function(event, ui) {
      var $group = $(event.target);
      var $node = $(ui.draggable.context);
crowbar_framework/app/assets/javascripts/barclamps/crowbar/application.js on lines 42..97

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

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

      $('[data-droppable=true]:last').droppable({
        hoverClass: 'targeted',
        drop: function(event, ui) {
          var $group = $(event.target);
          var $node = $(ui.draggable.context);
crowbar_framework/app/assets/javascripts/barclamps/crowbar/application.js on lines 125..180

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

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

Method proposal_update has a Cognitive Complexity of 86 (exceeds 5 allowed). Consider refactoring.
Open

  def proposal_update
    if params[:submit].nil?
      #
      # This is RESTFul path
      #
Severity: Minor
Found in crowbar_framework/app/controllers/barclamp_controller.rb - About 1 day 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

File nic.rb has 723 lines of code (exceeds 250 allowed). Consider refactoring.
Open

class ::Nic
  include Comparable
  private
  @@interfaces = Hash.new
  @nic = nil
Severity: Major
Found in chef/cookbooks/barclamp/libraries/nic.rb - About 1 day to fix

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

    _adjustOffsetFromHelper: function(obj) {
        if (typeof obj === "string") {
            obj = obj.split(" ");
        }
        if ($.isArray(obj)) {
Severity: Major
Found in crowbar_framework/vendor/assets/javascripts/jquery/ui.js and 1 other location - About 1 day to fix
crowbar_framework/vendor/assets/javascripts/jquery/ui.js on lines 4905..4924

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

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

    _adjustOffsetFromHelper: function(obj) {
        if (typeof obj === "string") {
            obj = obj.split(" ");
        }
        if ($.isArray(obj)) {
Severity: Major
Found in crowbar_framework/vendor/assets/javascripts/jquery/ui.js and 1 other location - About 1 day to fix
crowbar_framework/vendor/assets/javascripts/jquery/ui.js on lines 1759..1778

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

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

File upgrade_controller.rb has 668 lines of code (exceeds 250 allowed). Consider refactoring.
Open

class Api::UpgradeController < ApiController
  # disable upgrade API until upgrade to next version is implemented
  before_action(except: :show) do
    # skip filter if we're in the middle of upgrade from previos version
    unless File.exist?("/var/lib/crowbar/upgrade/8-to-9-upgrade-running")
Severity: Major
Found in crowbar_framework/app/controllers/api/upgrade_controller.rb - About 1 day to fix

Class Upgrade has 78 methods (exceeds 20 allowed). Consider refactoring.
Open

  class Upgrade < Tableless
    class << self
      def timeouts
        ::Crowbar::UpgradeTimeouts.new.values
      end
Severity: Major
Found in crowbar_framework/app/models/api/upgrade.rb - About 1 day to fix

Method apply_role has 289 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def apply_role(role, inst, in_queue, bootstrap = false)
    Rails.logger.debug "apply_role(#{role.name}, #{inst}, #{in_queue}, #{bootstrap})"
    Rails.logger.progress("Starting to apply role #{role.name}")

    # Variables used in the global ensure
Severity: Major
Found in crowbar_framework/app/models/service_object.rb - About 1 day to fix

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

            if ( data.collisionHeight > outerHeight ) {
                // element is initially over the top of within
                if ( overTop > 0 && overBottom <= 0 ) {
                    newOverBottom = position.top + overTop + data.collisionHeight - outerHeight - withinOffset;
                    position.top += overTop - newOverBottom;
Severity: Major
Found in crowbar_framework/vendor/assets/javascripts/jquery/ui.js and 1 other location - About 1 day to fix
crowbar_framework/vendor/assets/javascripts/jquery/ui.js on lines 1281..1306

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

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.collisionWidth > outerWidth ) {
                // element is initially over the left side of within
                if ( overLeft > 0 && overRight <= 0 ) {
                    newOverRight = position.left + overLeft + data.collisionWidth - outerWidth - withinOffset;
                    position.left += overLeft - newOverRight;
Severity: Major
Found in crowbar_framework/vendor/assets/javascripts/jquery/ui.js and 1 other location - About 1 day to fix
crowbar_framework/vendor/assets/javascripts/jquery/ui.js on lines 1318..1343

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

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

File default.rb has 621 lines of code (exceeds 250 allowed). Consider refactoring.
Open

return if node[:platform_family] == "windows"

dirty = false

# Make sure packages we need will be present
Severity: Major
Found in chef/cookbooks/network/recipes/default.rb - About 1 day to fix

Method bulk has a Cognitive Complexity of 66 (exceeds 5 allowed). Consider refactoring.
Open

  def bulk
    @report = {
      success: [],
      failed: [],
      duplicate_public: false,
Severity: Minor
Found in crowbar_framework/app/controllers/nodes_controller.rb - About 1 day 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 lexer has 243 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  var lexer = (function(){
  var lexer = ({EOF:1,
  parseError:function parseError(str, hash) {
          if (this.yy.parser) {
              this.yy.parser.parseError(str, hash);
Severity: Major
Found in crowbar_framework/vendor/assets/javascripts/misc/handlebars.js - About 1 day to fix

Class Nic has 66 methods (exceeds 20 allowed). Consider refactoring.
Open

class ::Nic
  include Comparable
  private
  @@interfaces = Hash.new
  @nic = nil
Severity: Major
Found in chef/cookbooks/barclamp/libraries/nic.rb - About 1 day to fix
Severity
Category
Status
Source
Language