crowbar/crowbar-core

View on GitHub

Showing 1,006 of 6,062 total issues

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

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

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

Function ajaxConvert has 56 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function ajaxConvert( s, response, jqXHR, isSuccess ) {
    var conv2, current, conv, tmp, prev,
        converters = {},
        // Work with a copy of dataTypes in case we need to modify it for conversion
        dataTypes = s.dataTypes.slice();
Severity: Major
Found in crowbar_framework/vendor/assets/javascripts/jquery/jquery.js - About 2 hrs to fix

Function _generateMonthYearHeader has 56 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    _generateMonthYearHeader: function(inst, drawMonth, drawYear, minDate, maxDate,
            secondary, monthNames, monthNamesShort) {

        var inMinYear, inMaxYear, month, years, thisYear, determineYear, year, endYear,
            changeMonth = this._get(inst, "changeMonth"),
Severity: Major
Found in crowbar_framework/vendor/assets/javascripts/jquery/ui.js - About 2 hrs to fix

Function renderRegion has 56 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      renderRegion: function (valuenum, highlight) {
        var vals = this.values[valuenum],
          options = this.options,
          xaxisOffset = this.xaxisOffset,
          result = [],
Severity: Major
Found in crowbar_framework/vendor/assets/javascripts/jquery/sparkline.js - About 2 hrs to fix

Function createWrapper has 56 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    createWrapper: function( element ) {

        // if the element is already wrapped, return it
        if ( element.parent().is( ".ui-effects-wrapper" )) {
            return element.parent();
Severity: Major
Found in crowbar_framework/vendor/assets/javascripts/jquery/ui.js - About 2 hrs to fix

Function _mouseStart has 54 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    _mouseStart: function(event) {
        var that = this,
            options = this.options;

        this.opos = [event.pageX, event.pageY];
Severity: Major
Found in crowbar_framework/vendor/assets/javascripts/jquery/ui.js - About 2 hrs to fix

Function show has 54 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  Tooltip.prototype.show = function () {
    var e = $.Event('show.bs.' + this.type)

    if (this.hasContent() && this.enabled) {
      this.$element.trigger(e)
Severity: Major
Found in crowbar_framework/vendor/assets/javascripts/bootstrap/tooltip.js - About 2 hrs to fix

Method evacuate_network_node has 54 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def evacuate_network_node(controller, network_node, delete_namespaces = false)
        save_node_action("evacuating dhcp networks")
        hostname = network_node["hostname"]
        migrated_file = "/var/lib/crowbar/upgrade/crowbar-network-evacuated"
        if network_node.file_exist? migrated_file
Severity: Major
Found in crowbar_framework/app/models/api/upgrade.rb - About 2 hrs to fix

Method apply_role_pre_chef_call has 54 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def apply_role_pre_chef_call(old_role, role, all_nodes)
    Rails.logger.debug("DNS apply_role_pre_chef_call: entering #{all_nodes.inspect}")
    return if all_nodes.empty?

    tnodes = role.override_attributes["dns"]["elements"]["dns-server"]
Severity: Major
Found in crowbar_framework/app/models/dns_service.rb - About 2 hrs to fix
Severity
Category
Status
Source
Language