Skip to content

Commit

Permalink
Merge pull request #2667 from joshcooper/rubocop_3_Layout
Browse files Browse the repository at this point in the history
(FACT-3428) Resolve Layout cops
  • Loading branch information
cthorn42 authored Jan 10, 2024
2 parents 2018c67 + a031a63 commit f1db991
Show file tree
Hide file tree
Showing 17 changed files with 29 additions and 75 deletions.
3 changes: 3 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ require:
- rubocop-performance
- rubocop-rspec

Layout/LineLength:
Enabled: false

Metrics/AbcSize:
Enabled: false

Expand Down
49 changes: 0 additions & 49 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,48 +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: 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'

# 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: 1
# 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'

# 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
Expand Down Expand Up @@ -196,10 +154,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
2 changes: 1 addition & 1 deletion lib/facter/resolvers/fips_enabled.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module Facter
module Resolvers
module Linux
class FipsEnabled < BaseResolver
#:fips_enabled
# :fips_enabled

init_resolver

Expand Down
2 changes: 1 addition & 1 deletion lib/facter/resolvers/freebsd/dmi.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class DmiBios < BaseResolver
init_resolver

class << self
#:model
# :model

private

Expand Down
2 changes: 1 addition & 1 deletion lib/facter/resolvers/freebsd/virtual.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class Virtual < BaseResolver
init_resolver

class << self
#:model
# :model

VM_GUEST_SYSCTL_NAMES = {
'hv' => 'hyperv',
Expand Down
2 changes: 1 addition & 1 deletion lib/facter/resolvers/macosx/dmi.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class DmiBios < BaseResolver
init_resolver

class << self
#:model
# :model

private

Expand Down
2 changes: 1 addition & 1 deletion lib/facter/resolvers/networking.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions lib/facter/resolvers/processors_lscpu.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion spec/custom_facts/core/execution/posix_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
8 changes: 4 additions & 4 deletions spec/custom_facts/util/collection_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions spec/facter/facts/linux/system_uptime/days_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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

Expand Down
4 changes: 2 additions & 2 deletions spec/facter/facts/linux/system_uptime/hours_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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

Expand Down
4 changes: 2 additions & 2 deletions spec/facter/facts/linux/system_uptime/seconds_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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

Expand Down
4 changes: 2 additions & 2 deletions spec/facter/facts/linux/system_uptime/uptime_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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

Expand Down
2 changes: 1 addition & 1 deletion spec/facter/resolvers/lpar_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion spec/facter/util/facts/posix/virtual_detector_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions spec/facter/util/resolvers/filesystem_helper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit f1db991

Please sign in to comment.