crowbar/crowbar-core

View on GitHub

Showing 1,006 of 6,062 total issues

File upgrade_controller_spec.rb has 290 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require "spec_helper"

describe Api::UpgradeController, type: :request do
  context "with a successful upgrade API request" do
    let(:headers) { { ACCEPT: "application/vnd.crowbar.v2.0+json" } }
Severity: Minor
Found in crowbar_framework/spec/controllers/api/upgrade_controller_spec.rb - About 2 hrs to fix

Function add has 73 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    add: function( elem, types, handler, data, selector ) {
        var tmp, events, t, handleObjIn,
            special, eventHandle, handleObj,
            handlers, type, namespaces, origType,
            elemData = jQuery._data( elem );
Severity: Major
Found in crowbar_framework/vendor/assets/javascripts/jquery/jquery.js - About 2 hrs to fix

Function _create has 73 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    _create: function() {
        this.activeMenu = this.element;
        // flag used to prevent firing of the click handler
        // as the event bubbles up through nested menus
        this.mouseHandled = false;
Severity: Major
Found in crowbar_framework/vendor/assets/javascripts/jquery/ui.js - About 2 hrs to fix

Function write has 73 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  JsonAttribute.prototype.write = function(key, value, type) {
    switch (type) {
      case 'boolean':
        value = value.toLowerCase() == 'true';
        break;
Severity: Major
Found in crowbar_framework/vendor/assets/javascripts/jquery/jsonAttribute.js - About 2 hrs to fix

Method transition has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
Open

  def transition(inst, name, state)
    Rails.logger.debug("Provisioner transition: entering:  #{name} for #{state}")

    # hardware-installing for the bootdisk finder
    if ["hardware-installing", "installed", "readying"].include? state
Severity: Minor
Found in crowbar_framework/app/models/provisioner_service.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 verify_claimed_disks has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
Open

  def verify_claimed_disks
    unreferenced_disks = Array.new
    crowbar_wall[:claimed_disks].each do |disk, _claim|
      path, device_name = disk.split("/")[-2..-1]

Severity: Minor
Found in crowbar_framework/app/models/node.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

File restore.rb has 287 lines of code (exceeds 250 allowed). Consider refactoring.
Open

module Crowbar
  class Backup
    class Restore
      attr_accessor :backup, :version

Severity: Minor
Found in crowbar_framework/lib/crowbar/backup/restore.rb - About 2 hrs to fix

Function widget has 72 lines of code (exceeds 25 allowed). Consider refactoring.
Open

$.widget = function( name, base, prototype ) {
    var fullName, existingConstructor, constructor, basePrototype,
        // proxiedPrototype allows the provided prototype to remain unmodified
        // so that it can be used as a mixin for multiple widgets (#8876)
        proxiedPrototype = {},
Severity: Major
Found in crowbar_framework/vendor/assets/javascripts/jquery/ui.js - About 2 hrs to fix

Class Disk has 25 methods (exceeds 20 allowed). Consider refactoring.
Open

      class Disk
        attr_reader :device
        def initialize(node,name)
          # comes from ohai, and can e.g. "hda", "sda", or "cciss!c0d0"
          @device = name
Severity: Minor
Found in chef/cookbooks/barclamp/libraries/barclamp_library.rb - About 2 hrs to fix

Class BarclampController has 25 methods (exceeds 20 allowed). Consider refactoring.
Open

class BarclampController < ApplicationController
  wrap_parameters false

  skip_before_filter :enforce_installer, if: proc { Crowbar::Installer.initial_chef_client? }
  skip_before_filter :upgrade, only: [:transition]
Severity: Minor
Found in crowbar_framework/app/controllers/barclamp_controller.rb - About 2 hrs to fix

Class Attribute has 25 methods (exceeds 20 allowed). Consider refactoring.
Open

    class Attribute
      attr_accessor :attrs
      attr_accessor :proposal
      attr_accessor :view
      attr_accessor :attribute
Severity: Minor
Found in crowbar_framework/lib/dsl/proposal/attribute.rb - About 2 hrs to fix

Function _contactContainers has 70 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    _contactContainers: function(event) {
        var i, j, dist, itemWithLeastDistance, posProperty, sizeProperty, base, cur, nearBottom, floating,
            innermostContainer = null,
            innermostIndex = null;

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

Method bootstrap_ensure_proposal has 70 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def bootstrap_ensure_proposal(bc, override_attr_path)
    Rails.logger.info("Bootstrap: ensure proposal for bc: #{bc}, name: #{override_attr_path}")

    unless override_attr_path == "default" || File.exist?(override_attr_path)
      msg = "Cannot ensure proposal for #{bc} exists: #{override_attr_path} does not exist."
Severity: Major
Found in crowbar_framework/app/models/crowbar_service.rb - About 2 hrs to fix

Function statusCheck has 69 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  function statusCheck() {
    $.ajax({
      type: "GET",
      dataType: "json",
      url: Routes.status_installer_path(),
Severity: Major
Found in crowbar_framework/app/assets/javascripts/installer.js - About 2 hrs to fix

Method find_node_boot_mac_addresses has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
Open

def find_node_boot_mac_addresses(node, admin_data_net)
  # If we don't have an admin IP allocated yet, using node.macaddress is
  # our best guess for the boot macaddress.
  if admin_data_net.nil? || \
      admin_data_net.interface_list.nil?
Severity: Minor
Found in chef/cookbooks/provisioner/recipes/update_nodes.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 bootstrap_ensure_proposal has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
Open

  def bootstrap_ensure_proposal(bc, override_attr_path)
    Rails.logger.info("Bootstrap: ensure proposal for bc: #{bc}, name: #{override_attr_path}")

    unless override_attr_path == "default" || File.exist?(override_attr_path)
      msg = "Cannot ensure proposal for #{bc} exists: #{override_attr_path} does not exist."
Severity: Minor
Found in crowbar_framework/app/models/crowbar_service.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 reset_pk_sequence! has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
Open

        def reset_pk_sequence!(table, pk = nil, sequence = nil) #:nodoc:
          unless pk and sequence
            default_pk, default_sequence = pk_and_sequence_for(table)

            pk ||= default_pk

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 matcherFromGroupMatchers has 68 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function matcherFromGroupMatchers( elementMatchers, setMatchers ) {
    var bySet = setMatchers.length > 0,
        byElement = elementMatchers.length > 0,
        superMatcher = function( seed, context, xml, results, outermost ) {
            var elem, j, matcher,
Severity: Major
Found in crowbar_framework/vendor/assets/javascripts/jquery/jquery.js - About 2 hrs to fix

Function updateDisplay has 68 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    function updateDisplay(changes) {
      if (!scroller.clientWidth) {
        showingFrom = showingTo = 0;
        return;
      }
Severity: Major
Found in crowbar_framework/vendor/assets/javascripts/codemirror/codemirror.js - About 2 hrs to fix

Function done has 67 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        function done( status, nativeStatusText, responses, headers ) {
            var isSuccess, success, error, response, modified,
                statusText = nativeStatusText;

            // Called once
Severity: Major
Found in crowbar_framework/vendor/assets/javascripts/jquery/jquery.js - About 2 hrs to fix
Severity
Category
Status
Source
Language