ClusterLabs/hawk

View on GitHub

Showing 340 of 2,379 total issues

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

    Function statusCircle has 58 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      $.fn.statusCircle = function(status, tooltip) {
        if (tooltip === undefined) {
          if (status == "ok") {
            tooltip = __("OK");
          } else if (status == "maintenance") {
    Severity: Major
    Found in hawk/app/assets/javascripts/module/basics.js - About 2 hrs to fix

      Function StatusCheck has 58 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        function StatusCheck(el, options) {
          this.$el = $(el);
      
          this.defaults = {
            content: this.$el.data('content'),
      Severity: Major
      Found in hawk/app/assets/javascripts/module/status.js - About 2 hrs to fix

        Method edit has 58 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def edit
            if request.post?
              fencing = params[:fencing]
              fencing = fencing["fencing"] if fencing.is_a? Hash
              fencing = [] if fencing.nil?
        Severity: Major
        Found in hawk/app/controllers/fencing_controller.rb - About 2 hrs to fix

          Method persist! has 57 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            def persist!
              writer = {
                crm_config: {},
                rsc_defaults: {},
                op_defaults: {},
          Severity: Major
          Found in hawk/app/models/crm_config.rb - About 2 hrs to fix

            File form_builder.rb has 261 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            module Hawk
              class FormBuilder < ActionView::Helpers::FormBuilder
                def fields_for(record_name, record_object = nil, args = {}, &block)
                  unless options.fetch(:bootstrap, true)
                    return super
            Severity: Minor
            Found in hawk/app/lib/hawk/form_builder.rb - About 2 hrs to fix

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

                def shell_syntax
                  [].tap do |cmd|
                    cmd.push "rsc_ticket #{id} #{ticket}:"
              
                    Util.map_value(resources).each do |set|
              Severity: Minor
              Found in hawk/app/models/ticket.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 merge_nvpairs has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
              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 - 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 mapping has 55 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/clone.rb - About 2 hrs to fix

                File report.rb has 258 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

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

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

                      basicCreateBody: function() {
                          var s_hostname = __('Hostname');
                          var s_username = __('Username');
                          var s_password = __('Password');
                          var s_connect = __('Connect');
                  Severity: Major
                  Found in hawk/app/assets/javascripts/module/statustable.js - About 2 hrs to fix

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

                      MonitorCheck.prototype.processCheck = function() {
                        var self = this;
                    
                        $('.circle').statusCircleFromCIB();
                    
                    
                    Severity: Major
                    Found in hawk/app/assets/javascripts/module/monitor.js - About 2 hrs to fix

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

                          def instantiate(xml, state)
                            record = allocate
                            record.id = state[:id]
                            record.xml = xml
                            record.name = state[:name]
                      Severity: Major
                      Found in hawk/app/models/node.rb - About 2 hrs to fix

                        File basics.js has 256 lines of code (exceeds 250 allowed). Consider refactoring.
                        Open

                        // Copyright (c) 2009-2015 Tim Serong <tserong@suse.com>
                        // See COPYING for license.
                        
                        $(function() {
                          window.userIsNavigatingAway = false;
                        Severity: Minor
                        Found in hawk/app/assets/javascripts/module/basics.js - About 2 hrs to fix

                          File recipientlist.js has 255 lines of code (exceeds 250 allowed). Consider refactoring.
                          Open

                          // Copyright (c) 2016 Kristoffer Gronlund <kgronlund@suse.com>
                          // See COPYING for license.
                          
                          ;(function($) {
                            'use strict';
                          Severity: Minor
                          Found in hawk/app/assets/javascripts/module/recipientlist.js - About 2 hrs to fix

                            File application_helper.rb has 254 lines of code (exceeds 250 allowed). Consider refactoring.
                            Open

                            module ApplicationHelper
                              def branding_config
                                @branding_config ||= begin
                                  config = YAML.load_file(
                                    Rails.root.join(
                            Severity: Minor
                            Found in hawk/app/helpers/application_helper.rb - About 2 hrs to fix

                              Method merge_nvpairs has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
                              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 - 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 transitions has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
                              Open

                                def transitions(hb_report)
                                  # TODO(fix this)
                                  # Have to blow this away if it exists (i.e. is a cached report), else
                                  # prior cibadmin calls on individual PE inputs will have wrecked their mtimes.
                                  # FileUtils.remove_entry_secure(hb_report.path) if File.exist?(hb_report.path)
                              Severity: Minor
                              Found in hawk/app/models/report.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 show has 50 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                def show
                                  respond_to do |format|
                                    format.html do
                                      cmd = "show"
                                      cmd = "show xml" if params[:xml] == "true"
                              Severity: Minor
                              Found in hawk/app/controllers/configs_controller.rb - About 2 hrs to fix

                                Method result has 49 lines of code (exceeds 25 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 1 hr to fix
                                  Severity
                                  Category
                                  Status
                                  Source
                                  Language