Skip to content

Commit c528ea3

Browse files
committed
Layout/AssignmentIndentation
This commit enables the Rubocop Layout/AssignmentIndentation cop and addresses all offenses.
1 parent d110d95 commit c528ea3

File tree

15 files changed

+156
-175
lines changed

15 files changed

+156
-175
lines changed

.rubocop_todo.yml

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -22,25 +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: IndentationWidth.
27-
Layout/AssignmentIndentation:
28-
Exclude:
29-
- 'lib/puppet/application/apply.rb'
30-
- 'lib/puppet/ffi/windows/constants.rb'
31-
- 'lib/puppet/indirector/request.rb'
32-
- 'lib/puppet/parser/e4_parser_adapter.rb'
33-
- 'lib/puppet/pops/evaluator/evaluator_impl.rb'
34-
- 'lib/puppet/pops/model/model_tree_dumper.rb'
35-
- 'lib/puppet/pops/parser/lexer_support.rb'
36-
- 'lib/puppet/pops/types/type_parser.rb'
37-
- 'lib/puppet/resource/type.rb'
38-
- 'lib/puppet/settings.rb'
39-
- 'lib/puppet/settings/environment_conf.rb'
40-
- 'lib/puppet/type/resources.rb'
41-
- 'lib/puppet/util.rb'
42-
- 'lib/puppet/util/windows/daemon.rb'
43-
4425
# This cop supports safe auto-correction (--auto-correct).
4526
Layout/ClosingParenthesisIndentation:
4627
Enabled: false

lib/puppet/application/apply.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -234,12 +234,12 @@ def main
234234
# rule and gets logged.
235235
#
236236
catalog =
237-
begin
238-
Puppet::Resource::Catalog.indirection.find(node.name, :use_node => node)
239-
rescue Puppet::Error
240-
# already logged and handled by the compiler, including Puppet::ParseErrorWithIssue
241-
exit(1)
242-
end
237+
begin
238+
Puppet::Resource::Catalog.indirection.find(node.name, :use_node => node)
239+
rescue Puppet::Error
240+
# already logged and handled by the compiler, including Puppet::ParseErrorWithIssue
241+
exit(1)
242+
end
243243

244244
# Resolve all deferred values and replace them / mutate the catalog
245245
Puppet::Pops::Evaluator::DeferredResolver.resolve_and_replace(node.facts, catalog, apply_environment, Puppet[:preprocess_deferred])

lib/puppet/ffi/windows/constants.rb

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -47,25 +47,25 @@ module Constants
4747
FILE_ALL_ACCESS = STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | 0x1FF
4848

4949
FILE_GENERIC_READ =
50-
STANDARD_RIGHTS_READ |
51-
FILE_READ_DATA |
52-
FILE_READ_ATTRIBUTES |
53-
FILE_READ_EA |
54-
SYNCHRONIZE
50+
STANDARD_RIGHTS_READ |
51+
FILE_READ_DATA |
52+
FILE_READ_ATTRIBUTES |
53+
FILE_READ_EA |
54+
SYNCHRONIZE
5555

5656
FILE_GENERIC_WRITE =
57-
STANDARD_RIGHTS_WRITE |
58-
FILE_WRITE_DATA |
59-
FILE_WRITE_ATTRIBUTES |
60-
FILE_WRITE_EA |
61-
FILE_APPEND_DATA |
62-
SYNCHRONIZE
57+
STANDARD_RIGHTS_WRITE |
58+
FILE_WRITE_DATA |
59+
FILE_WRITE_ATTRIBUTES |
60+
FILE_WRITE_EA |
61+
FILE_APPEND_DATA |
62+
SYNCHRONIZE
6363

6464
FILE_GENERIC_EXECUTE =
65-
STANDARD_RIGHTS_EXECUTE |
66-
FILE_READ_ATTRIBUTES |
67-
FILE_EXECUTE |
68-
SYNCHRONIZE
65+
STANDARD_RIGHTS_EXECUTE |
66+
FILE_READ_ATTRIBUTES |
67+
FILE_EXECUTE |
68+
SYNCHRONIZE
6969

