Skip to content

Commit b95da82

Browse files
authored
Merge pull request #9238 from tvpartytonight/PUP-11767_todo_cleanup
(PUP-11767) Rubocop todo cleanup
2 parents 3379bce + 821a7c4 commit b95da82

Some content is hidden

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

64 files changed

+183
-354
lines changed

.rubocop.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,11 @@ Style/ColonMethodCall:
226226

227227
Style/CombinableLoops:
228228
Enabled: true
229+
Exclude:
230+
- 'lib/puppet/graph/relationship_graph.rb'
231+
- 'lib/puppet/pops/types/ruby_generator.rb'
232+
- 'lib/puppet/provider/service/init.rb'
233+
- 'lib/puppet/util/rdoc/generators/puppet_generator.rb'
229234

230235
Style/ColonMethodDefinition:
231236
Enabled: true
@@ -307,6 +312,8 @@ Style/HashEachMethods:
307312

308313
Style/HashLikeCase:
309314
Enabled: true
315+
Exclude:
316+
- 'lib/puppet/util/command_line/trollop.rb'
310317

311318
Style/HashTransformKeys:
312319
Enabled: true

.rubocop_todo.yml

Lines changed: 2 additions & 165 deletions
Original file line numberDiff line numberDiff line change
@@ -346,68 +346,24 @@ Style/CaseEquality:
346346
- 'lib/puppet/interface/face_collection.rb'
347347
- 'lib/puppet/module_tool/installed_modules.rb'
348348
- 'lib/puppet/module_tool/shared_behaviors.rb'
349-
- 'lib/puppet/provider/package/pip.rb'
350-
- 'lib/puppet/provider/package/pkgin.rb'
351-
- 'lib/puppet/settings/integer_setting.rb'
352349
- 'lib/puppet/util/command_line/puppet_option_parser.rb'
353350
- 'lib/puppet/util/log/destination.rb'
354351
- 'lib/puppet/util/multi_match.rb'
355352
- 'lib/puppet/util/rdoc/generators/puppet_generator.rb'
356353

357-
# This cop supports unsafe auto-correction (--auto-correct-all).
358-
Style/CaseLikeIf:
359-
Enabled: false
360-
361354
# This cop supports safe auto-correction (--auto-correct).
362355
# Configuration parameters: EnforcedStyle.
363356
# SupportedStyles: nested, compact
364357
Style/ClassAndModuleChildren:
365358
Enabled: false
366359

367-
# This cop supports safe auto-correction (--auto-correct).
368-
# Configuration parameters: EnforcedStyle.
369-
# SupportedStyles: is_a?, kind_of?
370-
Style/ClassCheck:
371-
Exclude:
372-
- 'lib/puppet/error.rb'
373-
- 'lib/puppet/functions.rb'
374-
- 'lib/puppet/graph/simple_graph.rb'
375-
- 'lib/puppet/node/environment.rb'
376-
- 'lib/puppet/provider/group/groupadd.rb'
377-
- 'lib/puppet/provider/group/windows_adsi.rb'
378-
- 'lib/puppet/provider/user/windows_adsi.rb'
379-
- 'lib/puppet/settings.rb'
380-
- 'lib/puppet/settings/environment_conf.rb'
381-
- 'lib/puppet/type.rb'
382-
- 'lib/puppet/util/suidmanager.rb'
383-
- 'lib/puppet/util/windows/adsi.rb'
384-
- 'lib/puppet/util/windows/sid.rb'
385-
386-
# This cop supports safe auto-correction (--auto-correct).
387-
# Configuration parameters: IgnoredMethods.
388-
# IgnoredMethods: ==, equal?, eql?
389-
Style/ClassEqualityComparison:
390-
Enabled: false
391-
392-
# This cop supports safe auto-correction (--auto-correct).
393-
Style/ClassMethods:
394-
Exclude:
395-
- 'lib/puppet/util/rdoc/generators/puppet_generator.rb'
396-
397360
Style/ClassVars:
398361
Enabled: false
399362

400363
# This cop supports safe auto-correction (--auto-correct).
401364
Style/ColonMethodCall:
402365
Enabled: false
403366

404-
Style/CombinableLoops:
405-
Exclude:
406-
- 'lib/puppet/graph/relationship_graph.rb'
407-
- 'lib/puppet/pops/types/ruby_generator.rb'
408-
- 'lib/puppet/provider/service/init.rb'
409-
- 'lib/puppet/util/rdoc/generators/puppet_generator.rb'
410-
411367
# This cop supports safe auto-correction (--auto-correct).
412368
# Configuration parameters: EnforcedStyle, AllowInnerBackticks.
413369
# SupportedStyles: backticks, percent_x, mixed
@@ -444,9 +400,6 @@ Style/ConditionalAssignment:
444400
Style/DateTime:
445401
Enabled: false
446402

