Skip to content

Commit c921972

Browse files
authored
Merge pull request #9177 from joshcooper/rubocop_main_11931
(PUP-11931) Resolve Lint rubocops
2 parents ccaea43 + db04912 commit c921972

File tree

157 files changed

+259
-480
lines changed

Some content is hidden

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

157 files changed

+259
-480
lines changed

.rubocop.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,17 @@ AllCops:
1717
- 'lib/puppet/vendor/**/*'
1818
- 'lib/puppet/pops/parser/eparser.rb'
1919

20+
# puppet uses symbol booleans in types and providers to work around long standing
21+
# bugs when trying to manage falsey pararameters and properties
22+
Lint/BooleanSymbol:
23+
Enabled: true
24+
Exclude:
25+
- 'lib/puppet/type.rb'
26+
- 'lib/puppet/type/**/*.rb'
27+
- 'lib/puppet/provider/**/*.rb'
28+
- 'lib/puppet/reference/providers.rb'
29+
- 'lib/puppet/parameter/value.rb'
30+
2031
Metrics/AbcSize:
2132
Enabled: false
2233

.rubocop_todo.yml

Lines changed: 0 additions & 177 deletions
Original file line numberDiff line numberDiff line change
@@ -580,89 +580,14 @@ Layout/TrailingEmptyLines:
580580
Layout/TrailingWhitespace:
581581
Enabled: false
582582

583-
# This cop supports safe auto-correction (--auto-correct).
584-
Lint/BooleanSymbol:
585-
Enabled: false
586-
587583
# Configuration parameters: AllowedMethods.
588584
# AllowedMethods: enums
589585
Lint/ConstantDefinitionInBlock:
590586
Enabled: false
591587

592-
# This cop supports safe auto-correction (--auto-correct).
593-
Lint/DeprecatedOpenSSLConstant:
594-
Exclude:
595-
- 'lib/puppet/util/checksums.rb'
596-
- 'lib/puppet/x509/cert_provider.rb'
597-
598-
# This cop supports safe auto-correction (--auto-correct).
599-
Lint/ElseLayout:
600-
Exclude:
601-
- 'lib/puppet/resource.rb'
602-
603-
# Configuration parameters: AllowComments.
604-
Lint/EmptyWhen:
605-
Exclude:
606-
- 'lib/puppet/indirector/hiera.rb'
607-
- 'lib/puppet/pops/evaluator/evaluator_impl.rb'
608-
- 'lib/puppet/pops/lookup/data_dig_function_provider.rb'
609-
- 'lib/puppet/pops/types/type_formatter.rb'
610-
- 'lib/puppet/pops/types/type_mismatch_describer.rb'
611-
- 'lib/puppet/pops/types/types.rb'
612-
- 'lib/puppet/pops/validation/checker4_0.rb'
613-
- 'lib/puppet/util/backups.rb'
614-
- 'lib/puppet/util/windows/security.rb'
615-
616-
# This cop supports safe auto-correction (--auto-correct).
617-
Lint/EnsureReturn:
618-
Exclude:
619-
- 'lib/puppet/configurer.rb'
620-
621-
Lint/FloatComparison:
622-
Exclude:
623-
- 'lib/puppet/pops/types/types.rb'
624-
625-
Lint/HashCompareByIdentity:
626-
Exclude:
627-
- 'lib/puppet/pops/serialization/serializer.rb'
628-
- 'lib/puppet/pops/types/recursion_guard.rb'
629-
630-
# This cop supports safe auto-correction (--auto-correct).
631-
Lint/IdentityComparison:
632-
Exclude:
633-
- 'lib/puppet/parser/resource.rb'
634-
- 'lib/puppet/ssl/verifier.rb'
635-
- 'lib/puppet/type.rb'
636-
637-
# This cop supports safe auto-correction (--auto-correct).
638-
# Configuration parameters: EnforcedStyle.
639-
# SupportedStyles: standard_error, runtime_error
640-
Lint/InheritException:
641-
Exclude:
642-
- 'lib/puppet/agent.rb'
643-
- 'lib/puppet/network/http/error.rb'
644-
- 'lib/puppet/pops/evaluator/closure.rb'
645-
- 'lib/puppet/util/logging.rb'
646-
- 'lib/puppet/util/retry_action.rb'
647-
648-
# This cop supports unsafe auto-correction (--auto-correct-all).
649-
Lint/InterpolationCheck:
650-
Exclude:
651-
- 'lib/puppet/util/package/version/pip.rb'
652-
653-
# This cop supports safe auto-correction (--auto-correct).
654-
Lint/LiteralInInterpolation:
655-
Exclude:
656-
- 'lib/puppet/provider/package/yum.rb'
657-
- 'lib/puppet/type/component.rb'
658-
659588
Lint/MissingSuper:
660589
Enabled: false
661590

