Skip to content

Commit 3e8e5c7

Browse files
authored
Merge pull request #9186 from mhashizume/PUP-11768/main/layout-cops
(PUP-11768) Enable and fix Rubocop Layout Cops
2 parents 3582a39 + c528ea3 commit 3e8e5c7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

92 files changed

+717
-782
lines changed

.rubocop.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,12 @@ Layout/ArgumentAlignment:
2222
Exclude:
2323
- 'lib/puppet/defaults.rb'
2424

25+
# The confine statements in package providers unexpectedly affect this cop.
26+
Layout/BeginEndAlignment:
27+
Enabled: true
28+
Exclude:
29+
- 'lib/puppet/provider/package/*.rb'
30+
2531
# puppet uses symbol booleans in types and providers to work around long standing
2632
# bugs when trying to manage falsey pararameters and properties
2733
Lint/BooleanSymbol:

.rubocop_todo.yml

Lines changed: 0 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -22,87 +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, IndentationWidth.
27-
# SupportedStyles: outdent, indent
28-
Layout/AccessModifierIndentation:
29-
Exclude:
30-
- 'lib/puppet/module_tool/install_directory.rb'
31-
- 'lib/puppet/pops/evaluator/collector_transformer.rb'
32-
- 'lib/puppet/provider/service/init.rb'
33-
- 'lib/puppet/provider/service/upstart.rb'
34-
- 'lib/puppet/settings/config_file.rb'
35-
- 'lib/puppet/settings/file_setting.rb'
36-
- 'lib/puppet/util/command_line/trollop.rb'
37-
- 'lib/puppet/util/run_mode.rb'
38-
39-
# This cop supports safe auto-correction (--auto-correct).
40-
# Configuration parameters: EnforcedStyle, IndentationWidth.
41-
# SupportedStyles: with_first_element, with_fixed_indentation
42-
Layout/ArrayAlignment:
43-
Exclude:
44-
- 'lib/puppet/module/plan.rb'
45-
- 'lib/puppet/pops/model/model_tree_dumper.rb'
46-
- 'lib/puppet/pops/parser/heredoc_support.rb'
47-
- 'lib/puppet/pops/parser/lexer2.rb'
48-
- 'lib/puppet/provider/service/init.rb'
49-
- 'lib/puppet/util/log/destinations.rb'
50-
- 'lib/puppet/util/posix.rb'
51-
- 'lib/puppet/util/windows/registry.rb'
52-
53-
# This cop supports safe auto-correction (--auto-correct).
54-
# Configuration parameters: IndentationWidth.
55-
Layout/AssignmentIndentation:
56-
Exclude:
57-
- 'lib/puppet/application/apply.rb'
58-
- 'lib/puppet/ffi/windows/constants.rb'
59-
- 'lib/puppet/indirector/request.rb'
60-
- 'lib/puppet/parser/e4_parser_adapter.rb'
61-
- 'lib/puppet/pops/evaluator/evaluator_impl.rb'
62-
- 'lib/puppet/pops/model/model_tree_dumper.rb'
63-
- 'lib/puppet/pops/parser/lexer_support.rb'
64-
- 'lib/puppet/pops/types/type_parser.rb'
65-
- 'lib/puppet/resource/type.rb'
66-
- 'lib/puppet/settings.rb'
67-
- 'lib/puppet/settings/environment_conf.rb'
68-
- 'lib/puppet/type/resources.rb'
69-
- 'lib/puppet/util.rb'
70-
- 'lib/puppet/util/windows/daemon.rb'
71-
72-
# This cop supports safe auto-correction (--auto-correct).
73-
# Configuration parameters: EnforcedStyleAlignWith, Severity.
74-
# SupportedStylesAlignWith: start_of_line, begin
75-
Layout/BeginEndAlignment:
76-
Exclude:
77-
- 'lib/puppet/provider/package/apt.rb'
78-
- 'lib/puppet/provider/package/aptrpm.rb'
79-
- 'lib/puppet/provider/package/dnf.rb'
80-
- 'lib/puppet/provider/package/rpm.rb'
81-
- 'lib/puppet/provider/package/tdnf.rb'
82-
- 'lib/puppet/provider/package/yum.rb'
83-
84-
# This cop supports safe auto-correction (--auto-correct).
85-
# Configuration parameters: EnforcedStyleAlignWith.
86-
# SupportedStylesAlignWith: either, start_of_block, start_of_line
87-
Layout/BlockAlignment:
88-
Exclude:
89-
- 'lib/puppet/defaults.rb'
90-
- 'lib/puppet/node/environment.rb'
91-
- 'lib/puppet/parser/functions/lookup.rb'
92-
- 'lib/puppet/provider/package/dnfmodule.rb'
93-
- 'lib/puppet/type/file.rb'
94-
- 'lib/puppet/util/windows/principal.rb'
95-
96-
# This cop supports safe auto-correction (--auto-correct).
97-
# Configuration parameters: EnforcedStyle, IndentOneStep, IndentationWidth.
98-
# SupportedStyles: case, end
99-
Layout/CaseIndentation:
100-
Enabled: false
101-
102-
# This cop supports safe auto-correction (--auto-correct).
103-
Layout/ClosingHeredocIndentation:
104-
Enabled: false
105-
10625
# This cop supports safe auto-correction (--auto-correct).
10726
Layout/ClosingParenthesisIndentation:
10827
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/application/doc.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ module - see https://github.com/puppetlabs/puppetlabs-strings for more informati
112112
---------
113113
Copyright (c) 2011 Puppet Inc., LLC Licensed under the Apache 2.0 License
114114
115-
HELP
115+
HELP
116116
end
117117

