Skip to content

Commit 292f55c

Browse files
committed
Performance/CompareWithBlock
1 parent cbc8f2e commit 292f55c

File tree

4 files changed

+4
-4
lines changed

4 files changed

+4
-4
lines changed

lib/puppet/module_tool.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ def self.build_tree(mods, dir)
103103
mod[:text] += " [#{mod[:path]}]" unless mod[:path].to_s == dir.to_s
104104

105105
deps = (mod[:dependencies] || [])
106-
deps.sort! { |a, b| a[:name] <=> b[:name] }
106+
deps.sort_by! { |a| a[:name] }
107107
build_tree(deps, dir)
108108
end
109109
end

lib/puppet/module_tool/shared_behaviors.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def get_remote_constraints(forge)
3939
releases.each do |rel|
4040
semver = SemanticPuppet::Version.parse(rel['version']) rescue SemanticPuppet::Version::MIN
4141
@versions[mod_name] << { :vstring => rel['version'], :semver => semver }
42-
@versions[mod_name].sort! { |a, b| a[:semver] <=> b[:semver] }
42+
@versions[mod_name].sort_by! { |a| a[:semver] }
4343
@urls["#{mod_name}@#{rel['version']}"] = rel['file']
4444
d = @remote["#{mod_name}@#{rel['version']}"]
4545
(rel['dependencies'] || []).each do |name, conditions|

lib/puppet/provider/nameservice/directoryservice.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ def self.next_system_id(id_type, min_id = 20)
298298
dscl_out = dscl(dscl_args)
299299
# We're ok with throwing away negative uids here.
300300
ids = dscl_out.split.compact.collect { |l| l.to_i if l =~ /^\d+$/ }
301-
ids.compact!.sort! { |a, b| a.to_f <=> b.to_f }
301+
ids.compact!.sort_by!(&:to_f)
302302
# We're just looking for an unused id in our sorted array.
303303
ids.each_index do |i|
304304
next_id = ids[i] + 1

lib/puppet/provider/user/directoryservice.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -521,7 +521,7 @@ def next_system_id(min_id = 20)
521521
dscl_output = dscl '.', '-list', '/Users', 'uid'
522522
# We're ok with throwing away negative uids here. Also, remove nil values.
523523
user_ids = dscl_output.split.compact.collect { |l| l.to_i if l =~ /^\d+$/ }
524-
ids = user_ids.compact!.sort! { |a, b| a.to_f <=> b.to_f }
524+
ids = user_ids.compact!.sort_by!(&:to_f)
525525
# We're just looking for an unused id in our sorted array.
526526
ids.each_index do |i|
527527
next_id = ids[i] + 1

0 commit comments

Comments
 (0)