662-
Lint/MixedRegexpCaptureTypes:
663-
Exclude:
664-
- 'lib/puppet/util.rb'
665-
666591
Lint/NestedMethodDefinition:
667592
Exclude:
668593
- 'lib/puppet/pops/types/p_binary_type.rb'
@@ -677,28 +602,6 @@ Lint/NestedMethodDefinition:
677602
- 'lib/puppet/pops/types/types.rb'
678603
- 'lib/puppet/type.rb'
679604

680-
Lint/OutOfRangeRegexpRef:
681-
Exclude:
682-
- 'lib/puppet/vendor.rb'
683-
684-
# This cop supports safe auto-correction (--auto-correct).
685-
Lint/ParenthesesAsGroupedExpression:
686-
Exclude:
687-
- 'lib/puppet/face/epp.rb'
688-
- 'lib/puppet/face/parser.rb'
689-
- 'lib/puppet/util/retry_action.rb'
690-
691-
# This cop supports safe auto-correction (--auto-correct).
692-
Lint/RedundantCopDisableDirective:
693-
Exclude:
694-
- 'lib/puppet/pops/loader/static_loader.rb'
695-
- 'lib/puppet/util/posix.rb'
696-
697-
# This cop supports safe auto-correction (--auto-correct).
698-
Lint/RedundantRequireStatement:
699-
Exclude:
700-
- 'lib/puppet/type/file.rb'
701-
702605
Lint/RescueException:
703606
Exclude:
704607
- 'ext/windows/service/daemon.rb'
@@ -711,29 +614,6 @@ Lint/RescueException:
711614
- 'lib/puppet/util/command_line/trollop.rb'
712615
- 'util/rspec_grouper'
713616

714-
Lint/ReturnInVoidContext:
715-
Exclude:
716-
- 'lib/puppet/type/component.rb'
717-
- 'lib/puppet/util/suidmanager.rb'
718-
719-
Lint/SelfAssignment:
720-
Exclude:
721-
- 'lib/puppet/pops/evaluator/evaluator_impl.rb'
722-
- 'lib/puppet/pops/evaluator/runtime3_support.rb'
723-
- 'lib/puppet/pops/validation/validator_factory_4_0.rb'
724-
- 'lib/puppet/provider/nameservice/directoryservice.rb'
725-
726-
# Configuration parameters: IgnoreImplicitReferences.
727-
Lint/ShadowedArgument:
728-
Exclude:
729-
- 'lib/puppet/pops/lookup.rb'
730-
- 'lib/puppet/settings/file_setting.rb'
731-
- 'lib/puppet/settings/port_setting.rb'
732-
733-
Lint/StructNewOverride:
734-
Exclude:
735-
- 'lib/puppet/network/http/request.rb'
736-
737617
# Configuration parameters: AllowComments, AllowNil.
738618
Lint/SuppressedException:
739619
Exclude:
@@ -758,68 +638,11 @@ Lint/ToJSON:
758638
- 'lib/puppet/network/http/error.rb'
759639
- 'lib/puppet/pops/serialization/json.rb'
760640

761-
# Configuration parameters: AllowKeywordBlockArguments.
762-
Lint/UnderscorePrefixedVariableName:
763-
Exclude:
764-
- 'lib/puppet/pops/types/p_object_type.rb'
765-
- 'lib/puppet/type/file/checksum_value.rb'
766-
- 'lib/puppet/type/file/content.rb'
767-
768-
Lint/UnreachableCode:
769-
Exclude:
770-
- 'lib/puppet/provider/package/portupgrade.rb'
771-
772-
# Configuration parameters: AllowedPatterns, IgnoredPatterns.
773-
# AllowedPatterns: (?-mix:(exactly|at_least|at_most)\(\d+\)\.times)
774-
Lint/UnreachableLoop:
775-
Exclude:
776-
- 'lib/puppet/util/at_fork.rb'
777-
778-
# This cop supports safe auto-correction (--auto-correct).
779-
# Configuration parameters: IgnoreEmptyBlocks, AllowUnusedKeywordArguments.
780-
Lint/UnusedBlockArgument:
781-
Enabled: false
782-
783641
# This cop supports safe auto-correction (--auto-correct).
784642
# Configuration parameters: AllowUnusedKeywordArguments, IgnoreEmptyMethods, IgnoreNotImplementedMethods.
785643
Lint/UnusedMethodArgument:
786644
Enabled: false
787645