7070
REPLACEFILE_WRITE_THROUGH = 0x1
7171
REPLACEFILE_IGNORE_MERGE_ERRORS = 0x2

lib/puppet/indirector/request.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,11 @@ def environment
3636

3737
def environment=(env)
3838
@environment =
39-
if env.is_a?(Puppet::Node::Environment)
40-
env
41-
else
42-
Puppet.lookup(:environments).get!(env)
43-
end
39+
if env.is_a?(Puppet::Node::Environment)
40+
env
41+
else
42+
Puppet.lookup(:environments).get!(env)
43+
end
4444
end
4545

4646
# LAK:NOTE This is a messy interface to the cache, and it's only

lib/puppet/parser/e4_parser_adapter.rb

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,14 @@ def parse(string = nil)
2323
self.string= string if string
2424
parser = Pops::Parser::EvaluatingParser.singleton
2525
model =
26-
if @use == :string
27-
# Parse with a source_file to set in created AST objects (it was either given, or it may be unknown
28-
# if caller did not set a file and the present a string.
29-
#
30-
parser.parse_string(@string, @file || "unknown-source-location")
31-
else
32-
parser.parse_file(@file)
33-
end
26+
if @use == :string
27+
# Parse with a source_file to set in created AST objects (it was either given, or it may be unknown
28+
# if caller did not set a file and the present a string.
29+
#
30+
parser.parse_string(@string, @file || "unknown-source-location")
31+
else
32+
parser.parse_file(@file)
33+
end
3434

3535
# the parse_result may be
3636
# * empty / nil (no input)
@@ -41,12 +41,12 @@ def parse(string = nil)
4141
Pops::Model::AstTransformer.new(@file).merge_location(args, model)
4242

4343
ast_code =
44-
if model.is_a? Pops::Model::Program
45-
AST::PopsBridge::Program.new(model, args)
46-
else
47-
args[:value] = model
48-
AST::PopsBridge::Expression.new(args)
49-
end
44+
if model.is_a? Pops::Model::Program
45+
AST::PopsBridge::Program.new(model, args)
46+
else
47+
args[:value] = model
48+
AST::PopsBridge::Expression.new(args)
49+
end
5050

5151
# Create the "main" class for the content - this content will get merged with all other "main" content
5252
AST::Hostclass.new('', :code => ast_code)

lib/puppet/pops/evaluator/evaluator_impl.rb

Lines changed: 39 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -766,45 +766,45 @@ def eval_ResourceExpression(o, scope)
766766

767767
# Get the type name
768768
type_name =
769-
if (tmp_name = o.type_name).is_a?(Model::QualifiedName)
770-
tmp_name.value # already validated as a name
771-
else
772-
type_name_acceptable =
773-
case o.type_name
774-
when Model::QualifiedReference
775-
true
776-
when Model::AccessExpression
777-
o.type_name.left_expr.is_a?(Model::QualifiedReference)
778-
end
779-
780-
evaluated_name = evaluate(tmp_name, scope)
781-
unless type_name_acceptable
782-
actual = type_calculator.generalize(type_calculator.infer(evaluated_name)).to_s
783-
fail(Issues::ILLEGAL_RESOURCE_TYPE, o.type_name, {:actual => actual})
784-
end
769+
if (tmp_name = o.type_name).is_a?(Model::QualifiedName)
770+
tmp_name.value # already validated as a name
771+
else
772+
type_name_acceptable =
773+
case o.type_name
774+
when Model::QualifiedReference
775+
true
776+
when Model::AccessExpression
777+
o.type_name.left_expr.is_a?(Model::QualifiedReference)
778+
end
785779

786-
# must be a CatalogEntry subtype
787-
case evaluated_name
788-
when Types::PClassType
789-
unless evaluated_name.class_name.nil?
790-
fail(Issues::ILLEGAL_RESOURCE_TYPE, o.type_name, {:actual=> evaluated_name.to_s})
780+
evaluated_name = evaluate(tmp_name, scope)
781+
unless type_name_acceptable
782+
actual = type_calculator.generalize(type_calculator.infer(evaluated_name)).to_s
783+
fail(Issues::ILLEGAL_RESOURCE_TYPE, o.type_name, {:actual => actual})
791784
end
792-
'class'
793785

