ClusterLabs/hawk

View on GitHub

Showing 2,379 of 2,379 total issues

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

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"
    @constraint = Constraint.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

File util.rb has 352 lines of code (exceeds 250 allowed). Consider refactoring.
Open

module Util

  # From http://mentalized.net/journal/2011/04/14/ruby_how_to_check_if_a_string_is_numeric/
  def numeric?(n)
    Float(n) != nil rescue false
Severity: Minor
Found in hawk/app/lib/util.rb - About 4 hrs to fix

    Method check_drbd_status has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
    Open

      def check_drbd_status
        # if there are any running drbd resources on this node and a drbdadm command,
        # check drbdadm status
        # do we need sudo to do it?
        me = Socket.gethostname
    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

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

                    tag.find("button.btn").click(function() {
                        var username = tag.find("input[name=username]").val();
                        var password = tag.find("input[name=password]").val();
                        tag.find('.btn-success').attr('disabled', true);
                        tag.find('input').attr('disabled', true);
    Severity: Major
    Found in hawk/app/assets/javascripts/module/statustable.js and 1 other location - About 4 hrs to fix
    hawk/app/assets/javascripts/module/statustable.js on lines 364..372

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

    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

                        btn.click(function() {
                            var username = tag_body.find("input[name=username]").val();
                            var password = tag_body.find("input[name=password]").val();
                            tag_body.find('.btn-success').attr('disabled', true);
                            tag_body.find('input').attr('disabled', true);
    Severity: Major
    Found in hawk/app/assets/javascripts/module/statustable.js and 1 other location - About 4 hrs to fix
    hawk/app/assets/javascripts/module/statustable.js on lines 201..209

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

    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

    Class ReportsController has 34 methods (exceeds 20 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

      Function test_check_cluster_configuration has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
      Open

          def test_check_cluster_configuration(self, ssh):
              """
              The test does two things.
              First, it checks that the available resources are correct.
              Second, that the options of select-type resources are correct.
      Severity: Minor
      Found in e2e_test/hawk_test_driver.py - 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

      Function AttrList has 106 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        function AttrList(el, options) {
          this.$el = $(el);
      
          this.values = this.$el.data('attrlist');
      
      
      Severity: Major
      Found in hawk/app/assets/javascripts/module/attrlist.js - About 4 hrs to fix

        Assignment Branch Condition size for create is too high. [37.6/15]
        Open

          def create
            normalize_params! params[:location].permit!
            @title = _('Create Location Constraint')
        
            @location = Location.new params[:location].permit!

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

          def show
            if params[:id].start_with? "@"
              name = params[:id][1..-1]
              template = Hash.from_xml(Util.safe_x("/usr/sbin/cibadmin", "-l", "--query", "--xpath", "//template[@id='#{name}']"))
              Rails.logger.debug "Template: #{template}"

        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

          def update_name
            from = params[:id]
            to = params[:to]
            @source = params[:source] || "edit"
            @resource = Resource.find from
        Severity: Major
        Found in hawk/app/controllers/resources_controller.rb and 1 other location - About 4 hrs to fix
        hawk/app/controllers/constraints_controller.rb on lines 63..100

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

        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 update_name
            from = params[:id]
            to = params[:to]
            @source = params[:source] || "edit"
            @constraint = Constraint.find from
        Severity: Major
        Found in hawk/app/controllers/constraints_controller.rb and 1 other location - About 4 hrs to fix
        hawk/app/controllers/resources_controller.rb on lines 163..200

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

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

          function WizAttrList(el, options) {
            this.$el = $(el);
        
            this.values = this.$el.data('wizattrlist');
            this.targets = this.$el.data('wizattrlist-target');
        Severity: Major
        Found in hawk/app/assets/javascripts/module/wizattrlist.js - About 4 hrs to fix

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

              def instantiate(xml)
                record = allocate
                record.score = xml.attributes["score"] || xml.attributes["kind"] || nil
          
                record.symmetrical = Util.unstring(
          Severity: Minor
          Found in hawk/app/models/order.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

          Perceived complexity for update_resource_state is too high. [27/7]
          Open

            def update_resource_state(resource, node, instance, state, substate, failed_ops)
              # m/s slave state hack (*sigh*)
              state = :slave if resource[:is_ms] && state == :started
              instances = resource[:instances]
          
          
          Severity: Minor
          Found in hawk/app/models/cib.rb by rubocop

          This cop tries to produce a complexity score that's a measure of the complexity the reader experiences when looking at a method. For that reason it considers when nodes as something that doesn't add as much complexity as an if or a &&. Except if it's one of those special case/when constructs where there's no expression after case. Then the cop treats it as an if/elsif/elsif... and lets all the when nodes count. In contrast to the CyclomaticComplexity cop, this cop considers else nodes as adding complexity.

          Example:

          def my_method                   # 1
            if cond                       # 1
              case var                    # 2 (0.8 + 4 * 0.2, rounded)
              when 1 then func_one
              when 2 then func_two
              when 3 then func_three
              when 4..10 then func_other
              end
            else                          # 1
              do_something until a && b   # 2
            end                           # ===
          end                             # 7 complexity points

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

            def show
              respond_to do |format|
                format.html do
                  cmd = "show"
                  cmd = "show xml" if params[:xml] == "true"

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

            def safe_x(*cmd)
              raise SecurityError, "Util::safe_x called with < 2 args" if cmd.length < 2
              Rails.logger.debug "Executing `#{cmd.join(' ')}` through `safe_x`"
          
              pr = IO::pipe   # pipe[0] for read, pipe[1] for write
          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

          Function ConstraintList has 98 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            function ConstraintList(el, options) {
              this.$el = $(el);
          
              this.values = this.$el.data('constraints');
          
          
          Severity: Major
          Found in hawk/app/assets/javascripts/module/constraint.js - About 3 hrs to fix

            Method instantiate has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
            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 - About 3 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

            Severity
            Category
            Status
            Source
            Language