Skip to content

Commit fec7703

Browse files
committed
Layout/SpaceInsideReferenceBrackets
This commit enables the Rubocop Layout/SpaceInsideReferenceBrackets cop and addresses all offenses.
1 parent 5279caa commit fec7703

File tree

12 files changed

+19
-37
lines changed

12 files changed

+19
-37
lines changed

.rubocop_todo.yml

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

25-
# This cop supports safe auto-correction (--auto-correct).
26-
# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBrackets.
27-
# SupportedStyles: space, no_space
28-
# SupportedStylesForEmptyBrackets: space, no_space
29-
Layout/SpaceInsideReferenceBrackets:
30-
Exclude:
31-
- 'lib/puppet/application.rb'
32-
- 'lib/puppet/functions/unique.rb'
33-
- 'lib/puppet/parser/scope.rb'
34-
- 'lib/puppet/pops/evaluator/access_operator.rb'
35-
- 'lib/puppet/pops/evaluator/deferred_resolver.rb'
36-
- 'lib/puppet/pops/lookup/hiera_config.rb'
37-
- 'lib/puppet/pops/parser/locator.rb'
38-
- 'lib/puppet/pops/types/string_converter.rb'
39-
- 'lib/puppet/resource/type_collection.rb'
40-
- 'lib/puppet/util/windows/adsi.rb'
41-
- 'lib/puppet/util/windows/process.rb'
42-
4325
# This cop supports safe auto-correction (--auto-correct).
4426
# Configuration parameters: EnforcedStyle.
4527
# SupportedStyles: space, no_space

lib/puppet/application.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ def run_mode(mode_name = nil)
287287
return @run_mode if @run_mode and not mode_name
288288

289289
require_relative '../puppet/util/run_mode'
290-
@run_mode = Puppet::Util::RunMode[ mode_name || Puppet.settings.preferred_run_mode ]
290+
@run_mode = Puppet::Util::RunMode[mode_name || Puppet.settings.preferred_run_mode]
291291
end
292292

293293
# Sets environment_mode name. When acting as a compiler, the environment mode

lib/puppet/functions/unique.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ def unique_hash(hash, &block)
114114
block = lambda { |v| v } unless block_given?
115115
result = Hash.new { |h, k| h[k] = { :keys => [], :values => [] } }
116116
hash.each_pair do |k, v|
117-
rc = result[ block.call(v) ]
117+
rc = result[block.call(v)]
118118
rc[:keys] << k
119119
rc[:values] << v
120120
end

lib/puppet/parser/scope.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ def add_entries_to(target = {}, include_undef = false)
111111
if (v == :undef || v.nil?) && !include_undef
112112
target.delete(k)
113113
else
114-
target[ k ] = v
114+
target[k] = v
115115
end
116116
end
117117
target
@@ -609,8 +609,8 @@ def lookup_qualified_variable(fqn, options)
609609
# not found - search inherited scope for class
610610
leaf_index = fqn.rindex('::')
611611
unless leaf_index.nil?
612-
leaf_name = fqn[ (leaf_index + 2)..-1 ]
613-
class_name = fqn[ 0, leaf_index ]
612+
leaf_name = fqn[(leaf_index + 2)..-1]
613+
class_name = fqn[0, leaf_index]
614614
begin
615615
qs = qualified_scope(class_name)
616616
unless qs.nil?

lib/puppet/pops/evaluator/access_operator.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def access_String(o, scope, keys)
5656
if k1 < 0
5757
EMPTY_STRING
5858
else
59-
o[ k1, k2 ]
59+
o[k1, k2]
6060
end
6161
when 2
6262
k1 = Utils.to_n(keys[0])
@@ -70,7 +70,7 @@ def access_String(o, scope, keys)
7070
k2 = k2 + k1
7171
k1 = 0
7272
end
73-
o[ k1, k2 ]
73+
o[k1, k2]
7474
else
7575
fail(Issues::BAD_STRING_SLICE_ARITY, @semantic.left_expr, { :actual => keys.size })
7676
end
@@ -120,7 +120,7 @@ def access_Array(o, scope, keys)
120120
k1 = 0
121121
end
122122
# Help ruby always return empty array when asking for a sub array
123-
result = o[ k1, k2 ]
123+
result = o[k1, k2]
124124
result.nil? ? [] : result
125125
else
126126
fail(Issues::BAD_ARRAY_SLICE_ARITY, @semantic.left_expr, { :actual => keys.size })

lib/puppet/pops/evaluator/deferred_resolver.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ def resolve_futures(catalog)
102102
mark_sensitive_parameters(r, k)
103103
end
104104
end
105-
overrides[ k ] = resolved
105+
overrides[k] = resolved
106106
end
107107
r.parameters.merge!(overrides) unless overrides.empty?
108108
end

lib/puppet/pops/lookup/hiera_config.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ def self.symkeys_to_string(struct)
108108
case (struct)
109109
when Hash
110110
map = {}
111-
struct.each_pair { |k, v| map[ k.is_a?(Symbol) ? k.to_s : k] = symkeys_to_string(v) }
111+
struct.each_pair { |k, v| map[k.is_a?(Symbol) ? k.to_s : k] = symkeys_to_string(v) }
112112
map
113113
when Array
114114
struct.map { |v| symkeys_to_string(v) }

lib/puppet/pops/parser/locator.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ def char_length(offset, end_offset)
291291

292292
class LocatorForChars < AbstractLocator
293293
def offset_on_line(offset)
294-
line_offset = line_index[ line_for_offset(offset) - 1 ]
294+
line_offset = line_index[line_for_offset(offset) - 1]
295295
offset - line_offset
296296
end
297297

@@ -335,7 +335,7 @@ def self._pcore_type
335335
# Returns the offset on line (first offset on a line is 0).
336336
# Ruby 19 is multibyte but has no character position methods, must use byteslice
337337
def offset_on_line(offset)
338-
line_offset = line_index[ line_for_offset(offset) - 1 ]
338+
line_offset = line_index[line_for_offset(offset) - 1]
339339
@string.byteslice(line_offset, offset - line_offset).length
340340
end
341341

lib/puppet/pops/types/string_converter.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ def self.type_rank(t)
237237
# @returns [Array<String>] a tuple with left, right delimiters
238238
#
239239
def delimiter_pair(default = StringConverter::DEFAULT_ARRAY_DELIMITERS)
240-
DELIMITER_MAP[ @delimiters || @plus ] || default
240+
DELIMITER_MAP[@delimiters || @plus] || default
241241
end
242242

243243
def to_s

lib/puppet/resource/type_collection.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ def find_or_load(name, type)
196196

197197
result = send(type, fqname)
198198
unless result
199-
if @notfound[ fqname ] && Puppet[ :ignoremissingtypes ]
199+
if @notfound[fqname] && Puppet[:ignoremissingtypes]
200200
# do not try to autoload if we already tried and it wasn't conclusive
201201
# as this is a time consuming operation. Warn the user.
202202
# Check first if debugging is on since the call to debug_once is expensive
@@ -206,7 +206,7 @@ def find_or_load(name, type)
206206
else
207207
fqname = munge_name(fqname)
208208
result = loader.try_load_fqname(type, fqname)
209-
@notfound[ fqname ] = result.nil?
209+
@notfound[fqname] = result.nil?
210210
end
211211
end
212212
result

0 commit comments

Comments
 (0)