Skip to content

Commit

Permalink
(CONT-773) Rubocop Unsafe Auto Fixes 1-3
Browse files Browse the repository at this point in the history
- Lint/BooleanSymbol
- RSpec/BeEq
- Style/CaseLikeIf
  • Loading branch information
david22swan committed Apr 26, 2023
1 parent 8b630e0 commit 3d5e236
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 30 deletions.
20 changes: 0 additions & 20 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +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: 1
# This cop supports unsafe autocorrection (--autocorrect-all).
Lint/BooleanSymbol:
Exclude:
- 'spec/unit/puppet/type/apt_key_spec.rb'

# Offense count: 3
# Configuration parameters: AllowedMethods.
# AllowedMethods: enums
Expand Down Expand Up @@ -53,13 +47,6 @@ Performance/CollectionLiteralInLoop:
Exclude:
- 'spec/classes/apt_update_spec.rb'

# Offense count: 6
# This cop supports unsafe autocorrection (--autocorrect-all).
RSpec/BeEq:
Exclude:
- 'spec/unit/facter/apt_reboot_required_spec.rb'
- 'spec/unit/puppet/type/apt_key_spec.rb'

# Offense count: 6
# Configuration parameters: Prefixes, AllowedPatterns.
# Prefixes: when, with, without
Expand Down Expand Up @@ -141,13 +128,6 @@ Security/Open:
Exclude:
- 'lib/puppet/provider/apt_key/apt_key.rb'

# Offense count: 1
# This cop supports unsafe autocorrection (--autocorrect-all).
# Configuration parameters: MinBranchesCount.
Style/CaseLikeIf:
Exclude:
- 'lib/puppet/provider/apt_key/apt_key.rb'

# Offense count: 1
# This cop supports unsafe autocorrection (--autocorrect-all).
Style/GlobalStdStream:
Expand Down
7 changes: 4 additions & 3 deletions lib/puppet/provider/apt_key/apt_key.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,14 @@ def self.instances
def self.prefetch(resources)
apt_keys = instances
resources.each_key do |name|
if name.length == 40
case name.length
when 40
provider = apt_keys.find { |key| key.fingerprint == name }
resources[name].provider = provider if provider
elsif name.length == 16
when 16
provider = apt_keys.find { |key| key.long == name }
resources[name].provider = provider if provider
elsif name.length == 8
when 8
provider = apt_keys.find { |key| key.short == name }
resources[name].provider = provider if provider
end
Expand Down
4 changes: 2 additions & 2 deletions spec/unit/facter/apt_reboot_required_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
allow(File).to receive(:file?).once.with('/var/run/reboot-required').and_return(true)
end

it { is_expected.to eq true }
it { is_expected.to be true }
end

describe 'if a reboot is not required' do
Expand All @@ -24,6 +24,6 @@
allow(File).to receive(:file?).once.with('/var/run/reboot-required').and_return(false)
end

it { is_expected.to eq false }
it { is_expected.to be false }
end
end
10 changes: 5 additions & 5 deletions spec/unit/puppet/type/apt_key_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,19 @@
end

it 'source is not set' do
expect(resource[:source]).to eq nil
expect(resource[:source]).to be_nil
end

it 'content is not set' do
expect(resource[:content]).to eq nil
expect(resource[:content]).to be_nil
end

it 'refresh is not set' do
expect(resource[:refresh]).to eq nil
expect(resource[:refresh]).to be_nil
end

it 'weak_ssl is not set' do
expect(resource[:weak_ssl]).to eq nil
expect(resource[:weak_ssl]).to be_nil
end
end

Expand Down Expand Up @@ -167,7 +167,7 @@
Puppet::Type.type(:apt_key).new(id: 'EF8D349F',
source: 'http://apt.puppetlabs.com/pubkey.gpg',
ensure: :absent,
refresh: :true)
refresh: true)
}.to raise_error(%r{ensure => absent and refresh => true are mutually exclusive})
end

Expand Down

0 comments on commit 3d5e236

Please sign in to comment.