447-
Style/DefWithParentheses:
448-
Enabled: false
449-
450403
# Configuration parameters: AllowedConstants.
451404
Style/Documentation:
452405
Enabled: false
@@ -469,26 +422,6 @@ Style/DoubleNegation:
469422
- 'lib/puppet/util/feature.rb'
470423
- 'lib/puppet/util/windows/adsi.rb'
471424

472-
# This cop supports safe auto-correction (--auto-correct).
473-
Style/EachWithObject:
474-
Enabled: false
475-
476-
# This cop supports safe auto-correction (--auto-correct).
477-
Style/EmptyBlockParameter:
478-
Exclude:
479-
- 'lib/puppet/parser/type_loader.rb'
480-
481-
# This cop supports safe auto-correction (--auto-correct).
482-
Style/EmptyCaseCondition:
483-
Exclude:
484-
- 'lib/puppet/pops/serialization/serializer.rb'
485-
- 'lib/puppet/pops/types/type_calculator.rb'
486-
- 'lib/puppet/settings.rb'
487-
- 'lib/puppet/settings/duration_setting.rb'
488-
- 'lib/puppet/settings/priority_setting.rb'
489-
- 'lib/puppet/settings/ttl_setting.rb'
490-
- 'lib/puppet/type.rb'
491-
492425
# This cop supports safe auto-correction (--auto-correct).
493426
# Configuration parameters: EnforcedStyle.
494427
# SupportedStyles: empty, nil, both
@@ -526,30 +459,10 @@ Style/Encoding:
526459
- 'lib/puppet/type/package.rb'
527460
- 'lib/puppet/util/windows/service.rb'
528461

529-
# This cop supports safe auto-correction (--auto-correct).
530-
Style/EvenOdd:
531-
Exclude:
532-
- 'lib/puppet/pops/serialization/json.rb'
533-
- 'lib/puppet/pops/types/types.rb'
534-
535-
# This cop supports safe auto-correction (--auto-correct).
536-
Style/ExpandPathArguments:
537-
Exclude:
538-
- 'lib/puppet/util/libuser.rb'
539-
540462
# This cop supports safe auto-correction (--auto-correct).
541463
Style/ExplicitBlockArgument:
542464
Enabled: false
543465

544-
# This cop supports safe auto-correction (--auto-correct).
545-
# Configuration parameters: EnforcedStyle.
546-
# SupportedStyles: each, for
547-
Style/For:
548-
Exclude:
549-
- 'lib/puppet/file_system/uniquefile.rb'
550-
- 'lib/puppet/module_tool/contents_description.rb'
551-
- 'lib/puppet/util/rdoc/generators/puppet_generator.rb'
552-
553466
# This cop supports safe auto-correction (--auto-correct).
554467
# Configuration parameters: EnforcedStyle.
555468
# SupportedStyles: format, sprintf, percent
@@ -562,6 +475,7 @@ Style/FormatStringToken:
562475
Enabled: false
563476

564477
# This cop supports safe auto-correction (--auto-correct).
478+
# Applying the safe auto-correct results in util_spec failures.
565479
Style/GlobalStdStream:
566480
Exclude:
567481
- 'lib/puppet/application/apply.rb'
@@ -583,59 +497,19 @@ Style/GlobalVars:
583497
Style/GuardClause:
584498
Enabled: false
585499

586-
# This cop supports unsafe auto-correction (--auto-correct-all).
587-
# Configuration parameters: AllowedReceivers.
588-
Style/HashEachMethods:
589-
Enabled: false
590-
591-
# Configuration parameters: MinBranchesCount.
592-
Style/HashLikeCase:
593-
Exclude:
594-
- 'lib/puppet/util/command_line/trollop.rb'
595-
596500
# This cop supports safe auto-correction (--auto-correct).
597501
# Configuration parameters: EnforcedStyle, EnforcedShorthandSyntax, UseHashRocketsWithSymbolValues, PreferHashRocketsForNonAlnumEndingSymbols.
598502
# SupportedStyles: ruby19, hash_rockets, no_mixed_keys, ruby19_no_mixed_keys
599503
# SupportedShorthandSyntax: always, never, either
600504
Style/HashSyntax:
601505
Enabled: false
602506

