crowbar/crowbar-core

View on GitHub

Showing 6,062 of 6,062 total issues

Method start has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    def start
      header = :ok
      msg = ""
      msg_type = :alert

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_barclamp_list has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

  def node_barclamp_list(node)
    all_proposals = Proposal.all

    list_items = ActiveSupport::OrderedHash.new.tap do |listing|
      node_barclamps(node).map do |role|
Severity: Minor
Found in crowbar_framework/app/helpers/nodes_helper.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 net_rpc_cmd has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

  def net_rpc_cmd(cmd)
    case cmd
    when :power_cycle
      unless system("net", "rpc", "shutdown", "-f", "-r", "-I", @node.name ,"-U", "Administrator%#{@node[:provisioner][:windows][:admin_password]}")
        Rails.logger.warn("samba command \"#{cmd}\" for #{@node.name} failed - node in unknown state")
Severity: Minor
Found in crowbar_framework/app/models/node.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 transition has a Cognitive Complexity of 13 (exceeds 5 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

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 resolve_if_ref has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    def resolve_if_ref(if_ref)
      result = nil

      speeds = ["10m", "100m", "1g", "10g", "20g", "40g", "56g"]
      m = /^([-+?]?)(\d{1,3}[mg])(\d+)$/.match(if_ref) # [1]=sign, [2]=speed, [3]=count
Severity: Minor
Found in crowbar_framework/lib/crowbar/conduit_resolver.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

Function addCombinator has 39 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function addCombinator( matcher, combinator, base ) {
    var dir = combinator.dir,
        checkNonElements = base && dir === "parentNode",
        doneName = done++;

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

Function computeStyleTests has 39 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    function computeStyleTests() {
        // Minified: var b,c,d,j
        var div, body, container, contents;

        body = document.getElementsByTagName( "body" )[ 0 ];
Severity: Minor
Found in crowbar_framework/vendor/assets/javascripts/jquery/jquery.js - About 1 hr to fix

Function _optionDatepicker has 39 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    _optionDatepicker: function(target, name, value) {
        var settings, date, minDate, maxDate,
            inst = this._getInst(target);

        if (arguments.length === 2 && typeof name === "string") {
Severity: Minor
Found in crowbar_framework/vendor/assets/javascripts/jquery/ui.js - About 1 hr to fix

Function bridge has 39 lines of code (exceeds 25 allowed). Consider refactoring.
Open

$.widget.bridge = function( name, object ) {
    var fullName = object.prototype.widgetFullName || name;
    $.fn[ name ] = function( options ) {
        var isMethodCall = typeof options === "string",
            args = slice.call( arguments, 1 ),
Severity: Minor
Found in crowbar_framework/vendor/assets/javascripts/jquery/ui.js - About 1 hr to fix

Function scanValues has 39 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      scanValues: function () {
        var values = this.values,
          valcount = values.length,
          xvalues = this.xvalues,
          yvalues = this.yvalues,
Severity: Minor
Found in crowbar_framework/vendor/assets/javascripts/jquery/sparkline.js - About 1 hr to fix

Function uploadExtraOnly has 39 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        uploadExtraOnly: function () {
            var self = this, params = {}, fnBefore, fnSuccess, fnComplete, fnError;
            self.formdata = new FormData();
            if (self.abort(params)) {
                return;
Severity: Minor
Found in crowbar_framework/vendor/assets/javascripts/bootstrap/fileinput.js - About 1 hr to fix

Function backdrop has 39 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  Modal.prototype.backdrop = function (callback) {
    var that = this
    var animate = this.$element.hasClass('fade') ? 'fade' : ''

    if (this.isShown && this.options.backdrop) {
Severity: Minor
Found in crowbar_framework/vendor/assets/javascripts/bootstrap/modal.js - About 1 hr to fix

Method add_and_filter has 39 lines of code (exceeds 25 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 1 hr to fix

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

  Modal.prototype.show = function (_relatedTarget) {
    var that = this
    var e = $.Event('show.bs.modal', { relatedTarget: _relatedTarget })

    this.$element.trigger(e)
Severity: Minor
Found in crowbar_framework/vendor/assets/javascripts/bootstrap/modal.js - About 1 hr to fix

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

                case 35: if (event.ctrlKey || event.metaKey) {
                            $.datepicker._clearDate(event.target);
                        }
                        handled = event.ctrlKey || event.metaKey;
                        break; // clear on ctrl or command +end
Severity: Major
Found in crowbar_framework/vendor/assets/javascripts/jquery/ui.js and 1 other location - About 1 hr to fix
crowbar_framework/vendor/assets/javascripts/jquery/ui.js on lines 7387..7391

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

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

        top: function() {
            $.ui.position.flip.top.apply( this, arguments );
            $.ui.position.fit.top.apply( this, arguments );
        }
Severity: Major
Found in crowbar_framework/vendor/assets/javascripts/jquery/ui.js and 1 other location - About 1 hr to fix
crowbar_framework/vendor/assets/javascripts/jquery/ui.js on lines 1419..1422

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

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

        left: function() {
            $.ui.position.flip.left.apply( this, arguments );
            $.ui.position.fit.left.apply( this, arguments );
        },
Severity: Major
Found in crowbar_framework/vendor/assets/javascripts/jquery/ui.js and 1 other location - About 1 hr to fix
crowbar_framework/vendor/assets/javascripts/jquery/ui.js on lines 1423..1426

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

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

                case 36: if (event.ctrlKey || event.metaKey) {
                            $.datepicker._gotoToday(event.target);
                        }
                        handled = event.ctrlKey || event.metaKey;
                        break; // current on ctrl or command +home
Severity: Major
Found in crowbar_framework/vendor/assets/javascripts/jquery/ui.js and 1 other location - About 1 hr to fix
crowbar_framework/vendor/assets/javascripts/jquery/ui.js on lines 7382..7386

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

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

def list
  struct = get_json("/")

  if struct[1] != 200
    ["Failed to talk to service list: #{struct[1]}: #{struct[0]}", 1]
Severity: Major
Found in bin/barclamp_lib.rb and 1 other location - About 1 hr to fix
bin/barclamp_lib.rb on lines 269..283

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

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

def proposal_list
  struct = get_json("/proposals/")

  if struct[1] != 200
    ["Failed to talk to service proposal list: #{struct[1]}: #{struct[0]}", 1]
Severity: Major
Found in bin/barclamp_lib.rb and 1 other location - About 1 hr to fix
bin/barclamp_lib.rb on lines 213..227

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

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