Skip to content

Commit 06c4a92

Browse files
committed
(PUP-11993) Style/SymbolProc
This commit enables the Style/SymbolProc cop and fixes 125 (unsafe) autocorrectable offenses.
1 parent 9a1fe32 commit 06c4a92

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

78 files changed

+120
-142
lines changed

.rubocop_todo.yml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -728,12 +728,6 @@ Style/StringLiterals:
728728
Style/SymbolArray:
729729
Enabled: false
730730

731-
# This cop supports unsafe auto-correction (--auto-correct-all).
732-
# Configuration parameters: AllowMethodsWithArguments, IgnoredMethods, AllowComments.
733-
# IgnoredMethods: respond_to, define_method
734-
Style/SymbolProc:
735-
Enabled: false
736-
737731
# This cop supports safe auto-correction (--auto-correct).
738732
# Configuration parameters: EnforcedStyle, AllowSafeAssignment.
739733
# SupportedStyles: require_parentheses, require_no_parentheses, require_parentheses_when_complex

lib/puppet/confine/feature.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
class Puppet::Confine::Feature < Puppet::Confine
66
def self.summarize(confines)
7-
confines.collect { |c| c.values }.flatten.uniq.find_all { |value| !confines[0].pass?(value) }
7+
confines.collect(&:values).flatten.uniq.find_all { |value| !confines[0].pass?(value) }
88
end
99

1010
# Is the named feature available?

lib/puppet/environments.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ def get_conf(name)
313313
end
314314

315315
def clear_all
316-
@loaders.each { |loader| loader.clear_all }
316+
@loaders.each(&:clear_all)
317317
end
318318
end
319319

lib/puppet/face/catalog/select.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
if value.nil? then
4545
_("no matching resources found")
4646
else
47-
value.map { |x| x.to_s }.join("\n")
47+
value.map(&:to_s).join("\n")
4848
end
4949
end
5050
end

lib/puppet/face/module/changes.rb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,7 @@
3838
else
3939
Puppet.warning _("%{count} files modified") % { count: return_value.size }
4040
end
41-
return_value.map do |changed_file|
42-
changed_file.to_s
43-
end.join("\n")
41+
return_value.map(&:to_s).join("\n")
4442
end
4543
end
4644
end

lib/puppet/face/module/list.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ def unmet_dependencies(environment)
117117
end
118118

119119
# Prepare the unmet dependencies for display on the console.
120-
environment.modules.sort_by { |mod| mod.name }.each do |mod|
120+
environment.modules.sort_by(&:name).each do |mod|
121121
unmet_grouped = Hash.new { |h, k| h[k] = [] }
122122
unmet_grouped = mod.unmet_dependencies.each_with_object(unmet_grouped) do |dep, acc|
123123
acc[dep[:reason]] << dep

lib/puppet/file_serving/mount/locales.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def find(relative_path, request)
1717
def search(relative_path, request)
1818
# We currently only support one kind of search on locales - return
1919
# them all.
20-
paths = request.environment.modules.find_all { |mod| mod.locales? }.collect { |mod| mod.locale_directory }
20+
paths = request.environment.modules.find_all(&:locales?).collect(&:locale_directory)
2121
if paths.empty?
2222
# If the modulepath is valid then we still need to return a valid root
2323
# directory for the search, but make sure nothing inside it is

lib/puppet/file_serving/mount/pluginfacts.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def find(relative_path, request)
1717
def search(relative_path, request)
1818
# We currently only support one kind of search on plugins - return
1919
# them all.
20-
paths = request.environment.modules.find_all { |mod| mod.pluginfacts? }.collect { |mod| mod.plugin_fact_directory }
20+
paths = request.environment.modules.find_all(&:pluginfacts?).collect(&:plugin_fact_directory)
2121
if paths.empty?
2222
# If the modulepath is valid then we still need to return a valid root
2323
# directory for the search, but make sure nothing inside it is

lib/puppet/file_serving/mount/plugins.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def find(relative_path, request)
1717
def search(relative_path, request)
1818
# We currently only support one kind of search on plugins - return
1919
# them all.
20-
paths = request.environment.modules.find_all { |mod| mod.plugins? }.collect { |mod| mod.plugin_directory }
20+
paths = request.environment.modules.find_all(&:plugins?).collect(&:plugin_directory)
2121
if paths.empty?
2222
# If the modulepath is valid then we still need to return a valid root
2323
# directory for the search, but make sure nothing inside it is

lib/puppet/forge.rb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -200,9 +200,7 @@ def tmpdir
200200
end
201201

202202
def tmpfile
203-
@file ||= Tempfile.new(name, Puppet::Forge::Cache.base_path).tap do |f|
204-
f.binmode
205-
end
203+
@file ||= Tempfile.new(name, Puppet::Forge::Cache.base_path).tap(&:binmode)
206204
end
207205
# rubocop:enable Naming/MemoizedInstanceVariableName
208206

0 commit comments

Comments
 (0)