Skip to content

Commit f6f9066

Browse files
authored
Upgrade rubocop and fix new cops
1 parent 6c7c0c5 commit f6f9066

File tree

6 files changed

+162
-15
lines changed

6 files changed

+162
-15
lines changed

.rubocop.yml

Lines changed: 152 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ inherit_mode:
1212
- Exclude # Merge my AllCops.Exclude with default exludes from https://github.com/rubocop/rubocop/blob/master/config/default.yml
1313

1414
# Standard Cops
15-
Gemspec/DateAssignment:
15+
Gemspec/DeprecatedAttributeAssignment:
1616
Enabled: true
1717
Gemspec/RequireMFA:
1818
Enabled: true
@@ -68,19 +68,19 @@ Naming/BlockForwarding:
6868
Enabled: true
6969
Metrics/AbcSize:
7070
Enabled: true
71-
IgnoredMethods:
71+
AllowedMethods:
7272
- detect_line_tag
7373
Metrics/ClassLength:
7474
Enabled: true
7575
Metrics/CyclomaticComplexity:
7676
Enabled: true
77-
IgnoredMethods:
77+
AllowedMethods:
7878
- detect_line_tag
7979
- parse_any
8080
Metrics/MethodLength:
8181
Enabled: true
8282
Max: 15
83-
IgnoredMethods:
83+
AllowedMethods:
8484
- test_hash_multiline_key_all_cases
8585
- test_hash_key_line_endings
8686
- test_array_with_multiple_hash
@@ -90,7 +90,7 @@ Metrics/MethodLength:
9090
- parse_any
9191
Metrics/PerceivedComplexity:
9292
Enabled: true
93-
IgnoredMethods:
93+
AllowedMethods:
9494
- detect_line_tag
9595
Security/IoMethods:
9696
Enabled: true
@@ -157,3 +157,150 @@ require:
157157
# Reference: https://github.com/rubocop/rubocop-rake/blob/master/config/default.yml
158158
Rake:
159159
Enabled: true
160+
161+
162+
163+
Gemspec/AddRuntimeDependency: # new in 1.65
164+
Enabled: true
165+
Gemspec/DevelopmentDependencies: # new in 1.44
166+
Enabled: true
167+
Layout/LineContinuationLeadingSpace: # new in 1.31
168+
Enabled: true
169+
Layout/LineContinuationSpacing: # new in 1.31
170+
Enabled: true
171+
Lint/ArrayLiteralInRegexp: # new in 1.71
172+
Enabled: true
173+
Lint/ConstantOverwrittenInRescue: # new in 1.31
174+
Enabled: true
175+
Lint/ConstantReassignment: # new in 1.70
176+
Enabled: true
177+
Lint/DuplicateMagicComment: # new in 1.37
178+
Enabled: true
179+
Lint/DuplicateMatchPattern: # new in 1.50
180+
Enabled: true
181+
Lint/DuplicateSetElement: # new in 1.67
182+
Enabled: true
183+
Lint/HashNewWithKeywordArgumentsAsDefault: # new in 1.69
184+
Enabled: true
185+
Lint/ItWithoutArgumentsInBlock: # new in 1.59
186+
Enabled: true
187+
Lint/LiteralAssignmentInCondition: # new in 1.58
188+
Enabled: true
189+
Lint/MixedCaseRange: # new in 1.53
190+
Enabled: true
191+
Lint/NonAtomicFileOperation: # new in 1.31
192+
Enabled: true
193+
Lint/NumericOperationWithConstantResult: # new in 1.69
194+
Enabled: true
195+
Lint/RedundantRegexpQuantifiers: # new in 1.53
196+
Enabled: true
197+
Lint/RefinementImportMethods: # new in 1.27
198+
Enabled: true
199+
Lint/RequireRangeParentheses: # new in 1.32
200+
Enabled: true
201+
Lint/SharedMutableDefault: # new in 1.70
202+
Enabled: true
203+
Lint/UnescapedBracketInRegexp: # new in 1.68
204+
Enabled: true
205+
Lint/UselessDefined: # new in 1.69
206+
Enabled: true
207+
Lint/UselessNumericOperation: # new in 1.66
208+
Enabled: true
209+
Lint/UselessRescue: # new in 1.43
210+
Enabled: true
211+
Metrics/CollectionLiteralLength: # new in 1.47
212+
Enabled: true
213+
Security/CompoundHash: # new in 1.28
214+
Enabled: true
215+
Style/AmbiguousEndlessMethodDefinition: # new in 1.68
216+
Enabled: true
217+
Style/ArrayIntersect: # new in 1.40
218+
Enabled: true
219+
Style/BitwisePredicate: # new in 1.68
220+
Enabled: true
221+
Style/CombinableDefined: # new in 1.68
222+
Enabled: true
223+
Style/ComparableClamp: # new in 1.44
224+
Enabled: true
225+
Style/ConcatArrayLiterals: # new in 1.41
226+
Enabled: true
227+
Style/DataInheritance: # new in 1.49
228+
Enabled: true
229+
Style/DigChain: # new in 1.69
230+
Enabled: true
231+
Style/DirEmpty: # new in 1.48
232+
Enabled: true
233+
Style/EmptyHeredoc: # new in 1.32
234+
Enabled: true
235+
Style/EnvHome: # new in 1.29
236+
Enabled: true
237+
Style/ExactRegexpMatch: # new in 1.51
238+
Enabled: true
239+
Style/FetchEnvVar: # new in 1.28
240+
Enabled: true
241+
Style/FileEmpty: # new in 1.48
242+
Enabled: true
243+
Style/FileNull: # new in 1.69
244+
Enabled: true
245+
Style/FileTouch: # new in 1.69
246+
Enabled: true
247+
Style/HashSlice: # new in 1.71
248+
Enabled: true
249+
Style/ItAssignment: # new in 1.70
250+
Enabled: true
251+
Style/KeywordArgumentsMerging: # new in 1.68
252+
Enabled: true
253+
Style/MagicCommentFormat: # new in 1.35
254+
Enabled: true
255+
Style/MapCompactWithConditionalBlock: # new in 1.30
256+
Enabled: true
257+
Style/MapIntoArray: # new in 1.63
258+
Enabled: true
259+
Style/MapToSet: # new in 1.42
260+
Enabled: true
261+
Style/MinMaxComparison: # new in 1.42
262+
Enabled: true
263+
Style/ObjectThen: # new in 1.28
264+
Enabled: true
265+
Style/OperatorMethodCall: # new in 1.37
266+
Enabled: true
267+
Style/RedundantArrayConstructor: # new in 1.52
268+
Enabled: true
269+
Style/RedundantConstantBase: # new in 1.40
270+
Enabled: true
271+
Style/RedundantCurrentDirectoryInPath: # new in 1.53
272+
Enabled: true
273+
Style/RedundantDoubleSplatHashBraces: # new in 1.41
274+
Enabled: true
275+
Style/RedundantEach: # new in 1.38
276+
Enabled: true
277+
Style/RedundantFilterChain: # new in 1.52
278+
Enabled: true
279+
Style/RedundantHeredocDelimiterQuotes: # new in 1.45
280+
Enabled: true
281+
Style/RedundantInitialize: # new in 1.27
282+
Enabled: true
283+
Style/RedundantInterpolationUnfreeze: # new in 1.66
284+
Enabled: true
285+
Style/RedundantLineContinuation: # new in 1.49
286+
Enabled: true
287+
Style/RedundantRegexpArgument: # new in 1.53
288+
Enabled: true
289+
Style/RedundantRegexpConstructor: # new in 1.52
290+
Enabled: true
291+
Style/RedundantStringEscape: # new in 1.37
292+
Enabled: true
293+
Style/ReturnNilInPredicateMethodDefinition: # new in 1.53
294+
Enabled: true
295+
Style/SafeNavigationChainLength: # new in 1.68
296+
Enabled: true
297+
Style/SendWithLiteralMethodName: # new in 1.64
298+
Enabled: true
299+
Style/SingleLineDoEndBlock: # new in 1.57
300+
Enabled: true
301+
Style/SuperArguments: # new in 1.64
302+
Enabled: true
303+
Style/SuperWithArgsParentheses: # new in 1.58
304+
Enabled: true
305+
Style/YAMLFileRead: # new in 1.53
306+
Enabled: true

Gemfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ end
2929
group :test do
3030
gem 'minitest-byebug', '~> 0.0.3'
3131
gem 'minitest-reporters', '~> 1.4', require: false
32-
gem 'rubocop', '~> 1.26.0', require: false
32+
gem 'rubocop', '~> 1.71', require: false
3333
gem 'rubocop-rake', '~> 0.6.0', require: false
3434
gem 'simplecov', '~> 0.21', require: false
35-
end
35+
end

lib/nestedtext/errors_internal.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ def initialize(line, ind_exp)
151151
class ParseLineTypeNotExpectedError < ParseError
152152
def initialize(line, type_exps, type_act)
153153
super(line, line.indentation,
154-
"The current line was detected to be #{type_act}, "\
154+
"The current line was detected to be #{type_act}, " \
155155
"but we expected to see any of [#{type_exps.join(', ')}] here.")
156156
end
157157
end
@@ -166,7 +166,7 @@ class ParseInvalidIndentationCharError < ParseError
166166
def initialize(line)
167167
char = line.content[0]
168168
# Official-tests kludge; Translate rubys \u00 to python's unicodedata.name \x format.
169-
printable_char = char.dump.gsub(/"/, '').gsub(/\\u0*/, '\x').downcase
169+
printable_char = char.dump.gsub('"', '').gsub(/\\u0*/, '\x').downcase
170170

171171
explanation = ''
172172
# Official-tests kludge; ASCII chars have printable names too,
@@ -195,7 +195,7 @@ def initialize(line, class_name)
195195
class ParseCustomClassNoCreateMethodError < ParseError
196196
def initialize(line, class_name)
197197
super(line, line.indentation,
198-
"Detected an encode custom class #{class_name} "\
198+
"Detected an encode custom class #{class_name} " \
199199
"but it does not have a #nt_create method, so it can't be deserialzied.")
200200
end
201201
end
@@ -275,8 +275,8 @@ def initialize(class_exp, class_act)
275275

276276
class DumpBadIOError < InternalError
277277
def initialize(io)
278-
super('When giving the io argument, it must be of type IO (respond to #write, #fsync).' \
279-
" Given: #{io.class.name}")
278+
super('When giving the io argument, it must be of type IO (respond to #write, #fsync). ' \
279+
"Given: #{io.class.name}")
280280
end
281281
end
282282

lib/nestedtext/parser.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def parse
4545
private
4646

4747
def return_object(result)
48-
raise Errors::AssertionError, 'Parsed result is of unexpected type.' if \
48+
raise Errors::AssertionError, 'Parsed result is of unexpected type.' if
4949
!result.nil? && ![Hash, Array, String].include?(result.class) && @strict
5050

5151
result

lib/nestedtext/scanners.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ def fast_forward_indentation
132132
end
133133

134134
def detect_line_tag
135-
if @content.length.zero?
135+
if @content.length.zero? # rubocop:disable Style/ZeroLengthPredicate
136136
self.tag = :blank
137137
elsif @content[0] == '#'
138138
self.tag = :comment

test/nestedtext/decode_test.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -917,7 +917,7 @@ def test_load_file_invalid_filename_array
917917
class NoNTCreateClass; end # rubocop:disable Lint/EmptyClass
918918

919919
class DecodeCustomClassTest < NTTest
920-
class NotInScope; end # rubocop:disable Lint/EmptyClass
920+
class NotInScope; end # rubocop:disable Lint/EmptyClass
921921

922922
def test_custom_class_no_nt_creat_method
923923
nts = <<~NT

0 commit comments

Comments
 (0)