Skip to content

Commit 5153417

Browse files
committed
Lint/EmptyWhen
Ruby case/when statements don't fall through like many other languages, so add a comment when we're intentionally not falling through.
1 parent b92d72a commit 5153417

File tree

10 files changed

+14
-20
lines changed

10 files changed

+14
-20
lines changed

.rubocop_todo.yml

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -585,19 +585,6 @@ Layout/TrailingWhitespace:
585585
Lint/ConstantDefinitionInBlock:
586586
Enabled: false
587587

588-
# Configuration parameters: AllowComments.
589-
Lint/EmptyWhen:
590-
Exclude:
591-
- 'lib/puppet/indirector/hiera.rb'
592-
- 'lib/puppet/pops/evaluator/evaluator_impl.rb'
593-
- 'lib/puppet/pops/lookup/data_dig_function_provider.rb'
594-
- 'lib/puppet/pops/types/type_formatter.rb'
595-
- 'lib/puppet/pops/types/type_mismatch_describer.rb'
596-
- 'lib/puppet/pops/types/types.rb'
597-
- 'lib/puppet/pops/validation/checker4_0.rb'
598-
- 'lib/puppet/util/backups.rb'
599-
- 'lib/puppet/util/windows/security.rb'
600-
601588
# This cop supports safe auto-correction (--auto-correct).
602589
Lint/EnsureReturn:
603590
Exclude:

lib/puppet/indirector/hiera.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,7 @@ def find(request)
4242
# @return [Symbol,Hash,nil] The Hiera 'resolution_type'
4343
def convert_merge(merge)
4444
case merge
45-
when nil
46-
when 'first'
45+
when nil, 'first'
4746
# Nil is OK. Defaults to Hiera :priority
4847
nil
4948
when Puppet::Pops::MergeStrategy

lib/puppet/pops/evaluator/evaluator_impl.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1083,7 +1083,9 @@ def eval_VariableExpression o, scope
10831083
# may occur for some evaluation use cases.
10841084
case name
10851085
when String
1086+
# do nothing
10861087
when Numeric
1088+
# do nothing
10871089
else
10881090
fail(Issues::ILLEGAL_VARIABLE_EXPRESSION, o.expr)
10891091
end

lib/puppet/pops/lookup/data_dig_function_provider.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,7 @@ def instantiate_backend(lookup_invocation)
107107
# @return [Symbol,Hash,nil] The Hiera 'resolution_type'
108108
def convert_merge(merge)
109109
case merge
110-
when nil
111-
when 'first', 'default'
110+
when nil, 'first', 'default'
112111
# Nil is OK. Defaults to Hiera :priority
113112
nil
114113
when Puppet::Pops::MergeStrategy

lib/puppet/pops/types/type_formatter.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -728,6 +728,7 @@ def append_object_hash(hash)
728728
def append_elements(array, to_be_continued = false)
729729
case array.size
730730
when 0
731+
# do nothing
731732
when 1
732733
@bld << array[0]
733734
@bld << COMMA_SEP if to_be_continued
@@ -740,6 +741,7 @@ def append_elements(array, to_be_continued = false)
740741
def append_strings(array, to_be_continued = false)
741742
case array.size
742743
when 0
744+
# do nothing
743745
when 1
744746
append_string(array[0])
745747
@bld << COMMA_SEP if to_be_continued

lib/puppet/pops/types/type_mismatch_describer.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -533,6 +533,7 @@ def validate_parameters(subject, params_struct, given_hash, missing_ok = false,
533533
errors = describe_struct_signature(params_struct, given_hash, missing_ok).flatten
534534
case errors.size
535535
when 0
536+
# do nothing
536537
when 1
537538
raise Puppet::ParseError.new("#{subject}:#{errors[0].format}")
538539
else
@@ -573,6 +574,7 @@ def validate_default_parameter(subject, param_name, param_type, value, tense = :
573574
errors = describe(param_type, TypeCalculator.singleton.infer_set(value).generalize, [ParameterPathElement.new(param_name)])
574575
case errors.size
575576
when 0
577+
# do nothing
576578
when 1
577579
raise Puppet::ParseError.new("#{subject}:#{errors[0].format}")
578580
else

lib/puppet/pops/types/types.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1178,6 +1178,7 @@ def on_error(from, radix = :default, abs = nil)
11781178
def assert_radix(radix)
11791179
case radix
11801180
when 2, 8, 10, 16
1181+
# do nothing
11811182
else
11821183
raise ArgumentError.new(_("Illegal radix: %{radix}, expected 2, 8, 10, 16, or default") % { radix: radix })
11831184
end

lib/puppet/pops/validation/checker4_0.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,9 @@ def check_AttributesOperation(o)
236236
p = container
237237
case p
238238
when Model::AbstractResource
239+
# do nothing
239240
when Model::CollectExpression
241+
# do nothing
240242
else
241243
# protect against just testing a snippet that has no parent, error message will be a bit strange
242244
# but it is not for a real program.

lib/puppet/util/backups.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def perform_backup_with_bucket(fileobj)
2727
info _("Recursively backing up to filebucket")
2828
Find.find(self[:path]) { |f| backup_file_with_filebucket(f) if File.file?(f) }
2929
when "file"; backup_file_with_filebucket(file)
30-
when "link";
30+
when "link"; # do nothing
3131
end
3232
true
3333
end

lib/puppet/util/windows/security.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -237,8 +237,8 @@ def get_mode(path)
237237
if (ace.mask & FILE::FILE_APPEND_DATA).nonzero?
238238
mode |= S_ISVTX
239239
end
240-
when well_known_app_packages_sid
241-
when well_known_system_sid
240+
when well_known_app_packages_sid, well_known_system_sid
241+
# do nothing
242242
else
243243
#puts "Warning, unable to map SID into POSIX mode: #{ace.sid}"
244244
mode |= S_IEXTRA

0 commit comments

Comments
 (0)