crowbar/crowbar-core

View on GitHub

Showing 6,062 of 6,062 total issues

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

        getLayoutTemplate: function (t) {
            var self = this,
                template = isSet(t, self.layoutTemplates) ? self.layoutTemplates[t] : defaultLayoutTemplates[t];
            if (isEmpty(self.customLayoutTags)) {
                return template;
crowbar_framework/vendor/assets/javascripts/bootstrap/fileinput.js on lines 693..700

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

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

function ajaxConvert( s, response, jqXHR, isSuccess ) {
    var conv2, current, conv, tmp, prev,
        converters = {},
        // Work with a copy of dataTypes in case we need to modify it for conversion
        dataTypes = s.dataTypes.slice();
Severity: Major
Found in crowbar_framework/vendor/assets/javascripts/jquery/jquery.js - About 2 hrs to fix

Function _generateMonthYearHeader has 56 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    _generateMonthYearHeader: function(inst, drawMonth, drawYear, minDate, maxDate,
            secondary, monthNames, monthNamesShort) {

        var inMinYear, inMaxYear, month, years, thisYear, determineYear, year, endYear,
            changeMonth = this._get(inst, "changeMonth"),
Severity: Major
Found in crowbar_framework/vendor/assets/javascripts/jquery/ui.js - About 2 hrs to fix

Function createWrapper has 56 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    createWrapper: function( element ) {

        // if the element is already wrapped, return it
        if ( element.parent().is( ".ui-effects-wrapper" )) {
            return element.parent();
Severity: Major
Found in crowbar_framework/vendor/assets/javascripts/jquery/ui.js - About 2 hrs to fix

Function renderRegion has 56 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      renderRegion: function (valuenum, highlight) {
        var vals = this.values[valuenum],
          options = this.options,
          xaxisOffset = this.xaxisOffset,
          result = [],
Severity: Major
Found in crowbar_framework/vendor/assets/javascripts/jquery/sparkline.js - About 2 hrs to fix

Function _mouseStart has 54 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    _mouseStart: function(event) {
        var that = this,
            options = this.options;

        this.opos = [event.pageX, event.pageY];
Severity: Major
Found in crowbar_framework/vendor/assets/javascripts/jquery/ui.js - About 2 hrs to fix

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

  Tooltip.prototype.show = function () {
    var e = $.Event('show.bs.' + this.type)

    if (this.hasContent() && this.enabled) {
      this.$element.trigger(e)
Severity: Major
Found in crowbar_framework/vendor/assets/javascripts/bootstrap/tooltip.js - About 2 hrs to fix

Method apply_role_pre_chef_call has 54 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def apply_role_pre_chef_call(old_role, role, all_nodes)
    Rails.logger.debug("DNS apply_role_pre_chef_call: entering #{all_nodes.inspect}")
    return if all_nodes.empty?

    tnodes = role.override_attributes["dns"]["elements"]["dns-server"]
Severity: Major
Found in crowbar_framework/app/models/dns_service.rb - About 2 hrs to fix

Method evacuate_network_node has 54 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def evacuate_network_node(controller, network_node, delete_namespaces = false)
        save_node_action("evacuating dhcp networks")
        hostname = network_node["hostname"]
        migrated_file = "/var/lib/crowbar/upgrade/crowbar-network-evacuated"
        if network_node.file_exist? migrated_file
Severity: Major
Found in crowbar_framework/app/models/api/upgrade.rb - About 2 hrs to fix

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

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

    # discovering because mandatory for discovery image
    if ["discovering", "readying"].include? state
Severity: Major
Found in crowbar_framework/app/models/ipmi_service.rb - About 2 hrs to fix

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

        if (this.values[0] !== null) {
          shape = this.renderTarget().append();
          this.shapes[shape.id] = 't0';
          this.valueShapes.t0 = shape.id;
        }
crowbar_framework/vendor/assets/javascripts/jquery/sparkline.js on lines 2237..2241

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

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 (this.values[1] !== null) {
          shape = this.renderPerformance().append();
          this.shapes[shape.id] = 'p1';
          this.valueShapes.p1 = shape.id;
        }
crowbar_framework/vendor/assets/javascripts/jquery/sparkline.js on lines 2242..2246

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

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

    parse: function( red, green, blue, alpha ) {
        if ( red === undefined ) {
            this._rgba = [ null, null, null, null ];
            return this;
        }
Severity: Major
Found in crowbar_framework/vendor/assets/javascripts/jquery/ui.js - About 2 hrs to fix

Method canonical_address has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

    def canonical_address
      f = 0
      in_run = false
      runs = Array.new
      a = self.to_a
Severity: Minor
Found in chef/cookbooks/barclamp/libraries/ip.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 validate_proposal_after_save has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

  def validate_proposal_after_save proposal
    require "set"

    proposal["attributes"]["provisioner"]["packages"].each do |platform, packages|
      packages.each do |package|
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 openstackbackup has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

      def openstackbackup
        crowbar_lib_dir = "/var/lib/crowbar"
        dump_path = "#{crowbar_lib_dir}/backup/8-to-9-openstack_dump.sql.gz"
        if File.exist?(dump_path)
          Rails.logger.warn("OpenStack backup already exists. Skipping...")
Severity: Minor
Found in crowbar_framework/app/models/api/upgrade.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 interface_list has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

  def interface_list
    return [] if @node.nil?
    answer = []
    @node["network"]["interfaces"].each do |k,v|
      next if k == "lo"     # no loopback, please
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

Method add_pending_elements has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

    def add_pending_elements(bc, inst, element_order, elements, queue_me, pre_cached_nodes = {})
      nodes_map, pre_cached_nodes = elements_to_nodes_to_roles_map(
        elements, element_order, pre_cached_nodes
      )

Severity: Minor
Found in crowbar_framework/lib/crowbar/deployment_queue.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 elements_to_nodes_to_roles_map has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

    def elements_to_nodes_to_roles_map(elements, element_order = [], pre_cached_nodes = {})
      nodes_map = {}
      active_elements = element_order.flatten

      elements.each do |role_name, nodes|
Severity: Minor
Found in crowbar_framework/lib/crowbar/deployment_queue.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

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

  describe "POST rename" do
    context "for existent node" do
      it "renames a node to tester" do
        expect_any_instance_of(Node).to receive(:alias=).with("tester")

crowbar_framework/spec/controllers/machines_controller_spec.rb on lines 124..145

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

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