Skip to content

Commit e05d91c

Browse files
authored
Merge pull request #9222 from mhashizume/maint/main/rubocop-update
Update Rubocop
2 parents bf7710c + b00d968 commit e05d91c

Some content is hidden

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

46 files changed

+171
-62
lines changed

.rubocop.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ require:
77
- rubocop-rspec
88

99
AllCops:
10-
TargetRubyVersion: 2.5
10+
TargetRubyVersion: 3.1
1111
Include:
1212
- 'lib/**/*.rb'
1313
- 'ext/**/*.rb'

.rubocop_todo.yml

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,15 @@ I18n/GetText/DecorateStringFormattingUsingPercent:
2222
I18n/RailsI18n/DecorateString:
2323
Enabled: false
2424

25+
Lint/AmbiguousAssignment: # new in 1.7
26+
Enabled: false
27+
28+
Lint/AmbiguousOperatorPrecedence: # new in 1.21
29+
Enabled: false
30+
31+
Lint/AmbiguousRange: # new in 1.19
32+
Enabled: false
33+
2534
# Configuration parameters: AllowedMethods.
2635
# AllowedMethods: enums
2736
Lint/ConstantDefinitionInBlock:
@@ -42,9 +51,51 @@ Lint/ConstantDefinitionInBlock:
4251
- 'lib/puppet/type/schedule.rb'
4352
- 'lib/puppet/type/tidy.rb'
4453

54+
Lint/ConstantOverwrittenInRescue: # new in 1.31
55+
Enabled: false
56+
57+
Lint/DeprecatedConstants: # new in 1.8
58+
Enabled: false
59+
60+
Lint/DuplicateBranch: # new in 1.3
61+
Enabled: false
62+
63+
Lint/DuplicateMagicComment: # new in 1.37
64+
Enabled: false
65+
66+
Lint/DuplicateMatchPattern: # new in 1.50
67+
Enabled: false
68+
69+
Lint/DuplicateRegexpCharacterClassElement: # new in 1.1
70+
Enabled: false
71+
72+
Lint/EmptyBlock: # new in 1.1
73+
Enabled: false
74+
75+
Lint/EmptyClass: # new in 1.3
76+
Enabled: false
77+
78+
Lint/EmptyInPattern: # new in 1.16
79+
Enabled: false
80+
81+
Lint/IncompatibleIoSelectWithFiberScheduler: # new in 1.21
82+
Enabled: false
83+
84+
Lint/ItWithoutArgumentsInBlock: # new in 1.59
85+
Enabled: false
86+
87+
Lint/LambdaWithoutLiteralBlock: # new in 1.8
88+
Enabled: false
89+
90+
Lint/LiteralAssignmentInCondition: # new in 1.58
91+
Enabled: false
92+
4593
Lint/MissingSuper:
4694
Enabled: false
4795

96+
Lint/MixedCaseRange: # new in 1.53
97+
Enabled: false
98+
4899
Lint/NestedMethodDefinition:
49100
Exclude:
50101
- 'lib/puppet/pops/types/p_binary_type.rb'
@@ -59,6 +110,33 @@ Lint/NestedMethodDefinition:
59110
- 'lib/puppet/pops/types/types.rb'
60111
- 'lib/puppet/type.rb'
61112

113+
Lint/NonAtomicFileOperation: # new in 1.31
114+
Enabled: false
115+
116+
Lint/NoReturnInBeginEndBlocks: # new in 1.2
117+
Enabled: false
118+
119+
Lint/NumberedParameterAssignment: # new in 1.9
120+
Enabled: false
121+
122+
Lint/OrAssignmentToConstant: # new in 1.9
123+
Enabled: false
124+
125+
Lint/RedundantDirGlobSort: # new in 1.8
126+
Enabled: false
127+
128+
Lint/RedundantRegexpQuantifiers: # new in 1.53
129+
Enabled: false
130+
131+
Lint/RefinementImportMethods: # new in 1.27
132+
Enabled: false
133+
134+
Lint/RequireRangeParentheses: # new in 1.32
135+
Enabled: false
136+
137+
Lint/RequireRelativeSelfPath: # new in 1.22
138+
Enabled: false
139+
62140
Lint/RescueException:
63141
Exclude:
64142
- 'ext/windows/service/daemon.rb'
@@ -88,18 +166,39 @@ Lint/SuppressedException:
88166
- 'lib/puppet/util/execution.rb'
89167
- 'util/rspec_grouper'
90168

169+
Lint/SymbolConversion: # new in 1.9
170+
Enabled: false
171+
172+
Lint/ToEnumArguments: # new in 1.1
173+
Enabled: false
174+
91175
# This cop supports safe auto-correction (--auto-correct).
92176
Lint/ToJSON:
93177
Exclude:
94178
- 'lib/puppet/module_tool/metadata.rb'
95179
- 'lib/puppet/network/http/error.rb'
96180
- 'lib/puppet/pops/serialization/json.rb'
97181