794-
when Types::PResourceType
795-
unless evaluated_name.title().nil?
796-
fail(Issues::ILLEGAL_RESOURCE_TYPE, o.type_name, {:actual=> evaluated_name.to_s})
797-
end
798-
evaluated_name.type_name # assume validated
786+
# must be a CatalogEntry subtype
787+
case evaluated_name
788+
when Types::PClassType
789+
unless evaluated_name.class_name.nil?
790+
fail(Issues::ILLEGAL_RESOURCE_TYPE, o.type_name, {:actual=> evaluated_name.to_s})
791+
end
792+
'class'
793+
794+
when Types::PResourceType
795+
unless evaluated_name.title().nil?
796+
fail(Issues::ILLEGAL_RESOURCE_TYPE, o.type_name, {:actual=> evaluated_name.to_s})
797+
end
798+
evaluated_name.type_name # assume validated
799799

800-
when Types::PTypeReferenceType
801-
fail(Issues::UNKNOWN_RESOURCE_TYPE, o.type_string, {:type_name => evaluated_name.to_s})
800+
when Types::PTypeReferenceType
801+
fail(Issues::UNKNOWN_RESOURCE_TYPE, o.type_string, {:type_name => evaluated_name.to_s})
802802

803-
else
804-
actual = type_calculator.generalize(type_calculator.infer(evaluated_name)).to_s
805-
fail(Issues::ILLEGAL_RESOURCE_TYPE, o.type_name, {:actual=>actual})
803+
else
804+
actual = type_calculator.generalize(type_calculator.infer(evaluated_name)).to_s
805+
fail(Issues::ILLEGAL_RESOURCE_TYPE, o.type_name, {:actual=>actual})
806+
end
806807
end
807-
end
808808

809809
# This is a runtime check - the model is valid, but will have runtime issues when evaluated
810810
# and storeconfigs is not set.
@@ -919,12 +919,12 @@ def eval_AttributesOperation(o, scope)
919919
def eval_ResourceDefaultsExpression(o, scope)
920920
type = evaluate(o.type_ref, scope)
921921
type_name =
922-
if type.is_a?(Types::PResourceType) && !type.type_name.nil? && type.title.nil?
923-
type.type_name # assume it is a valid name
924-
else
925-
actual = type_calculator.generalize(type_calculator.infer(type))
926-
fail(Issues::ILLEGAL_RESOURCE_TYPE, o.type_ref, {:actual => actual})
927-
end
922+
if type.is_a?(Types::PResourceType) && !type.type_name.nil? && type.title.nil?
923+
type.type_name # assume it is a valid name
924+
else
925+
actual = type_calculator.generalize(type_calculator.infer(type))
926+
fail(Issues::ILLEGAL_RESOURCE_TYPE, o.type_ref, {:actual => actual})
927+
end
928928
evaluated_parameters = o.operations.map {|op| evaluate(op, scope) }
929929
create_resource_defaults(o, scope, type_name, evaluated_parameters)
930930
# Produce the type

lib/puppet/pops/model/model_tree_dumper.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -321,19 +321,19 @@ def dump_IfExpression o
321321
result = ["if", do_dump(o.test), :indent, :break,
322322
["then", :indent, do_dump(o.then_expr), :dedent]]
323323
result +=
324-
[:break,
325-
["else", :indent, do_dump(o.else_expr), :dedent],
326-
:dedent] unless is_nop? o.else_expr
324+
[:break,
325+
["else", :indent, do_dump(o.else_expr), :dedent],
326+
:dedent] unless is_nop? o.else_expr
327327
result
328328
end
329329

330330
def dump_UnlessExpression o
331331
result = ["unless", do_dump(o.test), :indent, :break,
332332
["then", :indent, do_dump(o.then_expr), :dedent]]
333333
result +=
334-
[:break,
335-
["else", :indent, do_dump(o.else_expr), :dedent],
336-
:dedent] unless is_nop? o.else_expr
334+
[:break,
335+
["else", :indent, do_dump(o.else_expr), :dedent],
336+
:dedent] unless is_nop? o.else_expr
337337
result
338338
end
339339

