From 1c3381f63858096f2065a7ee51cb3df0c29d541b Mon Sep 17 00:00:00 2001 From: archanaserver Date: Thu, 4 Jan 2024 17:21:12 +0530 Subject: [PATCH] Refs #37926 - Fix rubocop Layout/FirstHashElementIndentation --- .rubocop.yml | 3 ++ app/helpers/layout_helper.rb | 8 ++--- app/helpers/search_bar_helper.rb | 18 +++++----- app/services/power_manager/bmc.rb | 16 ++++----- app/services/power_manager/virt.rb | 14 ++++---- lib/tasks/seed.rake | 8 ++--- .../api/v2/bookmarks_controller_test.rb | 8 ++--- test/models/host_test.rb | 36 +++++++++---------- test/models/operatingsystems/solaris_test.rb | 20 +++++------ .../config_report_status_calculator_test.rb | 16 ++++----- 10 files changed, 75 insertions(+), 72 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 73d1b23e061..9b1850652a6 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -104,3 +104,6 @@ Layout/EmptyLinesAroundAttributeAccessor: Layout/EmptyLineBetweenDefs: Enabled: true + +Layout/FirstHashElementIndentation: + Enabled: false diff --git a/app/helpers/layout_helper.rb b/app/helpers/layout_helper.rb index bea0c3b70b4..50779a1f7bd 100644 --- a/app/helpers/layout_helper.rb +++ b/app/helpers/layout_helper.rb @@ -1,10 +1,10 @@ module LayoutHelper def mount_react_app react_component('ReactApp', { - layout: layout_data, - metadata: app_metadata, - toasts: toast_notifications_data, - }) + layout: layout_data, + metadata: app_metadata, + toasts: toast_notifications_data, + }) end def fetch_menus diff --git a/app/helpers/search_bar_helper.rb b/app/helpers/search_bar_helper.rb index 15500a128b1..5371769d521 100644 --- a/app/helpers/search_bar_helper.rb +++ b/app/helpers/search_bar_helper.rb @@ -7,14 +7,14 @@ def mount_search_bar } url = send("auto_complete_search_#{auto_complete_controller_name}_path") react_component("SearchBar", data: { - controller: auto_complete_controller_name, - autocomplete: { - id: 'searchBar', - searchQuery: params[:search], - url: url, - useKeyShortcuts: true, - }, - bookmarks: bookmarks, - }) + controller: auto_complete_controller_name, + autocomplete: { + id: 'searchBar', + searchQuery: params[:search], + url: url, + useKeyShortcuts: true, + }, + bookmarks: bookmarks, + }) end end diff --git a/app/services/power_manager/bmc.rb b/app/services/power_manager/bmc.rb index e49e44a854e..18a1d2d26c4 100644 --- a/app/services/power_manager/bmc.rb +++ b/app/services/power_manager/bmc.rb @@ -16,14 +16,14 @@ def ready? # TODO: consider moving this to the proxy code, so we can just delegate like as with Virt. def action_map super.deep_merge({ - :start => 'on', - :stop => 'off', - :poweroff => 'off', - :reboot => 'soft', - :reset => 'cycle', - :state => 'status', - :ready? => 'ready?', - }) + :start => 'on', + :stop => 'off', + :poweroff => 'off', + :reboot => 'soft', + :reset => 'cycle', + :state => 'status', + :ready? => 'ready?', + }) end def default_action(action) diff --git a/app/services/power_manager/virt.rb b/app/services/power_manager/virt.rb index 2251f1d717e..04d4f5f6b13 100644 --- a/app/services/power_manager/virt.rb +++ b/app/services/power_manager/virt.rb @@ -35,13 +35,13 @@ def default_action(action) def action_map super.deep_merge({ - :on => 'start', - :off => 'stop', - :soft => 'reboot', - :cycle => 'reset', - :status => {:action => :virt_state, :output => :state_output}, - :state => {:action => :virt_state, :output => :state_output}, - }) + :on => 'start', + :off => 'stop', + :soft => 'reboot', + :cycle => 'reset', + :status => {:action => :virt_state, :output => :state_output}, + :state => {:action => :virt_state, :output => :state_output}, + }) end private diff --git a/lib/tasks/seed.rake b/lib/tasks/seed.rake index df036d24b76..6d7f1d6ec54 100644 --- a/lib/tasks/seed.rake +++ b/lib/tasks/seed.rake @@ -199,10 +199,10 @@ namespace :seed do "A message" end base["logs"].append({ - "log" => { "sources" => { "source" => src }, - "messages" => { "message" => msg }, - "level" => (i.even? ? "notice" : "err") }, - }) + "log" => { "sources" => { "source" => src }, + "messages" => { "message" => msg }, + "level" => (i.even? ? "notice" : "err") }, + }) end base["reporter"] = "ansible" if is_ansible base diff --git a/test/controllers/api/v2/bookmarks_controller_test.rb b/test/controllers/api/v2/bookmarks_controller_test.rb index 6c98b40dd98..ce280c959c1 100644 --- a/test/controllers/api/v2/bookmarks_controller_test.rb +++ b/test/controllers/api/v2/bookmarks_controller_test.rb @@ -7,14 +7,14 @@ class Api::V2::BookmarksControllerTest < ActionController::TestCase } simple_bookmark = bookmark_base.merge({ - :name => "foo-bar", + :name => "foo-bar", :query => "bar", - }) + }) dot_bookmark = bookmark_base.merge({ - :name => "facts.architecture", + :name => "facts.architecture", :query => " facts.architecture = x86_64", - }) + }) context 'index test' do def setup diff --git a/test/models/host_test.rb b/test/models/host_test.rb index 42d6e7d5454..49b5d2a1f9e 100644 --- a/test/models/host_test.rb +++ b/test/models/host_test.rb @@ -1754,13 +1754,13 @@ class HostTest < ActiveSupport::TestCase test "can search hosts by numeric and string facts" do host = FactoryBot.create(:host, :hostname => 'num001.example.com') HostFactImporter.new(host).import_facts({ - :architecture => "x86_64", + :architecture => "x86_64", :interfaces => 'eth0', :operatingsystem => 'RedHat-test', :operatingsystemrelease => '6.2', :memory_mb => "64498", :custom_fact => "find_me", - }) + }) hosts = Host::Managed.search_for("facts.memory_mb > 112889") assert_equal hosts.count, 0 @@ -2641,14 +2641,14 @@ def to_managed! test '#initialize respects primary interface attributes and sets provision to the same if missing' do h = Host.new(:interfaces_attributes => { - '0' => {'_destroy' => '0', - :type => 'Nic::Managed', - :mac => 'ff:ff:ff:aa:aa:aa', - :managed => '1', - :primary => '1', - :provision => '0', - :virtual => '0'}, - }) + '0' => {'_destroy' => '0', + :type => 'Nic::Managed', + :mac => 'ff:ff:ff:aa:aa:aa', + :managed => '1', + :primary => '1', + :provision => '0', + :virtual => '0'}, + }) refute_nil h.primary_interface refute_nil h.provision_interface assert_equal 'ff:ff:ff:aa:aa:aa', h.primary_interface.mac @@ -2657,13 +2657,13 @@ def to_managed! test '#initialize respects primary and provision interface attributes' do h = Host.new(:interfaces_attributes => { - '0' => {'_destroy' => '0', - :type => 'Nic::Managed', - :mac => 'ff:ff:ff:aa:aa:aa', - :managed => '1', - :primary => '1', - :provision => '0', - :virtual => '0'}, + '0' => {'_destroy' => '0', + :type => 'Nic::Managed', + :mac => 'ff:ff:ff:aa:aa:aa', + :managed => '1', + :primary => '1', + :provision => '0', + :virtual => '0'}, '1' => {'_destroy' => '0', :type => 'Nic::Managed', :mac => 'aa:aa:aa:ff:ff:ff', @@ -2671,7 +2671,7 @@ def to_managed! :primary => '0', :provision => '1', :virtual => '0'}, - }) + }) refute_nil h.primary_interface refute_nil h.provision_interface assert_equal 'ff:ff:ff:aa:aa:aa', h.primary_interface.mac diff --git a/test/models/operatingsystems/solaris_test.rb b/test/models/operatingsystems/solaris_test.rb index 76cd9f4a422..a312a88af8e 100644 --- a/test/models/operatingsystems/solaris_test.rb +++ b/test/models/operatingsystems/solaris_test.rb @@ -19,15 +19,15 @@ class SolarisTest < ActiveSupport::TestCase Resolv::DNS.any_instance.stubs(:getaddress).with("brsla01.yourdomain.net").returns("2.3.4.5").once result = h.os.jumpstart_params h, h.model.vendor_class assert_equal({ - :vendor => "", - :install_path => "/vol/solgi_5.10/sol10_hw0910_sparc", - :install_server_ip => "2.3.4.5", - :install_server_name => "brsla01", - :jumpstart_server_path => "2.3.4.5:/vol/jumpstart", - :root_path_name => "/vol/solgi_5.10/sol10_hw0910_sparc/Solaris_10/Tools/Boot", - :root_server_hostname => "brsla01", - :root_server_ip => "2.3.4.5", - :sysid_server_path => "2.3.4.5:/vol/jumpstart/sysidcfg/sysidcfg_primary", - }, result) + :vendor => "", + :install_path => "/vol/solgi_5.10/sol10_hw0910_sparc", + :install_server_ip => "2.3.4.5", + :install_server_name => "brsla01", + :jumpstart_server_path => "2.3.4.5:/vol/jumpstart", + :root_path_name => "/vol/solgi_5.10/sol10_hw0910_sparc/Solaris_10/Tools/Boot", + :root_server_hostname => "brsla01", + :root_server_ip => "2.3.4.5", + :sysid_server_path => "2.3.4.5:/vol/jumpstart/sysidcfg/sysidcfg_primary", + }, result) end end diff --git a/test/unit/config_report_status_calculator_test.rb b/test/unit/config_report_status_calculator_test.rb index 8d17824ea65..92dcde8d94b 100644 --- a/test/unit/config_report_status_calculator_test.rb +++ b/test/unit/config_report_status_calculator_test.rb @@ -13,13 +13,13 @@ class ConfigReportStatusCalculatorTest < ActiveSupport::TestCase test 'it should save metrics as bits in status integers' do r = ConfigReportStatusCalculator.new(:size => 6, :counters => { - 'applied': 1, + 'applied': 1, 'restarted': 2, 'failed': 3, 'failed_restarts': 4, 'skipped': 5, 'pending': 6, - }) + }) assert_equal 1, r.status_of('applied') assert_equal 2, r.status_of('restarted') assert_equal 3, r.status_of('failed') @@ -30,13 +30,13 @@ class ConfigReportStatusCalculatorTest < ActiveSupport::TestCase test 'it should save metrics as bits in status strings' do r = ConfigReportStatusCalculator.new(:size => 6, :counters => { - 'applied': 0, + 'applied': 0, 'restarted': 1, 'failed': 63, 'failed_restarts': 64, 'skipped': 100, 'pending': 200, - }) + }) assert_equal "0", r.status_as_text_of('applied') assert_equal "1", r.status_as_text_of('restarted') assert_equal "63+", r.status_as_text_of('failed') @@ -48,20 +48,20 @@ class ConfigReportStatusCalculatorTest < ActiveSupport::TestCase test 'it should make use of some bits for (the legacy) word size 6' do maximum_value = 63 r = ConfigReportStatusCalculator.new(:size => 6, :counters => { - 'applied': maximum_value, + 'applied': maximum_value, 'restarted': maximum_value, 'failed': maximum_value, 'failed_restarts': maximum_value, 'skipped': maximum_value, 'pending': maximum_value, - }) + }) assert_equal 0xFFFFFFFFF, r.calculate, "Expected in hex: %x, Actual in hex: %x" % [0xFFFFFFFFF, r.calculate] end test 'it should make use of all bits available' do maximum_value = 255 r = ConfigReportStatusCalculator.new(:metrics => %w[1 2 3 4 5 6 7 8], :counters => { - '1': maximum_value, + '1': maximum_value, '2': maximum_value, '3': maximum_value, '4': maximum_value, @@ -69,7 +69,7 @@ class ConfigReportStatusCalculatorTest < ActiveSupport::TestCase '6': maximum_value, '7': maximum_value, '8': maximum_value, - }) + }) assert_equal 0xFFFFFFFFFFFFFFFF, r.calculate, "Expected in hex: %x, Actual in hex: %x" % [0xFFFFFFFFFFFFFFFF, r.calculate] end