rubocop 1.8.0 → 1.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9e14b02ef2156539b9acbf92f0a131cbf5459cccdbb799cf96116f51b61e45c3
4
- data.tar.gz: 2322dcababa13d2dbc001fc4a6fb8fe8c39e39b0d27869f4b1b5c59aceefa577
3
+ metadata.gz: fe7ec80b8cde2a075fee5a5658abf6dc74889091dae29e88482107983d2de270
4
+ data.tar.gz: 7852fe6a6d0ba9cae98439cba0dfbfda659a5a434f62eca318bcd5bc45dfd3c4
5
5
  SHA512:
6
- metadata.gz: afc301f47f48f46587318215a0d64a246ac9f4007f7c2396867a1c26cff2a467d59ebd30531adaf5dd3eebcaea001f19b34ab4737bebfe4b51dda7f329a0b4f9
7
- data.tar.gz: ee54178b27d0dc5e058f004a27ea53d581583bf3386bf2fc572b4b16ad6099d849720935a6c632aaade0a3c71ca92129c0b3c9dc4dff80e00977d5141bc02615
6
+ metadata.gz: 4239a27259a39584a544ed4bfc7c6025ece2198d463f8a2918a98e5560cec9a5a2ea5b978f0d253e61ea700446bb49f705627d8b8e41d4ead0fef35b23b14d98
7
+ data.tar.gz: 59746b47f6bbe92dec5f6d79395ad6cd1a175d3a186005412953f0a849192673084b426bd14f6e9ac83e11dfaa0b27fc15718857b29ca6d359e2c9d387bca9c2
data/README.md CHANGED
@@ -109,6 +109,7 @@ Here's a list of RuboCop's core developers:
109
109
  * [Maxim Krizhanovski](https://github.com/darhazer)
110
110
  * [Benjamin Quorning](https://github.com/bquorning)
111
111
  * [Marc-André Lafortune](https://github.com/marcandre)
112
+ * [Daniel Vandersluis](https://github.com/dvandersluis)
112
113
 
113
114
  See the [team page](https://docs.rubocop.org/rubocop/about/team.html) for more details.
114
115
 
@@ -3271,9 +3271,8 @@ Style/ExplicitBlockArgument:
3271
3271
  that just passes its arguments to another block.
3272
3272
  StyleGuide: '#block-argument'
3273
3273
  Enabled: true
3274
- # May change the yielding arity.
3275
- Safe: false
3276
3274
  VersionAdded: '0.89'
3275
+ VersionChanged: '1.8'
3277
3276
 
3278
3277
  Style/ExponentialNotation:
3279
3278
  Description: 'When using exponential notation, favor a mantissa between 1 (inclusive) and 10 (exclusive).'
@@ -175,7 +175,7 @@ module RuboCop
175
175
  end
176
176
 
177
177
  def loaded_features
178
- @loaded_features.flatten.compact
178
+ @loaded_features.flatten.compact.uniq
179
179
  end
180
180
 
181
181
  # @api private
@@ -34,11 +34,13 @@ module RuboCop
34
34
 
35
35
  def on_send(node)
36
36
  return unless (receiver = node.receiver)
37
- return unless receiver.receiver.const_type? && receiver.receiver.short_name == :Dir
37
+ return unless receiver.receiver&.const_type? && receiver.receiver.short_name == :Dir
38
38
  return unless GLOB_METHODS.include?(receiver.method_name)
39
39
 
40
- add_offense(node.loc.selector) do |corrector|
41
- corrector.remove(node.loc.selector)
40
+ selector = node.loc.selector
41
+
42
+ add_offense(selector) do |corrector|
43
+ corrector.remove(selector)
42
44
  corrector.remove(node.loc.dot)
43
45
  end
44
46
  end
@@ -24,7 +24,11 @@ module RuboCop
24
24
  name = full_name.gsub(/\A(_+)/, '')
25
25
  next if allowed_names.include?(name)
26
26
 
27
- range = arg_range(arg, name.size)
27
+ length = full_name.size
28
+ length += 1 if arg.restarg_type?
29
+ length += 2 if arg.kwrestarg_type?
30
+
31
+ range = arg_range(arg, length)
28
32
  issue_offenses(node, range, name)
29
33
  end
30
34
  end
@@ -6,6 +6,9 @@ module RuboCop
6
6
  # This cop enforces the use of explicit block argument to avoid writing
7
7
  # block literal that just passes its arguments to another block.
8
8
  #
9
+ # NOTE: This cop only registers an offense if the block args match the
10
+ # yield args exactly.
11
+ #
9
12
  # @example
10
13
  # # bad
11
14
  # def with_tmp_dir
@@ -75,7 +78,14 @@ module RuboCop
75
78
  private
76
79
 
77
80
  def yielding_arguments?(block_args, yield_args)
81
+ yield_args = yield_args.dup.fill(
82
+ nil,
83
+ yield_args.length, block_args.length - yield_args.length
84
+ )
85
+
78
86
  yield_args.zip(block_args).all? do |yield_arg, block_arg|
87
+ next false unless yield_arg && block_arg
88
+
79
89
  block_arg && yield_arg.children.first == block_arg.children.first
80
90
  end
81
91
  end
@@ -89,7 +89,8 @@ module RuboCop
89
89
  end
90
90
 
91
91
  def correct_to_endless(corrector, node)
92
- replacement = "def #{node.method_name}(#{node.arguments.source}) = #{node.body.source}"
92
+ arguments = node.arguments.any? ? node.arguments.source : '()'
93
+ replacement = "def #{node.method_name}#{arguments} = #{node.body.source}"
93
94
  corrector.replace(node, replacement)
94
95
  end
95
96
 
@@ -63,13 +63,13 @@ module RuboCop
63
63
  end
64
64
 
65
65
  def autocorrect(corrector, node, if_branch)
66
+ corrector.wrap(node.condition, '(', ')') if node.condition.or_type?
67
+
66
68
  if node.unless?
67
69
  corrector.replace(node.loc.keyword, 'if')
68
70
  corrector.insert_before(node.condition, '!')
69
71
  end
70
72
 
71
- corrector.wrap(node.condition, '(', ')') if node.condition.or_type?
72
-
73
73
  and_operator = if_branch.unless? ? ' && !' : ' && '
74
74
  if if_branch.modifier_form?
75
75
  correct_for_guard_condition_style(corrector, node, if_branch, and_operator)
@@ -116,7 +116,7 @@ module RuboCop
116
116
  parts.map do |part|
117
117
  if part.str_type?
118
118
  if single_quoted?(part)
119
- part.value.gsub('\\') { '\\\\' }
119
+ part.value.gsub(/(\\|")/, '\\\\\&')
120
120
  else
121
121
  part.value.inspect[1..-2]
122
122
  end
@@ -41,12 +41,10 @@ module RuboCop
41
41
  'having a single-line body.'
42
42
 
43
43
  def on_while(node)
44
- return unless node.multiline? && single_line_as_modifier?(node)
44
+ return unless single_line_as_modifier?(node)
45
45
 
46
46
  add_offense(node.loc.keyword, message: format(MSG, keyword: node.keyword)) do |corrector|
47
- oneline = "#{node.body.source} #{node.keyword} #{node.condition.source}"
48
-
49
- corrector.replace(node, oneline)
47
+ corrector.replace(node, to_modifier_form(node))
50
48
  end
51
49
  end
52
50
  alias on_until on_while
@@ -3,7 +3,7 @@
3
3
  module RuboCop
4
4
  # This module holds the RuboCop version information.
5
5
  module Version
6
- STRING = '1.8.0'
6
+ STRING = '1.8.1'
7
7
 
8
8
  MSG = '%<version>s (using Parser %<parser_version>s, '\
9
9
  'rubocop-ast %<rubocop_ast_version>s, ' \
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubocop
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.8.0
4
+ version: 1.8.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bozhidar Batsov
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: exe
12
12
  cert_chain: []
13
- date: 2021-01-07 00:00:00.000000000 Z
13
+ date: 2021-01-11 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: parallel