lib/puppet/pops/parser/lexer_support.rb

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -167,35 +167,35 @@ def to_s
167167

168168
def assert_not_bom(content)
169169
name, size =
170-
case bom = get_bom(content)
170+
case bom = get_bom(content)
171171

172-
when BOM_UTF_32_1, BOM_UTF_32_2
173-
['UTF-32', 4]
172+
when BOM_UTF_32_1, BOM_UTF_32_2
173+
['UTF-32', 4]
174174

175-
when BOM_GB_18030
176-
['GB-18030', 4]
175+
when BOM_GB_18030
176+
['GB-18030', 4]
177177

178-
when BOM_UTF_EBCDIC
179-
['UTF-EBCDIC', 4]
178+
when BOM_UTF_EBCDIC
179+
['UTF-EBCDIC', 4]
180180

181-
when BOM_SCSU
182-
['SCSU', 3]
181+
when BOM_SCSU
182+
['SCSU', 3]
183183

184-
when BOM_UTF_8
185-
['UTF-8', 3]
184+
when BOM_UTF_8
185+
['UTF-8', 3]
186186

187-
when BOM_UTF_1
188-
['UTF-1', 3]
187+
when BOM_UTF_1
188+
['UTF-1', 3]
189189

190-
when BOM_BOCU
191-
['BOCU', 3]
190+
when BOM_BOCU
191+
['BOCU', 3]
192192

193-
when BOM_UTF_16_1, BOM_UTF_16_2
194-
['UTF-16', 2]
193+
when BOM_UTF_16_1, BOM_UTF_16_2
194+
['UTF-16', 2]
195195

196-
else
197-
return
198-
end
196+
else
197+
return
198+
end
199199

200200
lex_error_without_pos(
201201
Puppet::Pops::Issues::ILLEGAL_BOM,

lib/puppet/pops/types/type_parser.rb

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -542,21 +542,21 @@ def interpret_AccessExpression(ast, context)
542542

543543
when 'string'
544544
size_type =
545-
case parameters.size
546-
when 1
547-
if parameters[0].is_a?(PIntegerType)
548-
parameters[0]
549-
else
545+
case parameters.size
546+
when 1
547+
if parameters[0].is_a?(PIntegerType)
548+
parameters[0]
549+
else
550+
assert_range_parameter(ast, parameters[0])
551+
TypeFactory.range(parameters[0], :default)
552+
end
553+
when 2
550554
assert_range_parameter(ast, parameters[0])
551-
TypeFactory.range(parameters[0], :default)
555+
assert_range_parameter(ast, parameters[1])
556+
TypeFactory.range(parameters[0], parameters[1])
557+
else
558+
raise_invalid_parameters_error('String', '1 to 2', parameters.size)
552559
end
553-
when 2
554-
assert_range_parameter(ast, parameters[0])
555-
assert_range_parameter(ast, parameters[1])
556-
TypeFactory.range(parameters[0], parameters[1])
557-
else
558-
raise_invalid_parameters_error('String', '1 to 2', parameters.size)
559-
end
560560
TypeFactory.string(size_type)
561561

562562
when 'sensitive'

lib/puppet/resource/type.rb

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -153,14 +153,14 @@ def merge(other)
153153
# values.
154154
def ensure_in_catalog(scope, parameters=nil)
155155
resource_type =
156-
case type
157-
when :definition
158-
raise ArgumentError, _('Cannot create resources for defined resource types')
159-
when :hostclass
160-
:class
161-
when :node
162-
:node
163-
end
156+
case type
157+
when :definition
158+
raise ArgumentError, _('Cannot create resources for defined resource types')
159+
when :hostclass
160+
:class
161+
when :node
162+
:node
163+
end
164164

165165
# Do nothing if the resource already exists; this makes sure we don't
166166
# get multiple copies of the class resource, which helps provide the

0 commit comments

Comments
 (0)