Skip to content

Commit

Permalink
Merge pull request #9177 from joshcooper/rubocop_main_11931
Browse files Browse the repository at this point in the history
(PUP-11931) Resolve Lint rubocops
  • Loading branch information
joshcooper authored Dec 5, 2023
2 parents ccaea43 + db04912 commit c921972
Show file tree
Hide file tree
Showing 157 changed files with 259 additions and 480 deletions.
11 changes: 11 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,17 @@ AllCops:
- 'lib/puppet/vendor/**/*'
- 'lib/puppet/pops/parser/eparser.rb'

# puppet uses symbol booleans in types and providers to work around long standing
# bugs when trying to manage falsey pararameters and properties
Lint/BooleanSymbol:
Enabled: true
Exclude:
- 'lib/puppet/type.rb'
- 'lib/puppet/type/**/*.rb'
- 'lib/puppet/provider/**/*.rb'
- 'lib/puppet/reference/providers.rb'
- 'lib/puppet/parameter/value.rb'

Metrics/AbcSize:
Enabled: false

Expand Down
177 changes: 0 additions & 177 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -580,89 +580,14 @@ Layout/TrailingEmptyLines:
Layout/TrailingWhitespace:
Enabled: false

# This cop supports safe auto-correction (--auto-correct).
Lint/BooleanSymbol:
Enabled: false

# Configuration parameters: AllowedMethods.
# AllowedMethods: enums
Lint/ConstantDefinitionInBlock:
Enabled: false

# This cop supports safe auto-correction (--auto-correct).
Lint/DeprecatedOpenSSLConstant:
Exclude:
- 'lib/puppet/util/checksums.rb'
- 'lib/puppet/x509/cert_provider.rb'

# This cop supports safe auto-correction (--auto-correct).
Lint/ElseLayout:
Exclude:
- 'lib/puppet/resource.rb'

# Configuration parameters: AllowComments.
Lint/EmptyWhen:
Exclude:
- 'lib/puppet/indirector/hiera.rb'
- 'lib/puppet/pops/evaluator/evaluator_impl.rb'
- 'lib/puppet/pops/lookup/data_dig_function_provider.rb'
- 'lib/puppet/pops/types/type_formatter.rb'
- 'lib/puppet/pops/types/type_mismatch_describer.rb'
- 'lib/puppet/pops/types/types.rb'
- 'lib/puppet/pops/validation/checker4_0.rb'
- 'lib/puppet/util/backups.rb'
- 'lib/puppet/util/windows/security.rb'

# This cop supports safe auto-correction (--auto-correct).
Lint/EnsureReturn:
Exclude:
- 'lib/puppet/configurer.rb'

Lint/FloatComparison:
Exclude:
- 'lib/puppet/pops/types/types.rb'

Lint/HashCompareByIdentity:
Exclude:
- 'lib/puppet/pops/serialization/serializer.rb'
- 'lib/puppet/pops/types/recursion_guard.rb'

# This cop supports safe auto-correction (--auto-correct).
Lint/IdentityComparison:
Exclude:
- 'lib/puppet/parser/resource.rb'
- 'lib/puppet/ssl/verifier.rb'
- 'lib/puppet/type.rb'

# This cop supports safe auto-correction (--auto-correct).
# Configuration parameters: EnforcedStyle.
# SupportedStyles: standard_error, runtime_error
Lint/InheritException:
Exclude:
- 'lib/puppet/agent.rb'
- 'lib/puppet/network/http/error.rb'
- 'lib/puppet/pops/evaluator/closure.rb'
- 'lib/puppet/util/logging.rb'
- 'lib/puppet/util/retry_action.rb'

# This cop supports unsafe auto-correction (--auto-correct-all).
Lint/InterpolationCheck:
Exclude:
- 'lib/puppet/util/package/version/pip.rb'

# This cop supports safe auto-correction (--auto-correct).
Lint/LiteralInInterpolation:
Exclude:
- 'lib/puppet/provider/package/yum.rb'
- 'lib/puppet/type/component.rb'

Lint/MissingSuper:
Enabled: false

Lint/MixedRegexpCaptureTypes:
Exclude:
- 'lib/puppet/util.rb'

Lint/NestedMethodDefinition:
Exclude:
- 'lib/puppet/pops/types/p_binary_type.rb'
Expand All @@ -677,28 +602,6 @@ Lint/NestedMethodDefinition:
- 'lib/puppet/pops/types/types.rb'
- 'lib/puppet/type.rb'

Lint/OutOfRangeRegexpRef:
Exclude:
- 'lib/puppet/vendor.rb'

# This cop supports safe auto-correction (--auto-correct).
Lint/ParenthesesAsGroupedExpression:
Exclude:
- 'lib/puppet/face/epp.rb'
- 'lib/puppet/face/parser.rb'
- 'lib/puppet/util/retry_action.rb'

