From e924abd295874ffc79086bc64367050e17520fb2 Mon Sep 17 00:00:00 2001 From: Josh Cooper Date: Fri, 6 Oct 2023 10:36:35 -0700 Subject: [PATCH 1/8] (FACT-3428) Layout/SpaceAroundMethodCallOperator --- .rubocop_todo.yml | 14 -------------- spec/custom_facts/core/execution/posix_spec.rb | 2 +- spec/custom_facts/util/collection_spec.rb | 8 ++++---- spec/facter/facts/linux/system_uptime/days_spec.rb | 4 ++-- .../facter/facts/linux/system_uptime/hours_spec.rb | 4 ++-- .../facts/linux/system_uptime/seconds_spec.rb | 4 ++-- .../facts/linux/system_uptime/uptime_spec.rb | 4 ++-- spec/facter/resolvers/lpar_spec.rb | 2 +- .../util/facts/posix/virtual_detector_spec.rb | 2 +- .../util/resolvers/filesystem_helper_spec.rb | 8 ++++---- 10 files changed, 19 insertions(+), 33 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 8d4c9fb4b3..c24db56e3b 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -34,20 +34,6 @@ Layout/MultilineMethodCallIndentation: Exclude: - 'lib/facter/resolvers/networking.rb' -# Offense count: 19 -# This cop supports safe autocorrection (--autocorrect). -Layout/SpaceAroundMethodCallOperator: - Exclude: - - 'spec/custom_facts/core/execution/posix_spec.rb' - - 'spec/custom_facts/util/collection_spec.rb' - - 'spec/facter/facts/linux/system_uptime/days_spec.rb' - - 'spec/facter/facts/linux/system_uptime/hours_spec.rb' - - 'spec/facter/facts/linux/system_uptime/seconds_spec.rb' - - 'spec/facter/facts/linux/system_uptime/uptime_spec.rb' - - 'spec/facter/resolvers/lpar_spec.rb' - - 'spec/facter/util/facts/posix/virtual_detector_spec.rb' - - 'spec/facter/util/resolvers/filesystem_helper_spec.rb' - # Offense count: 1 # Configuration parameters: AllowedNames. # AllowedNames: module_parent diff --git a/spec/custom_facts/core/execution/posix_spec.rb b/spec/custom_facts/core/execution/posix_spec.rb index 2b3c8183da..db05a234df 100644 --- a/spec/custom_facts/core/execution/posix_spec.rb +++ b/spec/custom_facts/core/execution/posix_spec.rb @@ -6,7 +6,7 @@ describe '#search_paths' do it 'uses the PATH environment variable plus /sbin and /usr/sbin on unix' do allow(ENV).to receive(:[]).with('PATH').and_return '/bin:/usr/bin' - expect(posix_executor.search_paths). to eq %w[/bin /usr/bin /sbin /usr/sbin] + expect(posix_executor.search_paths).to eq %w[/bin /usr/bin /sbin /usr/sbin] end end diff --git a/spec/custom_facts/util/collection_spec.rb b/spec/custom_facts/util/collection_spec.rb index 4b98c99ba9..7638a132cc 100755 --- a/spec/custom_facts/util/collection_spec.rb +++ b/spec/custom_facts/util/collection_spec.rb @@ -401,11 +401,11 @@ def load(collection) end it 'loads one fact' do - expect(collection.custom_facts.size). to eq(1) + expect(collection.custom_facts.size).to eq(1) end it 'loads the new fact' do - expect(collection.custom_facts.first[0]). to eq(:new_fact) + expect(collection.custom_facts.first[0]).to eq(:new_fact) end end @@ -424,11 +424,11 @@ def load(collection) end it 'loads one fact' do - expect(collection.custom_facts.size). to eq(1) + expect(collection.custom_facts.size).to eq(1) end it 'loads the new fact' do - expect(collection.custom_facts.first[0]). to eq(:new_fact) + expect(collection.custom_facts.first[0]).to eq(:new_fact) end end end diff --git a/spec/facter/facts/linux/system_uptime/days_spec.rb b/spec/facter/facts/linux/system_uptime/days_spec.rb index 498f833f87..562c1d534a 100644 --- a/spec/facter/facts/linux/system_uptime/days_spec.rb +++ b/spec/facter/facts/linux/system_uptime/days_spec.rb @@ -8,7 +8,7 @@ context 'when on linux' do before do - allow(Facter::Resolvers::Containers).to receive(:resolve) .with(:hypervisor).and_return(nil) + allow(Facter::Resolvers::Containers).to receive(:resolve).with(:hypervisor).and_return(nil) allow(Facter::Resolvers::Uptime).to receive(:resolve).with(:days).and_return(value) end @@ -21,7 +21,7 @@ context 'when in docker container' do before do - allow(Facter::Resolvers::Containers).to receive(:resolve) .with(:hypervisor).and_return({ docker: '123' }) + allow(Facter::Resolvers::Containers).to receive(:resolve).with(:hypervisor).and_return({ docker: '123' }) allow(Facter::Resolvers::Linux::DockerUptime).to receive(:resolve).with(:days).and_return(value) end diff --git a/spec/facter/facts/linux/system_uptime/hours_spec.rb b/spec/facter/facts/linux/system_uptime/hours_spec.rb index afb412979e..70da047d2b 100644 --- a/spec/facter/facts/linux/system_uptime/hours_spec.rb +++ b/spec/facter/facts/linux/system_uptime/hours_spec.rb @@ -8,7 +8,7 @@ context 'when on linux' do before do - allow(Facter::Resolvers::Containers).to receive(:resolve) .with(:hypervisor).and_return(nil) + allow(Facter::Resolvers::Containers).to receive(:resolve).with(:hypervisor).and_return(nil) allow(Facter::Resolvers::Uptime).to receive(:resolve).with(:hours).and_return(value) end @@ -21,7 +21,7 @@ context 'when in docker container' do before do - allow(Facter::Resolvers::Containers).to receive(:resolve) .with(:hypervisor).and_return({ docker: '123' }) + allow(Facter::Resolvers::Containers).to receive(:resolve).with(:hypervisor).and_return({ docker: '123' }) allow(Facter::Resolvers::Linux::DockerUptime).to receive(:resolve).with(:hours).and_return(value) end diff --git a/spec/facter/facts/linux/system_uptime/seconds_spec.rb b/spec/facter/facts/linux/system_uptime/seconds_spec.rb index 01e450fb65..b8b05932ba 100644 --- a/spec/facter/facts/linux/system_uptime/seconds_spec.rb +++ b/spec/facter/facts/linux/system_uptime/seconds_spec.rb @@ -8,7 +8,7 @@ context 'when on linux' do before do - allow(Facter::Resolvers::Containers).to receive(:resolve) .with(:hypervisor).and_return(nil) + allow(Facter::Resolvers::Containers).to receive(:resolve).with(:hypervisor).and_return(nil) allow(Facter::Resolvers::Uptime).to receive(:resolve).with(:seconds).and_return(value) end @@ -21,7 +21,7 @@ context 'when in docker container' do before do - allow(Facter::Resolvers::Containers).to receive(:resolve) .with(:hypervisor).and_return({ docker: '123' }) + allow(Facter::Resolvers::Containers).to receive(:resolve).with(:hypervisor).and_return({ docker: '123' }) allow(Facter::Resolvers::Linux::DockerUptime).to receive(:resolve).with(:seconds).and_return(value) end diff --git a/spec/facter/facts/linux/system_uptime/uptime_spec.rb b/spec/facter/facts/linux/system_uptime/uptime_spec.rb index c765f3f20c..afe720e3ba 100644 --- a/spec/facter/facts/linux/system_uptime/uptime_spec.rb +++ b/spec/facter/facts/linux/system_uptime/uptime_spec.rb @@ -8,7 +8,7 @@ context 'when on linux' do before do - allow(Facter::Resolvers::Containers).to receive(:resolve) .with(:hypervisor).and_return(nil) + allow(Facter::Resolvers::Containers).to receive(:resolve).with(:hypervisor).and_return(nil) allow(Facter::Resolvers::Uptime).to receive(:resolve).with(:uptime).and_return(value) end @@ -21,7 +21,7 @@ context 'when in docker container' do before do - allow(Facter::Resolvers::Containers).to receive(:resolve) .with(:hypervisor).and_return({ docker: '123' }) + allow(Facter::Resolvers::Containers).to receive(:resolve).with(:hypervisor).and_return({ docker: '123' }) allow(Facter::Resolvers::Linux::DockerUptime).to receive(:resolve).with(:uptime).and_return(value) end diff --git a/spec/facter/resolvers/lpar_spec.rb b/spec/facter/resolvers/lpar_spec.rb index 76d573e84d..16f8b68eca 100644 --- a/spec/facter/resolvers/lpar_spec.rb +++ b/spec/facter/resolvers/lpar_spec.rb @@ -14,7 +14,7 @@ end it 'returns lpar pratition number' do - expect(lpar_resolver.resolve(:lpar_partition_number)) .to eq(15) + expect(lpar_resolver.resolve(:lpar_partition_number)).to eq(15) end it 'returns lpar pratition name' do diff --git a/spec/facter/util/facts/posix/virtual_detector_spec.rb b/spec/facter/util/facts/posix/virtual_detector_spec.rb index 303fe847ec..23366d9d44 100644 --- a/spec/facter/util/facts/posix/virtual_detector_spec.rb +++ b/spec/facter/util/facts/posix/virtual_detector_spec.rb @@ -80,7 +80,7 @@ it 'calls Facter::Resolvers::VirtWhat' do detector.platform - expect(Facter::Resolvers::VirtWhat). to have_received(:resolve).with(:vm) + expect(Facter::Resolvers::VirtWhat).to have_received(:resolve).with(:vm) end it 'returns xen' do diff --git a/spec/facter/util/resolvers/filesystem_helper_spec.rb b/spec/facter/util/resolvers/filesystem_helper_spec.rb index 3655354019..64bb9f33aa 100644 --- a/spec/facter/util/resolvers/filesystem_helper_spec.rb +++ b/spec/facter/util/resolvers/filesystem_helper_spec.rb @@ -33,19 +33,19 @@ let(:mount_points) { Facter::Util::Resolvers::FilesystemHelper.read_mountpoints } it 'converts name from ASCII-8BIT to UTF-8' do - expect(mount_points.first.name.encoding.name). to eq('UTF-8') + expect(mount_points.first.name.encoding.name).to eq('UTF-8') end it 'converts mount_type from ASCII-8BIT to UTF-8' do - expect(mount_points.first.mount_type.encoding.name). to eq('UTF-8') + expect(mount_points.first.mount_type.encoding.name).to eq('UTF-8') end it 'converts mount_point from ASCII-8BIT to UTF-8' do - expect(mount_points.first.mount_point.encoding.name). to eq('UTF-8') + expect(mount_points.first.mount_point.encoding.name).to eq('UTF-8') end it 'converts options from ASCII-8BIT to UTF-8' do - expect(mount_points.first.options.encoding.name). to eq('UTF-8') + expect(mount_points.first.options.encoding.name).to eq('UTF-8') end end end From d0ed6b2d9257b9f87234ab1cf7ae433da7816413 Mon Sep 17 00:00:00 2001 From: Josh Cooper Date: Tue, 19 Dec 2023 23:50:26 -0800 Subject: [PATCH 2/8] (FACT-3428) Layout/EmptyLinesAroundAttributeAccessor --- .rubocop_todo.yml | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index c24db56e3b..4d8c098e1e 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -8,12 +8,10 @@ # Offense count: 2 # This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: AllowAliasSyntax, AllowedMethods. -# AllowedMethods: alias_method, public, protected, private -Layout/EmptyLinesAroundAttributeAccessor: - Exclude: - - 'spec/custom_facts/core/resolvable_spec.rb' - - 'spec/custom_facts/core/suitable_spec.rb' +# Configuration parameters: IndentationWidth. +# SupportedStyles: special_inside_parentheses, consistent, align_braces +Layout/FirstHashElementIndentation: + EnforcedStyle: special_inside_parentheses # Offense count: 6 # This cop supports safe autocorrection (--autocorrect). From 5d6adad2078a0e0799d226136c9bd78e60abe801 Mon Sep 17 00:00:00 2001 From: Josh Cooper Date: Fri, 6 Oct 2023 10:43:33 -0700 Subject: [PATCH 3/8] (FACT-3428) Layout/LeadingCommentSpace --- lib/facter/resolvers/fips_enabled.rb | 2 +- lib/facter/resolvers/freebsd/dmi.rb | 2 +- lib/facter/resolvers/freebsd/virtual.rb | 2 +- lib/facter/resolvers/macosx/dmi.rb | 2 +- lib/facter/resolvers/processors_lscpu.rb | 4 ++-- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/facter/resolvers/fips_enabled.rb b/lib/facter/resolvers/fips_enabled.rb index 2628017369..fe45e8b49f 100644 --- a/lib/facter/resolvers/fips_enabled.rb +++ b/lib/facter/resolvers/fips_enabled.rb @@ -4,7 +4,7 @@ module Facter module Resolvers module Linux class FipsEnabled < BaseResolver - #:fips_enabled + # :fips_enabled init_resolver diff --git a/lib/facter/resolvers/freebsd/dmi.rb b/lib/facter/resolvers/freebsd/dmi.rb index 56916d406c..4a136c0019 100644 --- a/lib/facter/resolvers/freebsd/dmi.rb +++ b/lib/facter/resolvers/freebsd/dmi.rb @@ -7,7 +7,7 @@ class DmiBios < BaseResolver init_resolver class << self - #:model + # :model private diff --git a/lib/facter/resolvers/freebsd/virtual.rb b/lib/facter/resolvers/freebsd/virtual.rb index e522ff0836..8071fafe52 100644 --- a/lib/facter/resolvers/freebsd/virtual.rb +++ b/lib/facter/resolvers/freebsd/virtual.rb @@ -7,7 +7,7 @@ class Virtual < BaseResolver init_resolver class << self - #:model + # :model VM_GUEST_SYSCTL_NAMES = { 'hv' => 'hyperv', diff --git a/lib/facter/resolvers/macosx/dmi.rb b/lib/facter/resolvers/macosx/dmi.rb index 34a6965e3c..b7eaccb468 100644 --- a/lib/facter/resolvers/macosx/dmi.rb +++ b/lib/facter/resolvers/macosx/dmi.rb @@ -7,7 +7,7 @@ class DmiBios < BaseResolver init_resolver class << self - #:model + # :model private diff --git a/lib/facter/resolvers/processors_lscpu.rb b/lib/facter/resolvers/processors_lscpu.rb index e4248e57c2..eb34b3ac53 100644 --- a/lib/facter/resolvers/processors_lscpu.rb +++ b/lib/facter/resolvers/processors_lscpu.rb @@ -10,8 +10,8 @@ class Lscpu < BaseResolver cores_per_socket: "-e 'Core(s)'" }.freeze class << self - #:cores_per_socket - #:threads_per_core + # :cores_per_socket + # :threads_per_core private From 9647d7aafa6d41f0a6ec2dc0a2fac5c18bec570f Mon Sep 17 00:00:00 2001 From: Josh Cooper Date: Fri, 6 Oct 2023 14:29:23 -0700 Subject: [PATCH 4/8] (FACT-3428) Layout/MultilineMethodCallIndentation --- .rubocop_todo.yml | 12 ++++++------ lib/facter/resolvers/networking.rb | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 4d8c098e1e..a4f13a8e11 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -24,13 +24,13 @@ Layout/LeadingCommentSpace: - 'lib/facter/resolvers/macosx/dmi.rb' - 'lib/facter/resolvers/processors_lscpu.rb' -# Offense count: 1 +# Offense count: 3 # This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyle, IndentationWidth. -# SupportedStyles: aligned, indented, indented_relative_to_receiver -Layout/MultilineMethodCallIndentation: - Exclude: - - 'lib/facter/resolvers/networking.rb' +# Configuration parameters: EnforcedStyleForEmptyBraces. +# SupportedStyles: space, no_space, compact +# SupportedStylesForEmptyBraces: space, no_space +Layout/SpaceInsideHashLiteralBraces: + EnforcedStyle: space # Offense count: 1 # Configuration parameters: AllowedNames. diff --git a/lib/facter/resolvers/networking.rb b/lib/facter/resolvers/networking.rb index 5e3aa8ba11..9fbd9edc2a 100644 --- a/lib/facter/resolvers/networking.rb +++ b/lib/facter/resolvers/networking.rb @@ -66,7 +66,7 @@ def extract_mtu(raw_data, parsed_interface_data) def extract_mac(raw_data, parsed_interface_data) mac = raw_data.match(/(?:ether|lladdr)\s+((?:\w?\w:){5}\w?\w)|(?:infiniband)\s+((?:\w?\w:){19}\w?\w)/) - &.captures&.compact&.first + &.captures&.compact&.first parsed_interface_data[:mac] = mac unless mac.nil? end From 99e58971fc2daa7c53fab61d61c56e6e54f218c0 Mon Sep 17 00:00:00 2001 From: Josh Cooper Date: Wed, 20 Dec 2023 00:02:07 -0800 Subject: [PATCH 5/8] (FACT-3428) Layout/LineLength Also remove the RedundantDisableDirective that was working around the LineLength. --- .rubocop.yml | 3 +++ .rubocop_todo.yml | 7 ------- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 7efcb4fa1c..e865944ddd 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -11,6 +11,9 @@ require: - rubocop-performance - rubocop-rspec +Layout/LineLength: + Enabled: false + Metrics/AbcSize: Enabled: false diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index a4f13a8e11..bbaddf0b43 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -180,10 +180,3 @@ Style/Documentation: - 'spec_integration/**/*' - 'scripts/*' - 'install.rb' - -# Offense count: 8 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, AllowedPatterns. -# URISchemes: http, https -Layout/LineLength: - Max: 188 From 41b7877a4eefaaa125d6f70fb4efbf707da79079 Mon Sep 17 00:00:00 2001 From: Josh Cooper Date: Wed, 20 Dec 2023 12:08:39 -0800 Subject: [PATCH 6/8] (FACT-3428) Layout/FirstHashElementIndentation --- .rubocop_todo.yml | 7 ------- 1 file changed, 7 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index bbaddf0b43..9d4b7b6215 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -6,13 +6,6 @@ # Note that changes in the inspected code, or installation of new # versions of RuboCop, may require this file to be generated again. -# Offense count: 2 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: IndentationWidth. -# SupportedStyles: special_inside_parentheses, consistent, align_braces -Layout/FirstHashElementIndentation: - EnforcedStyle: special_inside_parentheses - # Offense count: 6 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: AllowDoxygenCommentStyle, AllowGemfileRubyComment. From 82e2ac1765c3c132f148eda9053c9a1266c052e4 Mon Sep 17 00:00:00 2001 From: Josh Cooper Date: Wed, 20 Dec 2023 12:10:05 -0800 Subject: [PATCH 7/8] (FACT-3428) Layout/LeadingCommentSpace --- .rubocop_todo.yml | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 9d4b7b6215..0e274ee75d 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -6,17 +6,6 @@ # Note that changes in the inspected code, or installation of new # versions of RuboCop, may require this file to be generated again. -# Offense count: 6 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: AllowDoxygenCommentStyle, AllowGemfileRubyComment. -Layout/LeadingCommentSpace: - Exclude: - - 'lib/facter/resolvers/fips_enabled.rb' - - 'lib/facter/resolvers/freebsd/dmi.rb' - - 'lib/facter/resolvers/freebsd/virtual.rb' - - 'lib/facter/resolvers/macosx/dmi.rb' - - 'lib/facter/resolvers/processors_lscpu.rb' - # Offense count: 3 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyleForEmptyBraces. From a031a6314871b653e2af58c00702f992cf0b0816 Mon Sep 17 00:00:00 2001 From: Josh Cooper Date: Wed, 20 Dec 2023 12:10:41 -0800 Subject: [PATCH 8/8] (FACT-3428) Layout/SpaceInsideHashLiteralBraces --- .rubocop_todo.yml | 8 -------- 1 file changed, 8 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 0e274ee75d..94d35515ae 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -6,14 +6,6 @@ # Note that changes in the inspected code, or installation of new # versions of RuboCop, may require this file to be generated again. -# Offense count: 3 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyleForEmptyBraces. -# SupportedStyles: space, no_space, compact -# SupportedStylesForEmptyBraces: space, no_space -Layout/SpaceInsideHashLiteralBraces: - EnforcedStyle: space - # Offense count: 1 # Configuration parameters: AllowedNames. # AllowedNames: module_parent