182+
Lint/TripleQuotes: # new in 1.9
183+
Enabled: false
184+
185+
Lint/UnexpectedBlockArity: # new in 1.5
186+
Enabled: false
187+
188+
Lint/UnmodifiedReduceAccumulator: # new in 1.1
189+
Enabled: false
190+
98191
# This cop supports safe auto-correction (--auto-correct).
99192
# Configuration parameters: AllowUnusedKeywordArguments, IgnoreEmptyMethods, IgnoreNotImplementedMethods.
100193
Lint/UnusedMethodArgument:
101194
Enabled: false
102195

196+
Lint/UselessRescue: # new in 1.43
197+
Enabled: false
198+
199+
Lint/UselessRuby2Keywords: # new in 1.23
200+
Enabled: false
201+
103202
Performance/BlockGivenWithExplicitBlock: # new in 1.9
104203
Enabled: false
105204

Gemfile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,11 @@ group(:test) do
4747
gem 'webrick', '~> 1.7', require: false
4848
gem 'yard', require: false
4949

50-
gem 'rubocop', '1.28.0', require: false, platforms: [:ruby]
50+
gem 'rubocop', '~> 1.0', require: false, platforms: [:ruby]
5151
gem 'rubocop-i18n', '~> 3.0', require: false, platforms: [:ruby]
52-
gem 'rubocop-performance', '1.13.3', require: false, platforms: [:ruby]
53-
gem 'rubocop-rake', '0.6.0', require: false, platforms: [:ruby]
54-
gem 'rubocop-rspec', '2.10.0', require: false, platforms: [:ruby]
52+
gem 'rubocop-performance', '~> 1.0', require: false, platforms: [:ruby]
53+
gem 'rubocop-rake', '~> 0.6', require: false, platforms: [:ruby]
54+
gem 'rubocop-rspec', '~> 2.0', require: false, platforms: [:ruby]
5555
end
5656

5757
group(:development, optional: true) do

lib/puppet/application/agent.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -410,6 +410,7 @@ def log_config
410410
end
411411
end
412412

413+
# rubocop:disable Lint/RedundantStringCoercion
413414
def fingerprint
414415
Puppet::Util::Log.newdestination(:console)
415416
cert_provider = Puppet::X509::CertProvider.new
@@ -429,6 +430,7 @@ def fingerprint
429430
Puppet.log_exception(e, _("Failed to generate fingerprint: %{message}") % { message: e.message })
430431
exit(1)
431432
end
433+
# rubocop:enable Lint/RedundantStringCoercion
432434

433435
def onetime(daemon)
434436
begin

lib/puppet/application/face_base.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
require_relative '../../puppet/application'
44
require_relative '../../puppet/face'
55
require 'optparse'
6-
require 'pp'
76

87
class Puppet::Application::FaceBase < Puppet::Application
98
option("--debug", "-d") do |_arg|

lib/puppet/application/filebucket.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class Puppet::Application::Filebucket < Puppet::Application
1313
option("--remote", "-r")
1414
option("--verbose", "-v")
1515

16-
attr :args
16+
attr_reader :args
1717

1818
def summary
1919
_("Store and retrieve files in a filebucket")

lib/puppet/file_bucket/file.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class Puppet::FileBucket::File
1313
extend Puppet::Indirector
1414
indirects :file_bucket_file, :terminus_class => :selector
1515

16-
attr :bucket_path
16+
attr_reader :bucket_path
1717

1818
def self.supported_formats
1919
[:binary]

lib/puppet/functions/getvar.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ def get_from_navigation(scope, navigation, default_value = nil, &block)
6969
matches = navigation.match(/^((::)?(\w+::)*\w+)(.*)\z/)
7070
navigation = matches[4]
7171
if navigation[0] == '.'
72-
navigation = navigation[1..-1]
72+
navigation = navigation[1..]
7373
else
7474
unless navigation.empty?
7575
raise ArgumentError, _("First character after var name in get string must be a '.' - got %{char}") % { char: navigation[0] }

lib/puppet/metatype/manager.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def allclear
2828
#
2929
def clear_misses
3030
unless @types.nil?
31-
@types.delete_if { |_, v| v.nil? }
31+
@types.compact
3232
end
3333
end
3434

lib/puppet/module_tool/errors/shared.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,15 +106,15 @@ def initialize(options)
106106
@requested_module = options[:requested_module]
107107
@requested_version = options[:requested_version]
108108
@conditions = options[:conditions]
109-
@source = options[:source][1..-1]
109+
@source = options[:source][1..]
110110

111111
super _("'%{module_name}' (%{version}) requested; Invalid dependency cycle") % { module_name: @requested_module, version: v(@requested_version) }
112112
end
113113

114114
def multiline
115115
dependency_list = []
116116
dependency_list << _("You specified '%{name}' (%{version})") % { name: @source.first[:name], version: v(@requested_version) }
117-
dependency_list += @source[1..-1].map do |m|
117+
dependency_list += @source[1..].map do |m|
118118
# TRANSLATORS This message repeats as separate lines as a list under the heading "You specified '%{name}' (%{version})\n"
119119
_("This depends on '%{name}' (%{version})") % { name: m[:name], version: v(m[:version]) }
120120
end

0 commit comments

Comments
 (0)