# This cop supports safe auto-correction (--auto-correct).
Lint/RedundantCopDisableDirective:
Exclude:
- 'lib/puppet/pops/loader/static_loader.rb'
- 'lib/puppet/util/posix.rb'

# This cop supports safe auto-correction (--auto-correct).
Lint/RedundantRequireStatement:
Exclude:
- 'lib/puppet/type/file.rb'

Lint/RescueException:
Exclude:
- 'ext/windows/service/daemon.rb'
Expand All @@ -711,29 +614,6 @@ Lint/RescueException:
- 'lib/puppet/util/command_line/trollop.rb'
- 'util/rspec_grouper'

Lint/ReturnInVoidContext:
Exclude:
- 'lib/puppet/type/component.rb'
- 'lib/puppet/util/suidmanager.rb'

Lint/SelfAssignment:
Exclude:
- 'lib/puppet/pops/evaluator/evaluator_impl.rb'
- 'lib/puppet/pops/evaluator/runtime3_support.rb'
- 'lib/puppet/pops/validation/validator_factory_4_0.rb'
- 'lib/puppet/provider/nameservice/directoryservice.rb'

# Configuration parameters: IgnoreImplicitReferences.
Lint/ShadowedArgument:
Exclude:
- 'lib/puppet/pops/lookup.rb'
- 'lib/puppet/settings/file_setting.rb'
- 'lib/puppet/settings/port_setting.rb'

Lint/StructNewOverride:
Exclude:
- 'lib/puppet/network/http/request.rb'

# Configuration parameters: AllowComments, AllowNil.
Lint/SuppressedException:
Exclude:
Expand All @@ -758,68 +638,11 @@ Lint/ToJSON:
- 'lib/puppet/network/http/error.rb'
- 'lib/puppet/pops/serialization/json.rb'

# Configuration parameters: AllowKeywordBlockArguments.
Lint/UnderscorePrefixedVariableName:
Exclude:
- 'lib/puppet/pops/types/p_object_type.rb'
- 'lib/puppet/type/file/checksum_value.rb'
- 'lib/puppet/type/file/content.rb'

Lint/UnreachableCode:
Exclude:
- 'lib/puppet/provider/package/portupgrade.rb'

# Configuration parameters: AllowedPatterns, IgnoredPatterns.
# AllowedPatterns: (?-mix:(exactly|at_least|at_most)\(\d+\)\.times)
Lint/UnreachableLoop:
Exclude:
- 'lib/puppet/util/at_fork.rb'

# This cop supports safe auto-correction (--auto-correct).
# Configuration parameters: IgnoreEmptyBlocks, AllowUnusedKeywordArguments.
Lint/UnusedBlockArgument:
Enabled: false

# This cop supports safe auto-correction (--auto-correct).
# Configuration parameters: AllowUnusedKeywordArguments, IgnoreEmptyMethods, IgnoreNotImplementedMethods.
Lint/UnusedMethodArgument:
Enabled: false

# This cop supports safe auto-correction (--auto-correct).
Lint/UriRegexp:
Exclude:
- 'lib/puppet/pops/pcore.rb'

# This cop supports safe auto-correction (--auto-correct).
# Configuration parameters: ContextCreatingMethods, MethodCreatingMethods.
Lint/UselessAccessModifier:
Exclude:
- 'lib/hiera_puppet.rb'

# This cop supports unsafe auto-correction (--auto-correct-all).
Lint/UselessMethodDefinition:
Exclude:
- 'lib/puppet/pops/evaluator/closure.rb'
- 'lib/puppet/pops/types/type_conversion_error.rb'
- 'lib/puppet/pops/types/type_mismatch_describer.rb'
- 'lib/puppet/settings/file_or_directory_setting.rb'
- 'lib/puppet/util/profiler/aggregate.rb'
- 'lib/puppet/util/rdoc/code_objects.rb'
- 'lib/puppet/util/rdoc/generators/puppet_generator.rb'

# Configuration parameters: CheckForMethodsWithNoSideEffects.
Lint/Void:
Exclude:
- 'lib/puppet/file_serving/http_metadata.rb'
- 'lib/puppet/interface/documentation.rb'
- 'lib/puppet/interface/option_builder.rb'
- 'lib/puppet/node.rb'
- 'lib/puppet/pops/model/factory.rb'
- 'lib/puppet/provider/file/windows.rb'
- 'lib/puppet/settings.rb'
- 'lib/puppet/ssl/certificate_signer.rb'
- 'lib/puppet/type.rb'

Naming/AccessorMethodName:
Enabled: false

Expand Down
3 changes: 0 additions & 3 deletions lib/hiera_puppet.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,6 @@ def parse_args(args)
return [key, default, override]
end

private
module_function

def hiera
@hiera ||= Hiera.new(:config => hiera_config)
end
Expand Down
2 changes: 1 addition & 1 deletion lib/puppet/agent.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class Puppet::Agent
include Puppet::Util::Splayer

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