788-
# This cop supports safe auto-correction (--auto-correct).
789-
Lint/UriRegexp:
790-
Exclude:
791-
- 'lib/puppet/pops/pcore.rb'
792-
793-
# This cop supports safe auto-correction (--auto-correct).
794-
# Configuration parameters: ContextCreatingMethods, MethodCreatingMethods.
795-
Lint/UselessAccessModifier:
796-
Exclude:
797-
- 'lib/hiera_puppet.rb'
798-
799-
# This cop supports unsafe auto-correction (--auto-correct-all).
800-
Lint/UselessMethodDefinition:
801-
Exclude:
802-
- 'lib/puppet/pops/evaluator/closure.rb'
803-
- 'lib/puppet/pops/types/type_conversion_error.rb'
804-
- 'lib/puppet/pops/types/type_mismatch_describer.rb'
805-
- 'lib/puppet/settings/file_or_directory_setting.rb'
806-
- 'lib/puppet/util/profiler/aggregate.rb'
807-
- 'lib/puppet/util/rdoc/code_objects.rb'
808-
- 'lib/puppet/util/rdoc/generators/puppet_generator.rb'
809-
810-
# Configuration parameters: CheckForMethodsWithNoSideEffects.
811-
Lint/Void:
812-
Exclude:
813-
- 'lib/puppet/file_serving/http_metadata.rb'
814-
- 'lib/puppet/interface/documentation.rb'
815-
- 'lib/puppet/interface/option_builder.rb'
816-
- 'lib/puppet/node.rb'
817-
- 'lib/puppet/pops/model/factory.rb'
818-
- 'lib/puppet/provider/file/windows.rb'
819-
- 'lib/puppet/settings.rb'
820-
- 'lib/puppet/ssl/certificate_signer.rb'
821-
- 'lib/puppet/type.rb'
822-
823646
Naming/AccessorMethodName:
824647
Enabled: false
825648

lib/hiera_puppet.rb

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,6 @@ def parse_args(args)
4949
return [key, default, override]
5050
end
5151

52-
private
53-
module_function
54-
5552
def hiera
5653
@hiera ||= Hiera.new(:config => hiera_config)
5754
end

lib/puppet/agent.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class Puppet::Agent
1818
include Puppet::Util::Splayer
1919

2020
# Special exception class used to signal an agent run has timed out.
21-
class RunTimeoutError < Exception
21+
class RunTimeoutError < Exception # rubocop:disable Lint/InheritException
2222
end
2323

2424
attr_reader :client_class, :client, :should_fork

lib/puppet/application.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -327,13 +327,13 @@ def clear_everything_for_tests
327327
# Every app responds to --version
328328
# See also `lib/puppet/util/command_line.rb` for some special case early
329329
# handling of this.
330-
option("--version", "-V") do |arg|
330+
option("--version", "-V") do |_arg|
331331
puts "#{Puppet.version}"
332332
exit(0)
333333
end
334334

335335
# Every app responds to --help
336-
option("--help", "-h") do |v|
336+
option("--help", "-h") do |_v|
337337
puts help
338338
exit(0)
339339
end

lib/puppet/application/agent.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ def preinit
6464

6565
option("--sourceaddress IP_ADDRESS")
6666

67-
option("--detailed-exitcodes") do |arg|
67+
option("--detailed-exitcodes") do |_arg|
6868
options[:detailed_exitcodes] = true
6969
end
7070

lib/puppet/application/apply.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class Puppet::Application::Apply < Puppet::Application
2929
handle_logdest_arg(arg)
3030
end
3131

32-
option("--parseonly") do |args|
32+
option("--parseonly") do |_args|
3333
puts "--parseonly has been removed. Please use 'puppet parser validate <manifest>'"
3434
exit 1
3535
end

lib/puppet/application/describe.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ def list_providers(type)
166166
class Puppet::Application::Describe < Puppet::Application
167167
banner "puppet describe [options] [type]"
168168

169-
option("--short", "-s", "Only list parameters without detail") do |arg|
169+
option("--short", "-s", "Only list parameters without detail") do |_arg|
170170
options[:parameters] = false
171171
end
172172

lib/puppet/application/device.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ def preinit
5252
option("--to_yaml","-y")
5353
option("--verbose","-v")
5454

55-
option("--detailed-exitcodes") do |arg|
55+
option("--detailed-exitcodes") do |_arg|
5656
options[:detailed_exitcodes] = true
5757
end
5858

@@ -251,7 +251,7 @@ def main
251251
require_relative '../../puppet/util/network_device/config'
252252
devices = Puppet::Util::NetworkDevice::Config.devices.dup
253253
if options[:target]
254-
devices.select! { |key, value| key == options[:target] }
254+
devices.select! { |key, _value| key == options[:target] }
255255
end
256256
if devices.empty?
257257
if options[:target]
@@ -261,7 +261,7 @@ def main
261261
exit(1)
262262
end
263263
end
264-
devices.collect do |devicename,device|
264+
devices.collect do |_devicename,device|
265265
# TODO when we drop support for ruby < 2.5 we can remove the extra block here
266266
begin
267267
device_url = URI.parse(device.url)

lib/puppet/application/doc.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def preinit
3939
end
4040
end
4141

42-
option("--list", "-l") do |arg|
42+
option("--list", "-l") do |_arg|
4343
require_relative '../../puppet/util/reference'
4444
refs = Puppet::Util::Reference.references(Puppet.lookup(:current_environment))
4545
puts refs.collect { |r| Puppet::Util::Reference.reference(r).doc }.join("\n")

0 commit comments

Comments
 (0)