603-
# This cop supports unsafe auto-correction (--auto-correct-all).
604-
Style/HashTransformValues:
605-
Exclude:
606-
- 'lib/puppet/functions/group_by.rb'
607-
- 'lib/puppet/parser/scope.rb'
608-
- 'lib/puppet/pops/loader/task_instantiator.rb'
609-
- 'lib/puppet/pops/types/p_type_set_type.rb'
610-
- 'lib/puppet/transaction/report.rb'
611-
612-
# This cop supports safe auto-correction (--auto-correct).
613-
Style/IdenticalConditionalBranches:
614-
Exclude:
615-
- 'lib/puppet/functions/filter.rb'
616-
- 'lib/puppet/network/http_pool.rb'
617-
- 'lib/puppet/node.rb'
618-
- 'lib/puppet/parser/resource.rb'
619-
- 'lib/puppet/pops/loader/module_loaders.rb'
620-
- 'lib/puppet/pops/types/p_type_set_type.rb'
621-
- 'lib/puppet/type.rb'
622-
- 'lib/puppet/util/feature.rb'
623-
624-
# This cop supports safe auto-correction (--auto-correct).
625-
# Configuration parameters: AllowIfModifier.
626-
Style/IfInsideElse:
627-
Enabled: false
628-
629507
# This cop supports safe auto-correction (--auto-correct).
630508
Style/IfUnlessModifier:
631509
Enabled: false
632510

633511
# This cop supports safe auto-correction (--auto-correct).
634-
Style/IfUnlessModifierOfIfUnless:
635-
Exclude:
636-
- 'lib/puppet/util/command_line/trollop.rb'
637-
638-
# This cop supports safe auto-correction (--auto-correct).
512+
# The auto-correct function introduces testing errors in the evaluating_parser_spec
639513
Style/IfWithSemicolon:
640514
Exclude:
641515
- 'lib/puppet/pops/parser/evaluating_parser.rb'
@@ -644,11 +518,6 @@ Style/IfWithSemicolon:
644518
Style/ImplicitRuntimeError:
645519
Enabled: false
646520

647-
# This cop supports unsafe auto-correction (--auto-correct-all).
648-
Style/InfiniteLoop:
649-
Exclude:
650-
- 'lib/puppet/util/posix.rb'
651-
652521
# This cop supports unsafe auto-correction (--auto-correct-all).
653522
# Configuration parameters: InverseMethods, InverseBlocks.
654523
Style/InverseMethods:
@@ -665,38 +534,6 @@ Style/InverseMethods:
665534
- 'lib/puppet/reference/providers.rb'
666535
- 'lib/puppet/type/file.rb'
667536

668-
# This cop supports safe auto-correction (--auto-correct).
669-
Style/KeywordParametersOrder:
670-
Exclude:
671-
- 'lib/puppet/http/service/file_server.rb'
672-
673-
# This cop supports safe auto-correction (--auto-correct).
674-
# Configuration parameters: EnforcedStyle.
675-
# SupportedStyles: line_count_dependent, lambda, literal
676-
Style/Lambda:
677-
Exclude:
678-
- 'lib/puppet/defaults.rb'
679-
- 'lib/puppet/functions/unique.rb'
680-
- 'lib/puppet/graph/relationship_graph.rb'
681-
- 'lib/puppet/http/session.rb'
682-
- 'lib/puppet/pops/lookup/interpolation.rb'
683-
- 'lib/puppet/pops/parser/lexer2.rb'
684-
- 'lib/puppet/provider/aix_object.rb'
685-
- 'lib/puppet/provider/service/upstart.rb'
686-
- 'lib/puppet/transaction.rb'
687-
- 'lib/puppet/util/command_line/puppet_option_parser.rb'
688-
- 'lib/puppet/util/symbolic_file_mode.rb'
689-
690-
# This cop supports safe auto-correction (--auto-correct).
691-
Style/LineEndConcatenation:
692-
Exclude:
693-
- 'lib/puppet/functions.rb'
694-
- 'lib/puppet/module.rb'
695-
- 'lib/puppet/network/http/api.rb'
696-
- 'lib/puppet/provider/user/directoryservice.rb'
697-
- 'lib/puppet/util/windows/file.rb'
698-
- 'lib/puppet/util/windows/process.rb'
699-
700537
# This cop supports safe auto-correction (--auto-correct).
701538
# Configuration parameters: IgnoredMethods.
702539
Style/MethodCallWithoutArgsParentheses:

