Skip to content

Commit d999d97

Browse files
(PUP-11767) Enable Style/ClassMethods|CollectionCompact
1 parent 27609dd commit d999d97

File tree

9 files changed

+16
-10
lines changed

9 files changed

+16
-10
lines changed

.rubocop.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,3 +214,9 @@ Style/ClassCheck:
214214

215215
Style/ClassEqualityComparison:
216216
Enabled: true
217+
218+
Style/ClassMethods:
219+
Enabled: true
220+
221+
Style/CollectionCompact:
222+
Enabled: true

lib/puppet/generate/models/type/property.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ def self.get_puppet_type(property)
6161
enum = strings.empty? ? nil : "Enum[#{strings.join(', ')}]"
6262
pattern = regexes.empty? ? nil : "Pattern[#{regexes.join(', ')}]"
6363
boolean = strings.include?('\'true\'') || strings.include?('\'false\'') ? 'Boolean' : nil
64-
variant = [boolean, enum, pattern].reject { |t| t.nil? }
64+
variant = [boolean, enum, pattern].compact
6565
return variant[0] if variant.size == 1
6666

6767
"Variant[#{variant.join(', ')}]"

lib/puppet/parser/ast/resource.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,6 @@ def evaluate(scope)
6161
resource
6262
end
6363
end
64-
end.flatten.reject { |resource| resource.nil? }
64+
end.flatten.compact
6565
end
6666
end

lib/puppet/provider/package/blastwave.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def self.blastlist(hash)
4747
next if line =~ /localrev\s+remoterev/
4848

4949
blastsplit(line)
50-
end.reject { |h| h.nil? }
50+
end.compact
5151

5252
if hash[:justme]
5353
return list[0]

lib/puppet/provider/package/gem.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ def self.gemlist(options)
121121
begin
122122
list = execute_gem_command(options[:command], command_options).lines
123123
.map { |set| gemsplit(set) }
124-
.reject { |x| x.nil? }
124+
.compact
125125
rescue Puppet::ExecutionFailure => detail
126126
raise Puppet::Error, _("Could not list gems: %{detail}") % { detail: detail }, detail.backtrace
127127
end

lib/puppet/provider/package/pkgutil.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ def self.availlist
7474
else
7575
Puppet.warning _("Cannot match %{line}") % { line: line }
7676
end
77-
end.reject { |h| h.nil? }
77+
end.compact
7878
end
7979

8080
# Turn our pkgutil -c listing into a hash for a single package.
@@ -99,7 +99,7 @@ def self.parse_pkglist(output, hash = {})
9999
next if noise?(line)
100100

101101
pkgsplit(line)
102-
end.reject { |h| h.nil? }
102+
end.compact
103103

104104
if hash[:justme]
105105
# Single queries may have been for an alias so return the name requested

lib/puppet/type.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2149,7 +2149,7 @@ def builddepends
21492149
self.class.relationship_params.collect do |klass|
21502150
param = @parameters[klass.name]
21512151
param.to_edges if param
2152-
end.flatten.reject { |r| r.nil? }
2152+
end.flatten.compact
21532153
end
21542154

21552155
# Sets the initial list of tags to associate to this resource.
@@ -2504,7 +2504,7 @@ def finish
25042504
self.class.relationship_params.collect do |klass|
25052505
param = @parameters[klass.name]
25062506
param.validate_relationship if param
2507-
end.flatten.reject { |r| r.nil? }
2507+
end.flatten.compact
25082508
end
25092509

25102510
# @comment For now, leave the 'name' method functioning like it used to. Once 'title'

lib/puppet/type/file.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -592,7 +592,7 @@ def newchild(path)
592592
# or so. Unfortunately, we don't have a straightforward way to manage
593593
# the different lifetimes of this data, so we kludge it like this.
594594
# The right-side hash wins in the merge.
595-
options = @original_parameters.merge(:path => full_path).reject { |_param, value| value.nil? }
595+
options = @original_parameters.merge(:path => full_path).compact
596596

597597
# These should never be passed to our children.
598598
[:parent, :ensure, :recurse, :recurselimit, :max_files, :target, :alias, :source].each do |param|

lib/puppet/util/fileparsing.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ def join(details)
116116
else
117117
details[field].to_s
118118
end
119-
}.reject { |c| c.nil? }.join(joinchar)
119+
}.compact.join(joinchar)
120120
end
121121

122122
# Customize this so we can do a bit of validation.

0 commit comments

Comments
 (0)