ClusterLabs/hawk

View on GitHub

Showing 337 of 2,376 total issues

Method get_resource has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
Open

  def get_resource(elem, is_managed = true, maintenance = false, clone_max = nil, is_ms = false)
    res = {
      id: elem.attributes['id'],
      object_type: elem.name,
      attributes: {},
Severity: Minor
Found in hawk/app/models/cib.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 instantiate has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
Open

    def instantiate(xml)
      record = allocate

      record.resources = [].tap do |resources|
        if xml.attributes["rsc"]
Severity: Minor
Found in hawk/app/models/location.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 graph has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
Open

  def graph
    respond_to do |format|
      format.html do
        render layout: false
      end
Severity: Minor
Found in hawk/app/controllers/reports_controller.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 update_resource_state has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
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 - 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

Class ApplicationController has 25 methods (exceeds 20 allowed). Consider refactoring.
Open

class ApplicationController < ActionController::Base
  include FastGettext::Translation

  protect_from_forgery with: :exception
  helper :all
Severity: Minor
Found in hawk/app/controllers/application_controller.rb - About 2 hrs to fix

    Method mapping has 69 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

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

      Method create has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
      Open

        def create
          normalize_params! params[:primitive].permit!
          @title = _("Create Primitive")
      
          @primitive = Primitive.new params[:primitive].permit!
      Severity: Minor
      Found in hawk/app/controllers/primitives_controller.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 result has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
      Open

        def result
          case params[:file]
          when "info"
            send_data File.new("#{Rails.root}/tmp/sim.info").read,
                      type: "text/plain", disposition: :inline
      Severity: Minor
      Found in hawk/app/controllers/simulator_controller.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 installed_docs has 67 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def installed_docs
          [
            {
              title: "SLE HA Administration Guide",
              html: docs_path.join(
      Severity: Major
      Found in hawk/app/helpers/application_helper.rb - About 2 hrs to fix

        Class Report has 24 methods (exceeds 20 allowed). Consider refactoring.
        Open

        class Report
          attr_accessor :id
          attr_accessor :name
          attr_accessor :archive
          attr_accessor :from_time
        Severity: Minor
        Found in hawk/app/models/report.rb - About 2 hrs to fix

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

            def ops
              invars = params[:id].split(",", 2)
              if invars.length == 1
                rsc = invars[0]
                node = "*"
          Severity: Minor
          Found in hawk/app/controllers/cib_controller.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

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

                    formatter: function(value, row, index) {
                      var operations = [];
                      var dropdowns = [];
          
                      var add_operation = function(dest, path, path_class, icon_class, text) {
          Severity: Major
          Found in hawk/app/assets/javascripts/module/nodes.js - About 2 hrs to fix

            File tickets.js has 270 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            // Copyright (c) 2009-2015 Tim Serong <tserong@suse.com>
            // See COPYING for license.
            
            $(function() {
              $('#tickets #middle table.tickets')
            Severity: Minor
            Found in hawk/app/assets/javascripts/module/tickets.js - About 2 hrs to fix

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

                rulesList.prototype.init = function() {
                  var self = this;
              
                  var content = {
                    prefix: self.prefixes,
              Severity: Major
              Found in hawk/app/assets/javascripts/module/location.js - About 2 hrs to fix

                Method instantiate has 62 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    def instantiate(xml)
                      record = allocate
                
                      record.resources = [].tap do |resources|
                        if xml.attributes["rsc"]
                Severity: Major
                Found in hawk/app/models/location.rb - About 2 hrs to fix

                  Method select has 62 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      def select(field, choices = nil, args = {}, html = {})
                        unless options.fetch(:bootstrap, true)
                          return super
                        end
                  
                  
                  Severity: Major
                  Found in hawk/app/lib/hawk/form_builder.rb - About 2 hrs to fix

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

                      def shell_syntax
                        [].tap do |cmd|
                          cmd.push "order #{id} #{score}:"
                    
                          resources.each do |set|
                    Severity: Minor
                    Found in hawk/app/models/order.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 run has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
                    Open

                      def run(params, rootpw=nil)
                        # TODO: live-update frontend
                        @params = params
                        @actions = []
                        @errors = []
                    Severity: Minor
                    Found in hawk/app/models/wizard.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 run has 59 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      def run
                        if current_cib.id == "live"
                          head :bad_request
                          return
                        end
                    Severity: Major
                    Found in hawk/app/controllers/simulator_controller.rb - About 2 hrs to fix

                      Class ResourcesController has 22 methods (exceeds 20 allowed). Consider refactoring.
                      Open

                      class ResourcesController < ApplicationController
                        before_action :login_required
                        before_action :set_title
                        before_action :set_cib
                      
                      
                      Severity: Minor
                      Found in hawk/app/controllers/resources_controller.rb - About 2 hrs to fix
                        Severity
                        Category
                        Status
                        Source
                        Language