Skip to content

Commit f6dfecb

Browse files
committed
Layout/SpaceAroundKeyword
This commit enables the Rubocop Layout/SpaceAroundKeyword cop and addresses all offenses.
1 parent 9fd6354 commit f6dfecb

File tree

12 files changed

+16
-31
lines changed

12 files changed

+16
-31
lines changed

.rubocop_todo.yml

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -22,21 +22,6 @@ I18n/GetText/DecorateStringFormattingUsingPercent:
2222
I18n/RailsI18n/DecorateString:
2323
Enabled: false
2424

25-
# This cop supports safe auto-correction (--auto-correct).
26-
Layout/SpaceAroundKeyword:
27-
Exclude:
28-
- 'lib/puppet/functions/max.rb'
29-
- 'lib/puppet/functions/min.rb'
30-
- 'lib/puppet/pops/evaluator/evaluator_impl.rb'
31-
- 'lib/puppet/pops/lookup/global_data_provider.rb'
32-
- 'lib/puppet/pops/lookup/hiera_config.rb'
33-
- 'lib/puppet/pops/parser/slurp_support.rb'
34-
- 'lib/puppet/pops/types/p_object_type.rb'
35-
- 'lib/puppet/pops/types/type_calculator.rb'
36-
- 'lib/puppet/pops/validation/checker4_0.rb'
37-
- 'lib/puppet/util/diff.rb'
38-
- 'lib/puppet/util/windows/daemon.rb'
39-
4025
# This cop supports safe auto-correction (--auto-correct).
4126
Layout/SpaceAroundMethodCallOperator:
4227
Exclude:

lib/puppet/functions/max.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ def on_numeric(*args)
145145
def on_string(*args)
146146
assert_arg_count(args)
147147

148-
args.max do|a, b|
148+
args.max do |a, b|
149149
if a.to_s =~ %r{\A^-?\d+([._eE]\d+)?\z} && b.to_s =~ %r{\A-?\d+([._eE]\d+)?\z}
150150
Puppet.warn_once('deprecations', 'max_function_numeric_coerce_string',
151151
_("The max() function's auto conversion of String to Numeric is deprecated - change to convert input before calling, or use lambda"))

lib/puppet/functions/min.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ def on_numeric(*args)
144144
def on_string(*args)
145145
assert_arg_count(args)
146146

147-
args.min do|a, b|
147+
args.min do |a, b|
148148
if a.to_s =~ %r{\A^-?\d+([._eE]\d+)?\z} && b.to_s =~ %r{\A-?\d+([._eE]\d+)?\z}
149149
Puppet.warn_once('deprecations', 'min_function_numeric_coerce_string',
150150
_("The min() function's auto conversion of String to Numeric is deprecated - change to convert input before calling, or use lambda"))

lib/puppet/pops/evaluator/evaluator_impl.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -810,7 +810,7 @@ def eval_ResourceExpression(o, scope)
810810

811811
# This is a runtime check - the model is valid, but will have runtime issues when evaluated
812812
# and storeconfigs is not set.
813-
if(o.exported)
813+
if (o.exported)
814814
optionally_fail(Issues::RT_NO_STORECONFIGS_EXPORT, o);
815815
end
816816

lib/puppet/pops/lookup/global_data_provider.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ def place
1313

1414
def unchecked_key_lookup(key, lookup_invocation, merge)
1515
config = config(lookup_invocation)
16-
if(config.version == 3)
16+
if (config.version == 3)
1717
# Hiera version 3 needs access to special scope variables
1818
scope = lookup_invocation.scope
1919
unless scope.is_a?(Hiera::Scope)

lib/puppet/pops/lookup/hiera_config.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ def self.config_exist?(config_root)
105105
end
106106

107107
def self.symkeys_to_string(struct)
108-
case(struct)
108+
case (struct)
109109
when Hash
110110
map = {}
111111
struct.each_pair {|k, v| map[ k.is_a?(Symbol) ? k.to_s : k] = symkeys_to_string(v) }
@@ -690,7 +690,7 @@ def create_configured_data_providers(lookup_invocation, parent_data_provider, us
690690

691691
options = he[KEY_OPTIONS] || defaults[KEY_OPTIONS]
692692
options = options.nil? ? EMPTY_HASH : interpolate(options, lookup_invocation, false)
693-
if(function_kind == KEY_V3_BACKEND)
693+
if (function_kind == KEY_V3_BACKEND)
694694
v3options = { :datadir => entry_datadir.to_s }
695695
options.each_pair { |k, v| v3options[k.to_sym] = v }
696696
data_providers[name] =

lib/puppet/pops/parser/slurp_support.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ def slurp(scanner, pattern, escapes, ignore_invalid_escapes)
7676
# If later a \u is found it is warned not to be a unicode escape
7777
if escapes.include?('u')
7878
# gsub must be repeated to cater for adjacent escapes
79-
while(str.gsub!(/((?:[^\\]|^)(?:[\\]{2})*)\\u(?:([\da-fA-F]{4})|\{([\da-fA-F]{1,6})\})/m) { $1 + [($2 || $3).hex].pack("U") })
79+
while (str.gsub!(/((?:[^\\]|^)(?:[\\]{2})*)\\u(?:([\da-fA-F]{4})|\{([\da-fA-F]{1,6})\})/m) { $1 + [($2 || $3).hex].pack("U") })
8080
# empty block. Everything happens in the gsub block
8181
end
8282
end

lib/puppet/pops/types/p_object_type.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ def invoke(receiver, scope, args, &block)
261261
# @api private
262262
def create_dispatch(instance)
263263
# TODO: Assumes Ruby implementation for now
264-
if(callable_type.is_a?(PVariantType))
264+
if (callable_type.is_a?(PVariantType))
265265
callable_type.types.map do |ct|
266266
Functions::Dispatch.new(ct, RubyGenerator.protect_reserved_name(name), [], false, ct.block_type.nil? ? nil : 'block')
267267
end

lib/puppet/pops/types/type_calculator.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,7 @@ def common_type(t1, t2)
386386
end
387387

388388
if t1.is_a?(PStringType) && (t2.is_a?(PStringType) || t2.is_a?(PEnumType))
389-
if(t2.is_a?(PEnumType))
389+
if (t2.is_a?(PEnumType))
390390
return t1.value.nil? ? PEnumType::DEFAULT : PEnumType.new(t2.values | [t1.value])
391391
end
392392

@@ -465,7 +465,7 @@ def common_type(t1, t2)
465465
c2 = ClassLoader.provide_from_type(t2)
466466
if c1 && c2
467467
c2_superclasses = superclasses(c2)
468-
superclasses(c1).each do|c1_super|
468+
superclasses(c1).each do |c1_super|
469469
c2_superclasses.each do |c2_super|
470470
if c1_super == c2_super
471471
return PRuntimeType.new(:ruby, c1_super.name)

lib/puppet/pops/validation/checker4_0.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -560,7 +560,7 @@ def internal_check_top_construct_in_module(prog)
560560
body = prog.body
561561
return if prog.body.is_a?(Model::Nop) # Ignore empty or comment-only files
562562

563-
if(body.is_a?(Model::BlockExpression))
563+
if (body.is_a?(Model::BlockExpression))
564564
body.statements.each { |s| acceptor.accept(Issues::ILLEGAL_TOP_CONSTRUCT_LOCATION, s) unless valid_top_construct?(s) }
565565
else
566566
acceptor.accept(Issues::ILLEGAL_TOP_CONSTRUCT_LOCATION, body) unless valid_top_construct?(body)

0 commit comments

Comments
 (0)