lib/puppet/defaults.rb

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,7 @@ def self.initialize_default_settings!(settings)
467467
EOT
468468
},
469469
:diff_args => {
470-
:default => lambda { default_diffargs },
470+
:default => -> { default_diffargs },
471471
:desc => "Which arguments to pass to the diff command when printing differences between
472472
files. The command to use can be chosen with the `diff` setting.",
473473
},
@@ -818,7 +818,7 @@ def self.initialize_default_settings!(settings)
818818
# We have to downcase the fqdn, because the current ssl stuff (as opposed to in master) doesn't have good facilities for
819819
# manipulating naming.
820820
:certname => {
821-
:default => lambda { Puppet::Settings.default_certname.downcase },
821+
:default => -> { Puppet::Settings.default_certname.downcase },
822822
:desc => "The name to use when handling certificates. When a node
823823
requests a certificate from the CA Puppet Server, it uses the value of the
824824
`certname` setting as its requested Subject CN.
@@ -1086,15 +1086,15 @@ def self.initialize_default_settings!(settings)
10861086
Default is `prime256v1`."
10871087
},
10881088
:digest_algorithm => {
1089-
:default => lambda { default_digest_algorithm },
1089+
:default => -> { default_digest_algorithm },
10901090
:type => :enum,
10911091
:values => valid_digest_algorithms,
10921092
:desc => "Which digest algorithm to use for file resources and the filebucket.
10931093
Valid values are #{valid_digest_algorithms.join(', ')}. Default is
10941094
#{default_digest_algorithm}.",
10951095
},
10961096
:supported_checksum_types => {
1097-
:default => lambda { default_file_checksum_types },
1097+
:default => -> { default_file_checksum_types },
10981098
:type => :array,
10991099
:desc => "Checksum types supported by this agent for use in file resources of a
11001100
static catalog. Values must be comma-separated. Valid types are
@@ -1129,7 +1129,7 @@ def self.initialize_default_settings!(settings)
11291129
:desc => "The name to use the Certificate Authority certificate.",
11301130
},
11311131
:cadir => {
1132-
:default => lambda { default_cadir },
1132+
:default => -> { default_cadir },
11331133
:type => :directory,
11341134
:desc => "The root directory for the certificate authority.",
11351135
},
@@ -1419,7 +1419,7 @@ def self.initialize_default_settings!(settings)
14191419
:desc => "File that provides mapping between custom SSL oids and user-friendly names"
14201420
},
14211421
:basemodulepath => {
1422-
:default => lambda { default_basemodulepath },
1422+
:default => -> { default_basemodulepath },
14231423
:type => :path,
14241424
:desc => "The search path for **global** modules. Should be specified as a
14251425
list of directories separated by the system path separator character. (The
@@ -1431,7 +1431,7 @@ def self.initialize_default_settings!(settings)
14311431
<https://puppet.com/docs/puppet/latest/environments_about.html>",
14321432
},
14331433
:vendormoduledir => {
1434-
:default => lambda { default_vendormoduledir },
1434+
:default => -> { default_vendormoduledir },
14351435
:type => :string,
14361436
:desc => "The directory containing **vendored** modules. These modules will
14371437
be used by _all_ environments like those in the `basemodulepath`. The only
@@ -1666,7 +1666,7 @@ def self.initialize_default_settings!(settings)
16661666
:desc => "Whether the server will search for SRV records in DNS for the current domain.",
16671667
},
16681668
:srv_domain => {
1669-
:default => lambda { Puppet::Settings.domain_fact },
1669+
:default => -> { Puppet::Settings.domain_fact },
16701670
:desc => "The domain which will be queried to find the SRV records of servers to use.",
16711671
},
16721672
:http_extra_headers => {

lib/puppet/error.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ module ExternalFileError
2121
# 4 args including the position on the line.
2222
#
2323
def initialize(message, file = nil, line = nil, pos = nil, original = nil)
24-
if pos.kind_of? Exception
24+
if pos.is_a? Exception
2525
original = pos
2626
pos = nil
2727
end

lib/puppet/file_system/uniquefile.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ def try_convert_to_hash(h)
153153

154154
def tmpdir
155155
tmp = '.'
156-
for dir in [ENV.fetch('TMPDIR', nil), ENV.fetch('TMP', nil), ENV.fetch('TEMP', nil), @@systmpdir, '/tmp']
156+
[ENV.fetch('TMPDIR', nil), ENV.fetch('TMP', nil), ENV.fetch('TEMP', nil), @@systmpdir, '/tmp'].each do |dir|
157157
stat = File.stat(dir) if dir
158158
if stat && stat.directory? && stat.writable?
159159
tmp = dir

0 commit comments

Comments
 (0)