ClusterLabs/hawk

View on GitHub

Showing 2,376 of 2,376 total issues

Assignment Branch Condition size for shell_syntax is too high. [64.41/15]
Open

  def shell_syntax
    [].tap do |cmd|
      cmd.push "location #{id}"

      if resources.length == 1
Severity: Minor
Found in hawk/app/models/location.rb by rubocop

This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

Method has too many lines. [79/30]
Open

    def instantiate(xml)
      record = allocate
      record.clazz = xml.attributes["class"] || ""
      record.provider = xml.attributes["provider"] || ""
      record.type = xml.attributes["type"] || ""
Severity: Minor
Found in hawk/app/models/template.rb by rubocop

This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

Assignment Branch Condition size for fix_clone_instances is too high. [63.45/15]
Open

  def fix_clone_instances(rsclist)
    rsclist.each do |res|
      if res[:clone_max]
        # There'll be a stale default instance lying around if the resource was
        # started before it was cloned (bnc#711180), so ditch it.  This is all
Severity: Minor
Found in hawk/app/models/cib.rb by rubocop

This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

Assignment Branch Condition size for instantiate is too high. [61.04/15]
Open

    def instantiate(xml)
      record = allocate

      record.resources = [].tap do |resources|
        if xml.attributes["rsc"]
Severity: Minor
Found in hawk/app/models/location.rb by rubocop

This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

Assignment Branch Condition size for instantiate is too high. [60.21/15]
Open

    def instantiate(xml)
      record = allocate
      record.id = xml.attributes["id"] || ""
      record.path = xml.attributes["path"] || ""

Severity: Minor
Found in hawk/app/models/alert.rb by rubocop

This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

Assignment Branch Condition size for merge_operations is too high. [60.32/15]
Open

  def merge_operations(attrs)
    if attrs.empty?
      # No operations to set, get rid of the list (if it exists)
      xml.elements['operations'].remove if xml.elements['operations']
    else
Severity: Minor
Found in hawk/app/models/record.rb by rubocop

This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

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

        $.ajax({
          url: target.data('url'),
          success: function(data) {
            if (data) {
              if (!target.hasClass("loaded")) {
Severity: Major
Found in hawk/app/assets/javascripts/module/reports.js and 1 other location - About 6 hrs to fix
hawk/app/assets/javascripts/module/reports.js on lines 541..563

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

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

      $.ajax({
        url: target.data('url'),
        success: function(data) {
          if (data) {
            if (!target.hasClass("loaded")) {
Severity: Major
Found in hawk/app/assets/javascripts/module/reports.js and 1 other location - About 6 hrs to fix
hawk/app/assets/javascripts/module/reports.js on lines 500..521

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

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

  def fix_resource_states(rsclist)
    prio = {
      unknown: 0,
      stopped: 1,
      started: 2,
Severity: Minor
Found in hawk/app/models/cib.rb - About 6 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

Assignment Branch Condition size for rsc_state_from_lrm_rsc_op is too high. [57.91/15]
Open

  def rsc_state_from_lrm_rsc_op(xml, node_uname, rsc_id)
    xml.elements.each("cib/status/node_state[@uname='#{node_uname}']/lrm/lrm_resources/lrm_resource[@id='#{rsc_id}']") do |lrm_resource|
      # logic derived somewhat from pacemaker/lib/pengine/unpack.c:unpack_rsc_op()
      state = :unknown
      ops = []
Severity: Minor
Found in hawk/app/lib/cibtools.rb by rubocop

This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

Function build_tabs has 163 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  var build_tabs = function() {
    $('#reports #report-running').addClass('hidden');
    $('#reports #report-tabs').removeClass('hidden');

    var controls = $("#reports #report-controls");
Severity: Major
Found in hawk/app/assets/javascripts/module/reports.js - About 6 hrs to fix

    Assignment Branch Condition size for set_shadow_cib is too high. [56.54/15]
    Open

      def set_shadow_cib
        if !current_cib || current_cib.live?
          ENV.delete("CIB_shadow")
          return
        end

    This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

    Assignment Branch Condition size for persist! is too high. [55.87/15]
    Open

      def persist!
        writer = {
          crm_config: {},
          rsc_defaults: {},
          op_defaults: {},
    Severity: Minor
    Found in hawk/app/models/crm_config.rb by rubocop

    This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

    Assignment Branch Condition size for fix_resource_states is too high. [55.24/15]
    Open

      def fix_resource_states(rsclist)
        prio = {
          unknown: 0,
          stopped: 1,
          started: 2,
    Severity: Minor
    Found in hawk/app/models/cib.rb by rubocop

    This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

    Method has too many lines. [69/30]
    Open

        def mapping
          # TODO(must): Are other meta attributes for clone valid?
          @mapping ||= begin
            {
              "is-managed" => {
    Severity: Minor
    Found in hawk/app/models/master.rb by rubocop

    This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

    Assignment Branch Condition size for shell_syntax is too high. [53.91/15]
    Open

      def shell_syntax
        [].tap do |cmd|
    
          cmd.push "colocation #{@id} #{@score}:"
    
    
    Severity: Minor
    Found in hawk/app/models/colocation.rb by rubocop

    This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

    Assignment Branch Condition size for result is too high. [53.24/15]
    Open

      def result
        case params[:file]
        when "info"
          send_data File.new("#{Rails.root}/tmp/sim.info").read,
                    type: "text/plain", disposition: :inline

    This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

    Method has too many lines. [67/30]
    Open

      def installed_docs
        [
          {
            title: "SLE HA Administration Guide",
            html: docs_path.join(

    This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

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

      RecipientList.prototype.init = function() {
        var self = this;
    
        var content = {
          labels: self.options.labels,
    Severity: Major
    Found in hawk/app/assets/javascripts/module/recipientlist.js - About 5 hrs to fix

      Assignment Branch Condition size for ops is too high. [51.58/15]
      Open

        def ops
          invars = params[:id].split(",", 2)
          if invars.length == 1
            rsc = invars[0]
            node = "*"

      This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

      Severity
      Category
      Status
      Source
      Language