crowbar/crowbar-core

View on GitHub

Showing 6,062 of 6,062 total issues

Function handleRemote has 62 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    handleRemote: function(element) {
      var method, url, data, elCrossDomain, crossDomain, withCredentials, dataType, options;

      if (rails.fire(element, 'ajax:before')) {
        elCrossDomain = element.data('cross-domain');
Severity: Major
Found in crowbar_framework/vendor/assets/javascripts/jquery/rails.js - About 2 hrs to fix

Function getCurrentRegionTooltip has 62 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      getCurrentRegionTooltip: function () {
        var options = this.options,
          header = '',
          entries = [],
          fields, formats, formatlen, fclass, text, i,
Severity: Major
Found in crowbar_framework/vendor/assets/javascripts/jquery/sparkline.js - About 2 hrs to fix

Method parallel_upgrade_compute_nodes has 62 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def parallel_upgrade_compute_nodes(compute_nodes, controller = nil)
        Rails.logger.info("Entering parallel upgrade of compute nodes, #{upgrade_mode} mode")
        Rails.logger.info("Nodes for upgrade: #{compute_nodes.map(&:name).join(', ')}")
        save_nodes_state(compute_nodes, "compute", "upgrading")
        save_node_action("upgrading the packages")
Severity: Major
Found in crowbar_framework/app/models/api/upgrade.rb - About 2 hrs to fix

Function superMatcher has 61 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        superMatcher = function( seed, context, xml, results, outermost ) {
            var elem, j, matcher,
                matchedCount = 0,
                i = "0",
                unmatched = seed && [],
Severity: Major
Found in crowbar_framework/vendor/assets/javascripts/jquery/jquery.js - About 2 hrs to fix

Function _showDatepicker has 61 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    _showDatepicker: function(input) {
        input = input.target || input;
        if (input.nodeName.toLowerCase() !== "input") { // find from button/image trigger
            input = $("input", input.parentNode)[0];
        }
Severity: Major
Found in crowbar_framework/vendor/assets/javascripts/jquery/ui.js - About 2 hrs to fix

Method add_and_filter has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

def add_and_filter(file, add, filter_re)
  lock = nil
  lock = lock(@new_resource)
  need_to_add = !add.nil?
  need_to_remove = false
Severity: Minor
Found in chef/cookbooks/utils/providers/line.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 node_state_valid_for_role? has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

  def self.node_state_valid_for_role?(node, barclamp, role)
    # We always want deployer-client, both for heartbeat but also because it
    # sets up the ability to use the barclamp library
    return true if role == "deployer-client"

Severity: Minor
Found in chef/cookbooks/utils/libraries/role_recipe.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 skip_unready_nodes has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

  def skip_unready_nodes(bc, inst, new_elements, old_elements)
    logger.debug("skip_unready_nodes: enter for #{bc}:#{inst}")
    skip_unready_nodes_roles = Rails.application.config.crowbar.fetch(
      "skip_unready_nodes", {}
    ).fetch("roles", [])
Severity: Minor
Found in crowbar_framework/app/models/service_object.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 element_nodes has a Cognitive Complexity of 18 (exceeds 5 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 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 expand_nodes_for_all has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

  def expand_nodes_for_all(items)
    nodes = []
    failures = []

    items.each do |item|
Severity: Minor
Found in crowbar_framework/lib/crowbar_pacemaker_proxy.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 restore_chef has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

      def restore_chef
        Rails.logger.debug "Restoring chef backup files"

        begin
          [:nodes, :roles, :clients, :databags].each do |type|
Severity: Minor
Found in crowbar_framework/lib/crowbar/backup/restore.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 send has 60 lines of code (exceeds 25 allowed). Consider refactoring.
Open

                send: function( headers, complete ) {
                    var i,
                        xhr = options.xhr(),
                        id = ++xhrId;

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

Function domManip has 60 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    domManip: function( args, callback ) {

        // Flatten any nested arrays
        args = concat.apply( [], args );

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

Function init has 60 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    init = jQuery.fn.init = function( selector, context ) {
        var match, elem;

        // HANDLE: $(""), $(null), $(undefined), $(false)
        if ( !selector ) {
Severity: Major
Found in crowbar_framework/vendor/assets/javascripts/jquery/jquery.js - About 2 hrs to fix

Function drag has 60 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    drag: function(event, ui) {

        var inst = $(this).data("ui-draggable"), that = this;

        $.each(inst.sortables, function() {
Severity: Major
Found in crowbar_framework/vendor/assets/javascripts/jquery/ui.js - About 2 hrs to fix

Function drag has 60 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    drag: function(event, ui) {

        var ts, bs, ls, rs, l, r, t, b, i, first,
            inst = $(this).data("ui-draggable"),
            o = inst.options,
Severity: Major
Found in crowbar_framework/vendor/assets/javascripts/jquery/ui.js - About 2 hrs to fix

Method node_ip_list has 60 lines of code (exceeds 25 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: Major
Found in crowbar_framework/app/helpers/nodes_helper.rb - About 2 hrs to fix

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

            if (!event.metaKey && !event.ctrlKey) {
                selectee.$element.removeClass("ui-selected");
                selectee.selected = false;
                selectee.$element.addClass("ui-unselecting");
                selectee.unselecting = true;
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 3932..3942

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 (opts.theme && full) {
                s = '<div class="blockUI ' + opts.blockMsgClass + ' blockPage ui-dialog ui-widget ui-corner-all" style="z-index:'+(z+10)+';display:none;position:fixed">';
                if ( opts.title ) {
                    s += '<div class="ui-widget-header ui-dialog-titlebar ui-corner-all blockTitle">'+(opts.title || '&nbsp;')+'</div>';
                }
crowbar_framework/vendor/assets/javascripts/jquery/blockui.js on lines 312..325

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

            else if (opts.theme) {
                s = '<div class="blockUI ' + opts.blockMsgClass + ' blockElement ui-dialog ui-widget ui-corner-all" style="z-index:'+(z+10)+';display:none;position:absolute">';
                if ( opts.title ) {
                    s += '<div class="ui-widget-header ui-dialog-titlebar ui-corner-all blockTitle">'+(opts.title || '&nbsp;')+'</div>';
                }
crowbar_framework/vendor/assets/javascripts/jquery/blockui.js on lines 304..325

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

Severity
Category
Status
Source
Language