118118
def handle_unknown( opt, arg )

lib/puppet/application/ssl.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ def help
8383
8484
* show:
8585
Print the full-text version of this host's certificate.
86-
HELP
86+
HELP
8787
end
8888

8989
option('--target CERTNAME') do |arg|

lib/puppet/datatypes/error.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
functions => {
1515
message => Callable[[], String[1]]
1616
}
17-
PUPPET
17+
PUPPET
1818

1919
require_relative '../../puppet/datatypes/impl/error'
2020

lib/puppet/defaults.rb

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,7 @@ def self.initialize_default_settings!(settings)
430430
between the configured or resolved path.
431431
432432
When set to false, the resolved paths are reported instead of the configured paths.
433-
EOT
433+
EOT
434434
},
435435
:use_last_environment => {
436436
:type => :boolean,
@@ -441,7 +441,7 @@ def self.initialize_default_settings!(settings)
441441
environment and skip the node request.
442442
443443
When set to false, we will do the node request and ignore the environment data from the last_run_summary file.
444-
EOT
444+
EOT
445445
},
446446
:always_retry_plugins => {
447447
:type => :boolean,
@@ -462,7 +462,7 @@ def self.initialize_default_settings!(settings)
462462
feature. This behavior is almost always appropriate for the server,
463463
and can result in a significant performance improvement for types and
464464
features that are checked frequently.
465-
EOT
465+
EOT
466466
},
467467
:diff_args => {
468468
:default => lambda { default_diffargs },
@@ -493,10 +493,10 @@ def self.initialize_default_settings!(settings)
493493
currently cannot daemonize).",
494494
:short => "D",
495495
:hook => proc do |value|
496-
if value and Puppet::Util::Platform.windows?
497-
raise "Cannot daemonize on Windows"
498-
end
499-
end
496+
if value and Puppet::Util::Platform.windows?
497+
raise "Cannot daemonize on Windows"
498+
end
499+
end
500500
},
501501
:maximum_uid => {
502502
:default => 4294967290,
@@ -709,7 +709,7 @@ def self.initialize_default_settings!(settings)
709709
releases this value will only determine if file content is cached.
710710
711711
Valid values are 0 (never cache) and 15 (15 second minimum wait time).
712-
WARNING
712+
WARNING
713713
end
714714
end
715715
},

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/file_system/uniquefile.rb

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -100,14 +100,14 @@ def path
100100

101101
def make_tmpname(prefix_suffix, n)
102102
case prefix_suffix
103-
when String
104-
prefix = prefix_suffix
105-
suffix = ""
106-
when Array
107-
prefix = prefix_suffix[0]
108-
suffix = prefix_suffix[1]
109-
else
110-
raise ArgumentError, _("unexpected prefix_suffix: %{value}") % { value: prefix_suffix.inspect }
103+
when String
104+
prefix = prefix_suffix
105+
suffix = ""
106+
when Array
107+
prefix = prefix_suffix[0]
108+
suffix = prefix_suffix[1]
109+
else
110+
raise ArgumentError, _("unexpected prefix_suffix: %{value}") % { value: prefix_suffix.inspect }
111111
end
112112
t = Time.now.strftime("%Y%m%d")
113113
path = "#{prefix}#{t}-#{$$}-#{rand(0x100000000).to_s(36)}"

lib/puppet/http/dns.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,9 @@ def each_srv_record(domain, service_name = :puppet, &block)
4949
Puppet.debug "Searching for SRV records for domain: #{domain}"
5050

5151
case service_name
52-
when :puppet then service = '_x-puppet'
53-
when :file then service = '_x-puppet-fileserver'
54-
else service = "_x-puppet-#{service_name}"
52+
when :puppet then service = '_x-puppet'
53+
when :file then service = '_x-puppet-fileserver'
54+
else service = "_x-puppet-#{service_name}"
5555
end
5656
record_name = "#{service}._tcp.#{domain}"
5757

0 commit comments

Comments
 (0)