File tree Expand file tree Collapse file tree 11 files changed +23
-47
lines changed Expand file tree Collapse file tree 11 files changed +23
-47
lines changed Original file line number Diff line number Diff line change @@ -215,22 +215,6 @@ Style/GlobalStdStream:
215215 - ' spec/framework/core/fact/internal/internal_fact_manager_spec.rb'
216216 - ' spec/framework/logging/logger_spec.rb'
217217
218- # Offense count: 15
219- # This cop supports unsafe autocorrection (--autocorrect-all).
220- # Configuration parameters: AllowedReceivers.
221- # AllowedReceivers: Thread.current
222- Style/HashEachMethods :
223- Exclude :
224- - ' lib/facter/custom_facts/core/execution/base.rb'
225- - ' lib/facter/custom_facts/util/collection.rb'
226- - ' lib/facter/framework/cli/cli.rb'
227- - ' lib/facter/resolvers/aix/ffi/ffi_helper.rb'
228- - ' lib/facter/resolvers/windows/product_release.rb'
229- - ' scripts/generate_changelog.rb'
230- - ' spec/custom_facts/core/execution/fact_manager_spec.rb'
231- - ' spec/custom_facts/util/collection_spec.rb'
232- - ' spec/facter/resolvers/disks_spec.rb'
233-
234218# Offense count: 1
235219# This cop supports unsafe autocorrection (--autocorrect-all).
236220Style/HashTransformKeys :
Original file line number Diff line number Diff line change @@ -30,7 +30,7 @@ def with_env(values)
3030 # use an ensure block to make absolutely sure we restore the variables
3131 ensure
3232 # restore the old values
33- values . each do |var , _value |
33+ values . each_key do |var |
3434 if old . include? ( var )
3535 ENV [ var ] = old [ var ]
3636 else
Original file line number Diff line number Diff line change @@ -80,7 +80,7 @@ def fact(name)
8080
8181 # Flush all cached values.
8282 def flush
83- @facts . each { | _name , fact | fact . flush }
83+ @facts . each_value ( & : flush)
8484 @external_facts_loaded = nil
8585 end
8686
Original file line number Diff line number Diff line change @@ -198,9 +198,9 @@ def add_class_options_to_help
198198
199199 def add_commands_to_help
200200 help_command_options = +''
201- Cli . commands
202- . select { |_k , command_class | command_class . instance_of? ( Thor ::Command ) }
203- . each do |_k , command |
201+ Cli . commands . values
202+ . select { |command_class | command_class . instance_of? ( Thor ::Command ) }
203+ . each do |command |
204204 help_command_options << build_option (
205205 command [ 'name' ] ,
206206 [ command [ 'usage' ] . split ( ',' ) [ 1 ] ] ,
Original file line number Diff line number Diff line change @@ -77,7 +77,7 @@ def self.read_interfaces
7777
7878 family = FFI ::AF_UNSPEC
7979
80- addresses . each do |_k , addr |
80+ addresses . each_value do |addr |
8181 if family != FFI ::AF_UNSPEC &&
8282 addr [ :sa_family ] != FFI ::AF_UNSPEC &&
8383 family != addr [ :sa_family ]
Original file line number Diff line number Diff line change @@ -23,19 +23,19 @@ def read_fact_from_registry(fact_name)
2323 end
2424
2525 def build_fact_list ( reg )
26- reg . each do |name , _value |
26+ reg . each do |name , value |
2727 case name
2828 when 'EditionID'
29- @fact_list [ :edition_id ] = reg [ name ]
29+ @fact_list [ :edition_id ] = value
3030 when 'InstallationType'
31- @fact_list [ :installation_type ] = reg [ name ]
31+ @fact_list [ :installation_type ] = value
3232 when 'ProductName'
33- @fact_list [ :product_name ] = reg [ name ]
33+ @fact_list [ :product_name ] = value
3434 when 'DisplayVersion'
35- @fact_list [ :release_id ] = reg [ name ]
36- @fact_list [ :display_version ] = reg [ name ]
35+ @fact_list [ :release_id ] = value
36+ @fact_list [ :display_version ] = value
3737 when 'ReleaseId'
38- @fact_list [ :release_id ] = reg [ name ] unless @fact_list [ :release_id ]
38+ @fact_list [ :release_id ] = value unless @fact_list [ :release_id ]
3939 end
4040 end
4141 end
Original file line number Diff line number Diff line change @@ -110,7 +110,7 @@ def update_changelog
110110
111111 new_lines << "\n ### #{ type [ :name ] } \n "
112112
113- type [ :entries ] . each do |_ , entry |
113+ type [ :entries ] . each_value do |entry |
114114 new_lines << "- #{ entry [ :title ] . strip } [\# #{ entry [ :number ] } ](#{ entry [ :url ] } )" \
115115 " ([#{ entry [ :author ] } ](#{ entry [ :profile ] } ))"
116116 end
Original file line number Diff line number Diff line change 77 it "executes the caller's block with the specified env vars" do
88 test_env = { 'LANG' => 'C' , 'LC_ALL' => 'C' , 'FOO' => 'BAR' }
99 executor . with_env test_env do
10- test_env . keys . each do |key |
10+ test_env . each_key do |key |
1111 expect ( ENV [ key ] ) . to eq test_env [ key ]
1212 end
1313 end
2929
3030 # verify that, during the 'with_env', the new values are used
3131 executor . with_env new_env do
32- orig_env . keys . each do |key |
32+ orig_env . each_key do |key |
3333 expect ( ENV [ key ] ) . to eq new_env [ key ]
3434 end
3535 end
5050 end
5151
5252 # verify that, after the 'with_env', the old values are restored
53- orig_env . keys . each do |key |
53+ orig_env . each_key do |key |
5454 expect ( ENV [ key ] ) . to eq orig_env [ key ]
5555 end
5656 end
Original file line number Diff line number Diff line change @@ -291,7 +291,7 @@ def load(collection)
291291 end
292292
293293 it 'converts the fact name to a string' do
294- collection . each do |fact , _value |
294+ collection . each do |fact , _value | # rubocop:disable Style/HashEachMethods
295295 expect ( fact ) . to be_instance_of ( String )
296296 end
297297 end
Original file line number Diff line number Diff line change 9696 end
9797
9898 before do
99- paths . each do |_key , value |
100- disks . each do |disk , _values |
99+ paths . each_value do |value |
100+ disks . each_key do |disk |
101101 if value == '/size'
102102 allow ( Facter ::Util ::FileHelper ) . to receive ( :safe_read )
103103 . with ( "/sys/block/#{ disk } #{ value } " , nil ) . and_return ( nil )
118118 end
119119
120120 before do
121- paths . each do |_key , value |
122- disks . each do |disk , _values |
121+ paths . each_value do |value |
122+ disks . each_key do |disk |
123123 if value != '/size'
124124 allow ( Facter ::Util ::FileHelper ) . to receive ( :safe_read )
125125 . with ( "/sys/block/#{ disk } #{ value } " , nil ) . and_return ( nil )
141141
142142 before do
143143 paths . each do |fact , value |
144- disks . each do |disk , _values |
144+ disks . each_key do |disk |
145145 next unless value == 'false'
146146
147147 allow ( Facter ::Core ::Execution ) . to receive ( :execute )
You can’t perform that action at this time.
0 commit comments