attr_reader :client_class, :client, :should_fork
Expand Down
4 changes: 2 additions & 2 deletions lib/puppet/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -327,13 +327,13 @@ def clear_everything_for_tests
# Every app responds to --version
# See also `lib/puppet/util/command_line.rb` for some special case early
# handling of this.
option("--version", "-V") do |arg|
option("--version", "-V") do |_arg|
puts "#{Puppet.version}"
exit(0)
end

# Every app responds to --help
option("--help", "-h") do |v|
option("--help", "-h") do |_v|
puts help
exit(0)
end
Expand Down
2 changes: 1 addition & 1 deletion lib/puppet/application/agent.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def preinit

option("--sourceaddress IP_ADDRESS")

option("--detailed-exitcodes") do |arg|
option("--detailed-exitcodes") do |_arg|
options[:detailed_exitcodes] = true
end

Expand Down
2 changes: 1 addition & 1 deletion lib/puppet/application/apply.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class Puppet::Application::Apply < Puppet::Application
handle_logdest_arg(arg)
end

option("--parseonly") do |args|
option("--parseonly") do |_args|
puts "--parseonly has been removed. Please use 'puppet parser validate <manifest>'"
exit 1
end
Expand Down
2 changes: 1 addition & 1 deletion lib/puppet/application/describe.rb
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ def list_providers(type)
class Puppet::Application::Describe < Puppet::Application
banner "puppet describe [options] [type]"

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

Expand Down
6 changes: 3 additions & 3 deletions lib/puppet/application/device.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def preinit
option("--to_yaml","-y")
option("--verbose","-v")

option("--detailed-exitcodes") do |arg|
option("--detailed-exitcodes") do |_arg|
options[:detailed_exitcodes] = true
end

Expand Down Expand Up @@ -251,7 +251,7 @@ def main
require_relative '../../puppet/util/network_device/config'
devices = Puppet::Util::NetworkDevice::Config.devices.dup
if options[:target]
devices.select! { |key, value| key == options[:target] }
devices.select! { |key, _value| key == options[:target] }
end
if devices.empty?
if options[:target]
Expand All @@ -261,7 +261,7 @@ def main
exit(1)
end
end
devices.collect do |devicename,device|
devices.collect do |_devicename,device|
# TODO when we drop support for ruby < 2.5 we can remove the extra block here
begin
device_url = URI.parse(device.url)
Expand Down
2 changes: 1 addition & 1 deletion lib/puppet/application/doc.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def preinit
end
end

option("--list", "-l") do |arg|
option("--list", "-l") do |_arg|
require_relative '../../puppet/util/reference'
refs = Puppet::Util::Reference.references(Puppet.lookup(:current_environment))
puts refs.collect { |r| Puppet::Util::Reference.reference(r).doc }.join("\n")
Expand Down
8 changes: 4 additions & 4 deletions lib/puppet/application/face_base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
require 'pp'

class Puppet::Application::FaceBase < Puppet::Application
option("--debug", "-d") do |arg|
option("--debug", "-d") do |_arg|
set_log_level(:debug => true)
end

Expand All @@ -17,7 +17,7 @@ class Puppet::Application::FaceBase < Puppet::Application
self.render_as = format.to_sym
end

option("--help", "-h") do |arg|
option("--help", "-h") do |_arg|
if action && !@is_default_action
# Only invoke help on the action if it was specified, not if
# it was the default action.
Expand Down Expand Up @@ -155,7 +155,7 @@ def parse_options
end

def find_global_settings_argument(item)
Puppet.settings.each do |name, object|
Puppet.settings.each do |_name, object|
object.optparse_args.each do |arg|
next unless arg =~ /^-/
# sadly, we have to emulate some of optparse here...
Expand All @@ -167,7 +167,7 @@ def find_global_settings_argument(item)
end

def find_application_argument(item)
self.class.option_parser_commands.each do |options, function|
self.class.option_parser_commands.each do |options, _function|
options.each do |option|
next unless option =~ /^-/
pattern = /^#{option.sub('[no-]', '').sub(/[ =].*$/, '')}(?:[ =].*)?$/
Expand Down
2 changes: 1 addition & 1 deletion lib/puppet/application/resource.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def preinit
option("--edit","-e")
option("--to_yaml","-y")

option("--types", "-t") do |arg|
option("--types", "-t") do |_arg|
env = Puppet.lookup(:environments).get(Puppet[:environment]) || create_default_environment
types = []
Puppet::Type.typeloader.loadall(env)
Expand Down
4 changes: 2 additions & 2 deletions lib/puppet/coercion.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ def self.boolean(value)
end

case value
when true, :true, 'true', :yes, 'yes'
when true, :true, 'true', :yes, 'yes' # rubocop:disable Lint/BooleanSymbol
true
when false, :false, 'false', :no, 'no'
when false, :false, 'false', :no, 'no' # rubocop:disable Lint/BooleanSymbol
false
else
fail('expected a boolean value')
Expand Down
Loading

0 comments on commit c921972

Please sign in to comment.