crowbar/crowbar-core

View on GitHub

Showing 6,062 of 6,062 total issues

Function sparkline has 66 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    $.fn.sparkline = function (userValues, userOptions) {
      return this.each(function () {
        var options = new $.fn.sparkline.options(this, userOptions),
          $this = $(this),
          render, i;
Severity: Major
Found in crowbar_framework/vendor/assets/javascripts/jquery/sparkline.js - About 2 hrs to fix

File role_object.rb has 275 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require "ostruct"

class RoleObject < ChefObject
  self.chef_type = "role"

Severity: Minor
Found in crowbar_framework/app/models/role_object.rb - About 2 hrs to fix

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

            this.element.siblings( ":visible" ).each(function() {
                var elem = $( this ),
                    position = elem.css( "position" );

                if ( position === "absolute" || position === "fixed" ) {
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 11987..11995

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

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

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

            this.element.siblings( ":visible" ).each(function() {
                var elem = $( this ),
                    position = elem.css( "position" );

                if ( position === "absolute" || position === "fixed" ) {
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 5566..5574

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

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

Method node_architectures has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
Open

      def node_architectures
        {}.tap do |ret|
          ::Node.all.each do |node|
            arch = node.architecture
            ret["os"] ||= []
Severity: Minor
Found in crowbar_framework/app/models/api/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 application.js has 274 lines of code (exceeds 250 allowed). Consider refactoring.
Open

//= require_self

jQuery(document).ready(function($) {
  $('textarea.editor').each(function() {
    var cm = CodeMirror.fromTextArea(this, {
Severity: Minor
Found in crowbar_framework/app/assets/javascripts/application.js - About 2 hrs to fix

File ip.rb has 274 lines of code (exceeds 250 allowed). Consider refactoring.
Open

class IP
  include Comparable
  protected

  # Translate a CIDR subnet specification into a bitfield
Severity: Minor
Found in chef/cookbooks/barclamp/libraries/ip.rb - About 2 hrs to fix

Function template has 64 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  function template(templateSpec, env) {
    if (!env) {
      throw new Error("No environment passed to template");
    }

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

Function bounce has 64 lines of code (exceeds 25 allowed). Consider refactoring.
Open

$.effects.effect.bounce = function( o, done ) {
    var el = $( this ),
        props = [ "position", "top", "bottom", "left", "right", "height", "width" ],

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

Method make_zone has 64 lines of code (exceeds 25 allowed). Consider refactoring.
Open

def make_zone(zone)
  # copy over SOA records that we have not overridden
  populate_soa zone
  zonefile_entries=Array.new
  Chef::Log.debug "Processing zone: #{zone.inspect}"
Severity: Major
Found in chef/cookbooks/bind9/recipes/default.rb - About 2 hrs to fix

Method switch has 64 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def switch
    @port_start = 1
    @sum = 0
    @vports = {}
    @groups = {}
Severity: Major
Found in crowbar_framework/app/controllers/network_controller.rb - About 2 hrs to fix

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

        vel = '<v:shape coordorigin="0 0" coordsize="' + this.pixelWidth + ' ' + this.pixelHeight + '" ' +
          ' id="jqsshape' + shapeid + '" ' +
          stroke +
          fill +
          ' style="position:absolute;left:0px;top:0px;height:' + this.pixelHeight + 'px;width:' + this.pixelWidth + 'px;padding:0px;margin:0px;" ' +
crowbar_framework/vendor/assets/javascripts/jquery/sparkline.js on lines 2922..2927

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

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

        vel = '<v:shape coordorigin="0 0" coordsize="' + this.pixelWidth + ' ' + this.pixelHeight + '" ' +
          ' id="jqsshape' + shapeid + '" ' +
          stroke +
          fill +
          ' style="position:absolute;left:0px;top:0px;height:' + this.pixelHeight + 'px;width:' + this.pixelWidth + 'px;padding:0px;margin:0px;" ' +
crowbar_framework/vendor/assets/javascripts/jquery/sparkline.js on lines 2979..2984

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

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

Function updateLinesNoUndo has 63 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    function updateLinesNoUndo(from, to, newText, selFrom, selTo) {
      var recomputeMaxLength = false, maxLineLength = maxLine.length;
      for (var i = from.line; i <= to.line; ++i) {
        if (lines[i].text.length == maxLineLength) {recomputeMaxLength = true; break;}
      }
Severity: Major
Found in crowbar_framework/vendor/assets/javascripts/codemirror/codemirror.js - About 2 hrs to fix

Function SearchCursor has 63 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    function SearchCursor(query, pos, caseFold) {
      this.atOccurrence = false;
      if (caseFold == null) caseFold = typeof query == "string" && query == query.toLowerCase();

      if (pos && typeof pos == "object") pos = clipPos(pos);
Severity: Major
Found in crowbar_framework/vendor/assets/javascripts/codemirror/codemirror.js - About 2 hrs to fix

Function getHTML has 63 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    getHTML: function(sfrom, sto, includePre, endAt) {
      var html = [];
      if (includePre)
        html.push(this.className ? '<pre class="' + this.className + '">': "<pre>");
      function span(text, style) {
Severity: Major
Found in crowbar_framework/vendor/assets/javascripts/codemirror/codemirror.js - About 2 hrs to fix

Method node_role_list has 63 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def node_role_list(node)
    all_roles     = RoleObject.all
    all_proposals = Proposal.all

    list_items = ActiveSupport::OrderedHash.new.tap do |listing|
Severity: Major
Found in crowbar_framework/app/helpers/nodes_helper.rb - About 2 hrs to fix

File service_object_spec.rb has 271 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require "spec_helper"

describe ServiceObject do
  let(:service_object) { so = ServiceObject.new(Logger.new("/dev/null")); so.bc_name = "crowbar"; so }
  let(:proposal) { Proposal.where(barclamp: "crowbar", name:"default").first_or_create(barclamp: "crowbar", name: "default") }
Severity: Minor
Found in crowbar_framework/spec/models/service_object_spec.rb - About 2 hrs to fix

Class UcsController has 23 methods (exceeds 20 allowed). Consider refactoring.
Open

class UcsController < ApplicationController
  CREDENTIALS_XML_PATH = "/etc/crowbar/cisco-ucs/credentials.xml"
  COMPUTE_SERVICE_PROFILE = "suse-cloud-compute"
  STORAGE_SERVICE_PROFILE = "suse-cloud-storage"

Severity: Minor
Found in crowbar_framework/app/controllers/ucs_controller.rb - About 2 hrs to fix

Class Upload has 23 methods (exceeds 20 allowed). Consider refactoring.
Open

    class Upload

      def initialize
        @checked_dependencies = Array.new
      end
Severity: Minor
Found in crowbar_framework/lib/crowbar/chef/upload.rb - About 2 hrs to fix
Severity
Category
Status
Source
Language