crowbar/crowbar-core

View on GitHub

Showing 6,062 of 6,062 total issues

Function data has 32 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    data: function( key, value ) {
        var i, name, data,
            elem = this[0],
            attrs = elem && elem.attributes;

Severity: Minor
Found in crowbar_framework/vendor/assets/javascripts/jquery/jquery.js - About 1 hr to fix

Function fixCloneNodeIssues has 32 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function fixCloneNodeIssues( src, dest ) {
    var nodeName, e, data;

    // We do not need to do anything for non-Elements
    if ( dest.nodeType !== 1 ) {
Severity: Minor
Found in crowbar_framework/vendor/assets/javascripts/jquery/jquery.js - About 1 hr to fix

Function load has 32 lines of code (exceeds 25 allowed). Consider refactoring.
Open

jQuery.fn.load = function( url, params, callback ) {
    if ( typeof url !== "string" && _load ) {
        return _load.apply( this, arguments );
    }

Severity: Minor
Found in crowbar_framework/vendor/assets/javascripts/jquery/jquery.js - About 1 hr to fix

Function addClass has 32 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    addClass: function( value ) {
        var classes, elem, cur, clazz, j, finalValue,
            i = 0,
            len = this.length,
            proceed = typeof value === "string" && value;
Severity: Minor
Found in crowbar_framework/vendor/assets/javascripts/jquery/jquery.js - About 1 hr to fix

Function _size has 32 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    _size: function() {
        // If the user has resized the dialog, the .ui-dialog and .ui-dialog-content
        // divs will both have width and height set, so we need to reset them
        var nonContentHeight, minContentHeight, maxContentHeight,
            options = this.options;
Severity: Minor
Found in crowbar_framework/vendor/assets/javascripts/jquery/ui.js - About 1 hr to fix

Function left has 32 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        left: function( position, data ) {
            var within = data.within,
                withinOffset = within.offset.left + within.scrollLeft,
                outerWidth = within.width,
                offsetLeft = within.isWindow ? within.scrollLeft : within.offset.left,
Severity: Minor
Found in crowbar_framework/vendor/assets/javascripts/jquery/ui.js - About 1 hr to fix

Function _refreshItems has 32 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    _refreshItems: function(event) {

        this.items = [];
        this.containers = [this];

Severity: Minor
Found in crowbar_framework/vendor/assets/javascripts/jquery/ui.js - About 1 hr to fix

Function _normalizeArguments has 32 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function _normalizeArguments( effect, options, speed, callback ) {

    // allow passing all options as the first parameter
    if ( $.isPlainObject( effect ) ) {
        options = effect;
Severity: Minor
Found in crowbar_framework/vendor/assets/javascripts/jquery/ui.js - About 1 hr to fix

Function raise has 32 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        raise: function (event, params) {
            var self = this, e = $.Event(event);
            if (params !== undefined) {
                self.$element.trigger(e, params);
            } else {
Severity: Minor
Found in crowbar_framework/vendor/assets/javascripts/bootstrap/fileinput.js - About 1 hr to fix

Method load has 32 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        def load(group, barclamp, instance = nil)
          # If no instance is specified, see if this node uses an instance of
          # this barclamp and use it
          if instance.nil? && @node[barclamp] && @node[barclamp][:config]
            instance = @node[barclamp][:config][:environment]
Severity: Minor
Found in chef/cookbooks/barclamp/libraries/barclamp_library.rb - About 1 hr to fix

Function compile has 32 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    compile: function(environment, options, context, asObject) {
      this.environment = environment;
      this.options = options || {};

      log('debug', this.environment.disassemble() + "\n\n");
Severity: Minor
Found in crowbar_framework/vendor/assets/javascripts/misc/handlebars.js - About 1 hr to fix

Method wait_for_reboot has 32 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def wait_for_reboot(node)
    nobj = Node.find_by_name(node)
    if nobj[:crowbar_wall][:wait_for_reboot]
      puts "Waiting for reboot of node #{node}"
      if RemoteNode.ready?(node, 1200)
Severity: Minor
Found in crowbar_framework/app/models/service_object.rb - About 1 hr to fix

Method transition has 32 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def transition
    name = params[:id]
    state = params[:state]

    load_node
Severity: Minor
Found in crowbar_framework/app/controllers/restricted_controller.rb - About 1 hr to fix

Method element_nodes has 32 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def element_nodes(roles = self.class.all, nodes = Node.all)
    assigned_nodes = []

    # Get all nodes from proposal roles mentioning this one
    proposal_roles(roles).each do |prop|
Severity: Minor
Found in crowbar_framework/app/models/role_object.rb - About 1 hr to fix

Method get_node_and_network has 32 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def get_node_and_network(node_name)
    network = {}
    @network = []
    @node = Node.find_by_name(node_name) if @node.nil?
    if @node
Severity: Minor
Found in crowbar_framework/app/controllers/nodes_controller.rb - About 1 hr to fix

Method update has 32 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def update
    @updateDoc = ""

    case params[:updateAction]
    when "compute"
Severity: Minor
Found in crowbar_framework/app/controllers/ucs_controller.rb - About 1 hr to fix

Method adminrepocheck has 32 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def adminrepocheck
    check = Api::Upgrade.adminrepocheck

    if check.key?(:error)
      render json: {
Severity: Minor
Found in crowbar_framework/app/controllers/api/upgrade_controller.rb - About 1 hr to fix

Method wait_for_script_to_finish has 32 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def wait_for_script_to_finish(script, seconds, args = [], enforce_timeout = false)
    cmd = script
    cmd += " " + args.join(" ") unless args.empty?

    raise "Script #{script} is not present on the node #{@node.name}." unless file_exist?(script)
Severity: Minor
Found in crowbar_framework/app/models/node.rb - About 1 hr to fix

Method add_role_to_instance_and_node has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

  def add_role_to_instance_and_node(barclamp, instance, name, prop, role, newrole)
    node = Node.find_by_name(name)
    if node.nil?
      Rails.logger.debug("ARTOI: couldn't find node #{name}. bailing")
      return false
Severity: Minor
Found in crowbar_framework/app/models/service_object.rb - About 1 hr 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 enable_repository has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

  def enable_repository(platform, arch, repo)
    repo_object = Crowbar::Repository.where(platform: platform, arch: arch, repo: repo).first
    if repo_object.nil?
      message = "#{repo} repository for #{platform} / #{arch} does not exist."
      Rails.logger.debug(message)
Severity: Minor
Found in crowbar_framework/app/models/provisioner_service.rb - About 1 hr 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

Severity
Category
Status
Source
Language