crowbar/crowbar-core

View on GitHub

Showing 6,062 of 6,062 total issues

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

                    if (!event.metaKey && !event.ctrlKey && !selectee.startselected) {
                        selectee.$element.removeClass("ui-selected");
                        selectee.selected = false;

                        selectee.$element.addClass("ui-unselecting");
Severity: Major
Found in crowbar_framework/vendor/assets/javascripts/jquery/ui.js and 1 other location - About 2 hrs to fix
crowbar_framework/vendor/assets/javascripts/jquery/ui.js on lines 3818..3827

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

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(!inst.snapElements[i].snapping && (ts || bs || ls || rs || first)) {
                (inst.options.snap.snap && inst.options.snap.snap.call(inst.element, event, $.extend(inst._uiHash(), { snapItem: inst.snapElements[i].item })));
            }
Severity: Major
Found in crowbar_framework/vendor/assets/javascripts/jquery/ui.js and 1 other location - About 2 hrs to fix
crowbar_framework/vendor/assets/javascripts/jquery/ui.js on lines 2321..2323

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

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(inst.snapElements[i].snapping) {
                    (inst.options.snap.release && inst.options.snap.release.call(inst.element, event, $.extend(inst._uiHash(), { snapItem: inst.snapElements[i].item })));
                }
Severity: Major
Found in crowbar_framework/vendor/assets/javascripts/jquery/ui.js and 1 other location - About 2 hrs to fix
crowbar_framework/vendor/assets/javascripts/jquery/ui.js on lines 2368..2370

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

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

Function Deferred has 59 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    Deferred: function( func ) {
        var tuples = [
                // action, add listener, listener list, final state
                [ "resolve", "done", jQuery.Callbacks("once memory"), "resolved" ],
                [ "reject", "fail", jQuery.Callbacks("once memory"), "rejected" ],
Severity: Major
Found in crowbar_framework/vendor/assets/javascripts/jquery/jquery.js - About 2 hrs to fix

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

      success: function(data) {
        // check for invalid network.json
        $("#network-alert").remove();
        if (!data.network.valid) {
          $(".button_to").find("input").prop("disabled", true);
Severity: Major
Found in crowbar_framework/app/assets/javascripts/installer.js - About 2 hrs to fix

Function CHILD has 59 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        "CHILD": function( type, what, argument, first, last ) {
            var simple = type.slice( 0, 3 ) !== "nth",
                forward = type.slice( -4 ) !== "last",
                ofType = what === "of-type";

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

Function __module3__ has 59 lines of code (exceeds 25 allowed). Consider refactoring.
Open

var __module3__ = (function(__dependency1__) {
  "use strict";
  var __exports__ = {};
  var SafeString = __dependency1__;

Severity: Major
Found in crowbar_framework/vendor/assets/javascripts/misc/handlebars.js - About 2 hrs to fix

Function explode has 59 lines of code (exceeds 25 allowed). Consider refactoring.
Open

$.effects.effect.explode = function( o, done ) {

    var rows = o.pieces ? Math.round( Math.sqrt( o.pieces ) ) : 3,
        cells = rows,
        el = $( this ),
Severity: Major
Found in crowbar_framework/vendor/assets/javascripts/jquery/ui.js - About 2 hrs to fix

File modal.js has 265 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/* ========================================================================
 * Bootstrap: modal.js v3.4.1
 * https://getbootstrap.com/docs/3.4/javascript/#modals
 * ========================================================================
 * Copyright 2011-2019 Twitter, Inc.
Severity: Minor
Found in crowbar_framework/vendor/assets/javascripts/bootstrap/modal.js - About 2 hrs to fix

Consider simplifying this complex logical expression.
Open

                        if ( forward && useCache ) {
                            // Seek `elem` from a previously-cached index
                            outerCache = parent[ expando ] || (parent[ expando ] = {});
                            cache = outerCache[ type ] || [];
                            nodeIndex = cache[0] === dirruns && cache[1];
Severity: Critical
Found in crowbar_framework/vendor/assets/javascripts/jquery/jquery.js - About 2 hrs to fix

Consider simplifying this complex logical expression.
Open

  if new_group == "os_install" && !admin_data_net.nil?
    # This eventually needs to be configurable on a per-node basis
    # We select the os based on the target platform specified.
    os = mnode[:target_platform]
    if os.nil? || os.empty?
Severity: Critical
Found in chef/cookbooks/provisioner/recipes/update_nodes.rb - About 2 hrs to fix

Class Backup has 22 methods (exceeds 20 allowed). Consider refactoring.
Open

class Api::Backup < ActiveRecord::Base
  belongs_to :crowbar

  attr_accessor :file

Severity: Minor
Found in crowbar_framework/app/models/api/backup.rb - About 2 hrs to fix

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

    _generatePosition: function(event) {

        var containment, co, top, left,
            o = this.options,
            scroll = this.cssPosition === "absolute" && !( this.scrollParent[ 0 ] !== document && $.contains( this.scrollParent[ 0 ], this.offsetParent[ 0 ] ) ) ? this.offsetParent : this.scrollParent,
Severity: Major
Found in crowbar_framework/vendor/assets/javascripts/jquery/ui.js - About 2 hrs to fix

Method restore_files has 58 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        def restore_files
          [
            [
              "root/.gnupg",
              "/root/.gnupg"
Severity: Major
Found in crowbar_framework/lib/crowbar/backup/base.rb - About 2 hrs to fix

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

        keydown: function( event ) {
            /*jshint maxcomplexity:25*/
            var allowed, curVal, newVal, step,
                index = $( event.target ).data( "ui-slider-handle-index" );

Severity: Major
Found in crowbar_framework/vendor/assets/javascripts/jquery/ui.js - About 2 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

File provisioner_service.rb has 261 lines of code (exceeds 250 allowed). Consider refactoring.
Open

class ProvisionerService < ServiceObject
  include Crowbar::SSHKeyParser

  def initialize(thelogger = nil)
    super
Severity: Minor
Found in crowbar_framework/app/models/provisioner_service.rb - About 2 hrs to fix

Method node_ip_list has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

  def node_ip_list(ips)
    entries = [].tap do |result|
      ips.each do |network, addresses|
        unless network == "~notconnected" and addresses.nil?
          network_list = if ["[not managed]", "[dhcp]"].include? network
Severity: Minor
Found in crowbar_framework/app/helpers/nodes_helper.rb - About 2 hrs 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

Method save_node has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

  def save_node
    if params[:group] and params[:group] != "" and !(params[:group] =~ /^[a-zA-Z][a-zA-Z0-9._:-]+$/)
      flash[:alert] = t("nodes.list.group_error", failed: @node.name)
      return false
    end
Severity: Minor
Found in crowbar_framework/app/controllers/nodes_controller.rb - About 2 hrs 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

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

        getPreviewTemplate: function (t) {
            var self = this,
                template = isSet(t, self.previewTemplates) ? self.previewTemplates[t] : defaultPreviewTemplates[t];
            if (isEmpty(self.customPreviewTags)) {
                return template;
crowbar_framework/vendor/assets/javascripts/bootstrap/fileinput.js on lines 685..692

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

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

Severity
Category
Status
Source
Language