ClusterLabs/hawk

View on GitHub

Showing 2,376 of 2,376 total issues

Method shell_syntax has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring.
Open

  def shell_syntax
    [].tap do |cmd|

      cmd.push "colocation #{@id} #{@score}:"

Severity: Minor
Found in hawk/app/models/colocation.rb - About 4 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 merge_operations has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring.
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 - About 4 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 nodes.js has 371 lines of code (exceeds 250 allowed). Consider refactoring.
Open

// Copyright (c) 2009-2015 Tim Serong <tserong@suse.com>
// See COPYING for license.

$(function() {
  var rowStyleFn = function(row, index) {
Severity: Minor
Found in hawk/app/assets/javascripts/module/nodes.js - About 4 hrs to fix

    File reports_controller.rb has 371 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    class ReportsController < ApplicationController
      before_action :login_required
      before_action :set_title
      before_action :set_record, only: [:show, :destroy, :download, :cache]
      before_action :set_transition, only: [:display, :detail, :graph, :logs, :diff, :pefile, :status, :cib]
    Severity: Minor
    Found in hawk/app/controllers/reports_controller.rb - About 4 hrs to fix

      Method has too many lines. [57/30]
      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 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 submit is too high. [42.68/15]
      Open

        def submit
          pa = JSON.parse(params[:pa]) if params[:pa]
          pa = Rails.cache.read("#{session.id}-#{params[:id]}") if pa.nil?
      
          if pa.nil?

      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 sort_ops is too high. [42/15]
      Open

        def sort_ops(a, b)
          a_op = a.attributes['operation']
          b_op = b.attributes['operation']
          a_call_id = a.attributes['call-id'].to_i
          b_call_id = b.attributes['call-id'].to_i
      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

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

          unhighlight: function(element, errorClass, validClass) {
            if (element.type === "radio") {
              this.findByName(element.name).removeClass(errorClass).addClass(validClass);
            } else {
              $(element)
      Severity: Major
      Found in hawk/app/assets/javascripts/module/forms.js and 1 other location - About 4 hrs to fix
      hawk/app/assets/javascripts/module/forms.js on lines 43..58

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

      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

          highlight: function(element, errorClass, validClass) {
            if (element.type === "radio") {
              this.findByName(element.name).addClass(errorClass).removeClass(validClass);
            } else {
              $(element)
      Severity: Major
      Found in hawk/app/assets/javascripts/module/forms.js and 1 other location - About 4 hrs to fix
      hawk/app/assets/javascripts/module/forms.js on lines 59..74

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

      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

      Assignment Branch Condition size for simple? is too high. [41.98/15]
      Open

        def simple?
          rules.none? ||
            rules.length == 1 &&
            rules[0][:expressions] &&
            rules[0][:expressions].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

      Assignment Branch Condition size for select is too high. [41.1/15]
      Open

          def select(field, choices = nil, args = {}, html = {})
            unless options.fetch(:bootstrap, true)
              return super
            end
      
      
      Severity: Minor
      Found in hawk/app/lib/hawk/form_builder.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 persist! has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
      Open

        def persist!
          writer = {
            crm_config: {},
            rsc_defaults: {},
            op_defaults: {},
      Severity: Minor
      Found in hawk/app/models/crm_config.rb - About 4 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 fix_clone_instances has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
      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 - About 4 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 has too many lines. [55/30]
      Open

          def mapping
            # TODO(must): Are other meta attributes for clone valid?
            @mapping ||= begin
              {
                "is-managed" => {
      Severity: Minor
      Found in hawk/app/models/clone.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 merge_nvpairs is too high. [40.5/15]
      Open

        def merge_nvpairs(list, attrs)
          return if xml.nil?
          if attrs.empty?
            # No attributes to set, get rid of the list (if it exists)
            xml.elements[list].remove if xml.elements[list]
      Severity: Minor
      Found in hawk/app/models/node.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_nvpairs is too high. [40.36/15]
      Open

        def merge_nvpairs(list, attrs)
          if attrs.empty?
            # No attributes to set, get rid of the list (if it exists)
            xml.elements[list].remove if xml.elements[list]
          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

      Assignment Branch Condition size for has_feature? is too high. [40.84/15]
      Open

        def has_feature?(feature)
          case feature
          when :crm_history
            Rails.cache.fetch(:has_crm_history) {
              Util.safe_x('echo', 'quit', '|', '/usr/sbin/crm history', '2>&1')
      Severity: Minor
      Found in hawk/app/lib/util.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

      File oplist.js has 356 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      // Copyright (c) 2009-2015 Tim Serong <tserong@suse.com>
      // See COPYING for license.
      
      // ops and values is:
      //
      Severity: Minor
      Found in hawk/app/assets/javascripts/module/oplist.js - About 4 hrs to fix

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

            def instantiate(xml, state)
              record = allocate
              record.id = state[:id]
              record.xml = xml
              record.name = state[:name]
        Severity: Minor
        Found in hawk/app/models/node.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 update_name is too high. [39.1/15]
        Open

          def update_name
            from = params[:id]
            to = params[:to]
            @source = params[:source] || "edit"
            @resource = Resource.find from

        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