rubocop-expert 0.1.0
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 +7 -0
- data/.editorconfig +8 -0
- data/.gitignore +11 -0
- data/.rspec +3 -0
- data/.rubocop.yml +53 -0
- data/.rubocop_expert.yml +4 -0
- data/.travis.yml +7 -0
- data/Gemfile +8 -0
- data/Gemfile.lock +66 -0
- data/LICENSE.txt +21 -0
- data/README.md +43 -0
- data/Rakefile +12 -0
- data/bin/console +15 -0
- data/bin/setup +8 -0
- data/config/default.yml +4 -0
- data/lib/rubocop/cop/expert/redundant_parentheses_for_method_call.rb +312 -0
- data/lib/rubocop/expert/inject.rb +23 -0
- data/lib/rubocop/expert/version.rb +7 -0
- data/lib/rubocop/expert.rb +13 -0
- data/lib/rubocop-expert.rb +11 -0
- data/log/.gitignore +2 -0
- data/rubocop-expert.gemspec +37 -0
- metadata +151 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 974e35da2dea073e6767d09157e165d66f3163e0a7824d505cfaff18f754e3c5
|
4
|
+
data.tar.gz: 93ca7b4ae6cc48d2f534246813a6ff36067040d80a9a5fb204bdd3fa257c15fb
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: d433c84d5327579694cce88ab5dc2c7fe55415ca6a8b44ed3d854a4e2c2227c84279556cf9baf7fca783ff9e08897c34905b0bc2eed4b68bdd785f52a5b7eda9
|
7
|
+
data.tar.gz: 056d1feee3d416ec6c5692d33ca90fa2fe439c627d815cd4016b3ba5db5c396b3d8e1e2341b90c86cd40421de2ad3ebcb1c964890182481823c6cd08858765a0
|
data/.editorconfig
ADDED
data/.gitignore
ADDED
data/.rspec
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
inherit_from:
|
2
|
+
- .rubocop_expert.yml
|
3
|
+
- ./config/default.yml
|
4
|
+
|
5
|
+
AllCops:
|
6
|
+
TargetRubyVersion: 2.5
|
7
|
+
|
8
|
+
Layout/MultilineOperationIndentation:
|
9
|
+
EnforcedStyle: indented
|
10
|
+
|
11
|
+
Layout/ExtraSpacing:
|
12
|
+
AllowForAlignment: false
|
13
|
+
|
14
|
+
Layout/MultilineMethodCallIndentation:
|
15
|
+
EnforcedStyle: indented_relative_to_receiver
|
16
|
+
|
17
|
+
Layout/SpaceInsideBlockBraces:
|
18
|
+
SpaceBeforeBlockParameters: false
|
19
|
+
|
20
|
+
Metrics/BlockLength:
|
21
|
+
Exclude:
|
22
|
+
- '*.gemspec'
|
23
|
+
ExcludedMethods:
|
24
|
+
- describe
|
25
|
+
- context
|
26
|
+
|
27
|
+
Metrics/ClassLength:
|
28
|
+
Max: 500
|
29
|
+
|
30
|
+
Metrics/CyclomaticComplexity:
|
31
|
+
Max: 10
|
32
|
+
|
33
|
+
Metrics/LineLength:
|
34
|
+
Max: 100
|
35
|
+
|
36
|
+
Metrics/MethodLength:
|
37
|
+
Max: 15
|
38
|
+
|
39
|
+
Naming/UncommunicativeMethodParamName:
|
40
|
+
AllowedNames:
|
41
|
+
[op]
|
42
|
+
|
43
|
+
Style/AccessModifierDeclarations:
|
44
|
+
EnforcedStyle: inline
|
45
|
+
|
46
|
+
Style/EmptyCaseCondition:
|
47
|
+
Enabled: false
|
48
|
+
|
49
|
+
Style/MethodDefParentheses:
|
50
|
+
EnforcedStyle: require_no_parentheses_except_multiline
|
51
|
+
|
52
|
+
Style/NestedParenthesizedCalls:
|
53
|
+
Enabled: false
|
data/.rubocop_expert.yml
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,66 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
rubocop-expert (0.1.0)
|
5
|
+
rubocop (~> 0.58.2)
|
6
|
+
rubocop-rspec (~> 1.29.0)
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: https://rubygems.org/
|
10
|
+
specs:
|
11
|
+
ast (2.4.0)
|
12
|
+
byebug (10.0.2)
|
13
|
+
coderay (1.1.2)
|
14
|
+
diff-lcs (1.3)
|
15
|
+
jaro_winkler (1.5.1-x86_64-darwin-17)
|
16
|
+
method_source (0.9.0)
|
17
|
+
parallel (1.12.1)
|
18
|
+
parser (2.5.1.2)
|
19
|
+
ast (~> 2.4.0)
|
20
|
+
powerpack (0.1.2)
|
21
|
+
pry (0.11.3)
|
22
|
+
coderay (~> 1.1.0)
|
23
|
+
method_source (~> 0.9.0)
|
24
|
+
pry-byebug (3.6.0)
|
25
|
+
byebug (~> 10.0)
|
26
|
+
pry (~> 0.10)
|
27
|
+
rainbow (3.0.0)
|
28
|
+
rake (10.5.0)
|
29
|
+
rspec (3.8.0)
|
30
|
+
rspec-core (~> 3.8.0)
|
31
|
+
rspec-expectations (~> 3.8.0)
|
32
|
+
rspec-mocks (~> 3.8.0)
|
33
|
+
rspec-core (3.8.0)
|
34
|
+
rspec-support (~> 3.8.0)
|
35
|
+
rspec-expectations (3.8.1)
|
36
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
37
|
+
rspec-support (~> 3.8.0)
|
38
|
+
rspec-mocks (3.8.0)
|
39
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
40
|
+
rspec-support (~> 3.8.0)
|
41
|
+
rspec-support (3.8.0)
|
42
|
+
rubocop (0.58.2)
|
43
|
+
jaro_winkler (~> 1.5.1)
|
44
|
+
parallel (~> 1.10)
|
45
|
+
parser (>= 2.5, != 2.5.1.1)
|
46
|
+
powerpack (~> 0.1)
|
47
|
+
rainbow (>= 2.2.2, < 4.0)
|
48
|
+
ruby-progressbar (~> 1.7)
|
49
|
+
unicode-display_width (~> 1.0, >= 1.0.1)
|
50
|
+
rubocop-rspec (1.29.0)
|
51
|
+
rubocop (>= 0.58.0)
|
52
|
+
ruby-progressbar (1.10.0)
|
53
|
+
unicode-display_width (1.4.0)
|
54
|
+
|
55
|
+
PLATFORMS
|
56
|
+
ruby
|
57
|
+
|
58
|
+
DEPENDENCIES
|
59
|
+
bundler (~> 1.16)
|
60
|
+
pry-byebug (~> 3.0)
|
61
|
+
rake (~> 10.0)
|
62
|
+
rspec (~> 3.0)
|
63
|
+
rubocop-expert!
|
64
|
+
|
65
|
+
BUNDLED WITH
|
66
|
+
1.16.4
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2018 akouryy
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
# Rubocop::Expert
|
2
|
+
|
3
|
+
[RuboCop](https://github.com/rubocop-hq/rubocop/) custom cops for elegance.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'rubocop-akouryy'
|
11
|
+
```
|
12
|
+
|
13
|
+
Or install it yourself as:
|
14
|
+
|
15
|
+
```
|
16
|
+
gem install rubocop rubocop-rspec rubocop-akouryy
|
17
|
+
```
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
Require this gem in .rubocop.yml:
|
22
|
+
|
23
|
+
```yaml
|
24
|
+
require:
|
25
|
+
- rubocop-expert
|
26
|
+
```
|
27
|
+
|
28
|
+
### Cops
|
29
|
+
|
30
|
+
The list and documentation of cops are available at
|
31
|
+
[/lib/rubocop/cop/expert](https://github.com/akouryy/rubocop-expert/tree/master/lib/rubocop/cop/expert).
|
32
|
+
|
33
|
+
## Development
|
34
|
+
|
35
|
+
TODO
|
36
|
+
|
37
|
+
## Contributing
|
38
|
+
|
39
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/akouryy/rubocop-expert.
|
40
|
+
|
41
|
+
## License
|
42
|
+
|
43
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'bundler/gem_tasks'
|
4
|
+
require 'rspec/core/rake_task'
|
5
|
+
|
6
|
+
RSpec::Core::RakeTask.new :spec
|
7
|
+
RSpec::Core::RakeTask.new :spec_html do |t|
|
8
|
+
t.rspec_opts = '--format html --out log/rspec.html --no-color'
|
9
|
+
end
|
10
|
+
|
11
|
+
task default: :spec
|
12
|
+
task h: :spec_html
|
data/bin/console
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require 'bundler/setup'
|
5
|
+
require 'rubocop/expert'
|
6
|
+
|
7
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
8
|
+
# with your gem easier. You can also use a different console, if you like.
|
9
|
+
|
10
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
11
|
+
# require "pry"
|
12
|
+
# Pry.start
|
13
|
+
|
14
|
+
require 'irb'
|
15
|
+
IRB.start __FILE__
|
data/bin/setup
ADDED
data/config/default.yml
ADDED
@@ -0,0 +1,312 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'set'
|
4
|
+
|
5
|
+
module RuboCop
|
6
|
+
module Cop
|
7
|
+
module Expert
|
8
|
+
# This cop checks for all omittable parentheses in method calls.
|
9
|
+
#
|
10
|
+
# @example
|
11
|
+
# # bad
|
12
|
+
# foo()
|
13
|
+
# foo(0, 1)
|
14
|
+
# foo(0 + 1)
|
15
|
+
# foo(a = 1)
|
16
|
+
# foo(0, *a)
|
17
|
+
# foo(0, a: 1, b: 2)
|
18
|
+
# foo bar(0, 1)
|
19
|
+
# foo(bar 0, 1)
|
20
|
+
# foo 0, (bar(1))
|
21
|
+
# foo(0) do end
|
22
|
+
# foo(/a/)
|
23
|
+
# foo(%w[a b c])
|
24
|
+
# foo(<<~STR)
|
25
|
+
# heredoc
|
26
|
+
# STR
|
27
|
+
# for a in foo(0, 1); end
|
28
|
+
#
|
29
|
+
# # good
|
30
|
+
# foo
|
31
|
+
# foo 0, 1
|
32
|
+
# foo 0 + 1
|
33
|
+
# foo a = 1
|
34
|
+
# foo 0, *a
|
35
|
+
# foo 0, a: 1, b: 2
|
36
|
+
# foo bar 0, 1
|
37
|
+
# foo 0, (bar 1)
|
38
|
+
# foo 0 do end
|
39
|
+
# foo /a/
|
40
|
+
# foo %w[a b c]
|
41
|
+
# foo <<~STR
|
42
|
+
# heredoc
|
43
|
+
# STR
|
44
|
+
# for a in foo 0, 1; end
|
45
|
+
#
|
46
|
+
# # good
|
47
|
+
# # Parentheses are required.
|
48
|
+
# -foo(0)
|
49
|
+
# foo(0) + 1
|
50
|
+
# foo(0).bar
|
51
|
+
# foo(0){}
|
52
|
+
# foo 0, bar(1)
|
53
|
+
# foo bar(0), 1
|
54
|
+
# a = 0, foo(1) # multiple assignment
|
55
|
+
# foo bar(0) do end
|
56
|
+
# [foo(0)]
|
57
|
+
# { foo: bar(0) }
|
58
|
+
# case 0; when foo(1); end
|
59
|
+
# def foo a = bar(0), b: baz(1); end
|
60
|
+
# return 0, foo(1) # return multiple value
|
61
|
+
#
|
62
|
+
# # good
|
63
|
+
# # Parentheses are not part of the method call.
|
64
|
+
# # Use the default cop Style/RedundantParentheses.
|
65
|
+
# foo (0)
|
66
|
+
# foo (0 + 1)
|
67
|
+
# foo (bar 0), 1
|
68
|
+
#
|
69
|
+
# @example AllowInMultilineCall: never
|
70
|
+
# # bad
|
71
|
+
# foo(0, 1,
|
72
|
+
# a: 2,
|
73
|
+
# b: 3,
|
74
|
+
# )
|
75
|
+
# foo(
|
76
|
+
# 0,
|
77
|
+
# a: 1,
|
78
|
+
# b: 2,
|
79
|
+
# )
|
80
|
+
#
|
81
|
+
# # good
|
82
|
+
# foo 0, 1,
|
83
|
+
# a: 1,
|
84
|
+
# b: 2
|
85
|
+
# foo \
|
86
|
+
# 0,
|
87
|
+
# a: 1,
|
88
|
+
# b: 2
|
89
|
+
#
|
90
|
+
# @example AllowInMultilineCall: before_newline (default)
|
91
|
+
# # bad
|
92
|
+
# foo(0, 1,
|
93
|
+
# a: 2,
|
94
|
+
# b: 3,
|
95
|
+
# )
|
96
|
+
#
|
97
|
+
# # good
|
98
|
+
# foo(
|
99
|
+
# 0,
|
100
|
+
# a: 1,
|
101
|
+
# b: 2,
|
102
|
+
# )
|
103
|
+
# foo 0, 1,
|
104
|
+
# a: 1,
|
105
|
+
# b: 2
|
106
|
+
# foo \
|
107
|
+
# 0,
|
108
|
+
# a: 1,
|
109
|
+
# b: 2
|
110
|
+
#
|
111
|
+
# @example AllowInMultilineCall: always
|
112
|
+
# # good
|
113
|
+
# foo(0, 1,
|
114
|
+
# a: 2,
|
115
|
+
# b: 3,
|
116
|
+
# )
|
117
|
+
# foo(
|
118
|
+
# 0,
|
119
|
+
# a: 1,
|
120
|
+
# b: 2,
|
121
|
+
# )
|
122
|
+
# foo 0, 1,
|
123
|
+
# a: 1,
|
124
|
+
# b: 2
|
125
|
+
# foo \
|
126
|
+
# 0,
|
127
|
+
# a: 1,
|
128
|
+
# b: 2
|
129
|
+
class RedundantParenthesesForMethodCall < Cop
|
130
|
+
# https://docs.ruby-lang.org/ja/latest/doc/spec=2foperator.html
|
131
|
+
HIGH_OPERATORS = %i[
|
132
|
+
! +@ -@ ~
|
133
|
+
**
|
134
|
+
+ - * / %
|
135
|
+
& | ^ << >>
|
136
|
+
== != < <= > >= === <=> =~ !~
|
137
|
+
&& ||
|
138
|
+
.. ...
|
139
|
+
].to_set
|
140
|
+
|
141
|
+
MSG = 'Do not use unnecessary parentheses for method calls.'
|
142
|
+
|
143
|
+
MULTILINE_CONFIG_NAME = 'AllowInMultilineCall'
|
144
|
+
MULTILINE_CONFIG_VALUES = %i[never before_newline always].freeze
|
145
|
+
|
146
|
+
def on_send node
|
147
|
+
return unless node.parenthesized_call?
|
148
|
+
return if parens_allowed? node
|
149
|
+
return if allowed_by_multiline_config? node
|
150
|
+
add_offense node, location: :begin
|
151
|
+
end
|
152
|
+
|
153
|
+
private def allowed_by_multiline_config? node
|
154
|
+
fn_ln = node.loc.selector&.line
|
155
|
+
first_arg_ln = node.arguments[0]&.loc&.line
|
156
|
+
par_end_ln = node.loc.end.line
|
157
|
+
|
158
|
+
fn_ln && fn_ln != par_end_ln &&
|
159
|
+
case multiline_config
|
160
|
+
when :never
|
161
|
+
false
|
162
|
+
when :before_newline
|
163
|
+
first_arg_ln && fn_ln != first_arg_ln
|
164
|
+
when :always
|
165
|
+
true
|
166
|
+
end
|
167
|
+
end
|
168
|
+
|
169
|
+
private def_node_matcher :among_multiple_args?, <<~PAT
|
170
|
+
^(send
|
171
|
+
!equal?(%0)
|
172
|
+
_
|
173
|
+
...) #{'%0 is here' * 0}
|
174
|
+
PAT
|
175
|
+
|
176
|
+
private def_node_matcher :among_multiple_return?, <<~PAT
|
177
|
+
^(return _ _ ...) #{'>=1 values' * 0}
|
178
|
+
PAT
|
179
|
+
|
180
|
+
private def_node_matcher :array_element?, '^(array ...)'
|
181
|
+
|
182
|
+
private def_node_matcher :bracket_receiver?, <<~PAT
|
183
|
+
^[
|
184
|
+
(send
|
185
|
+
equal?(%0)
|
186
|
+
{ :[] :[]= }
|
187
|
+
...)
|
188
|
+
!dot?
|
189
|
+
]
|
190
|
+
PAT
|
191
|
+
|
192
|
+
private def_node_matcher :default_of_optarg?, <<~PAT
|
193
|
+
^[
|
194
|
+
({optarg kwoptarg}
|
195
|
+
_
|
196
|
+
equal?(%0))
|
197
|
+
]
|
198
|
+
PAT
|
199
|
+
|
200
|
+
private def_node_matcher :dot_receiver?, <<~PAT
|
201
|
+
^[
|
202
|
+
(send
|
203
|
+
equal?(%0)
|
204
|
+
$_
|
205
|
+
...)
|
206
|
+
dot?
|
207
|
+
]
|
208
|
+
PAT
|
209
|
+
|
210
|
+
private def explicit_receiver? node
|
211
|
+
bracket_receiver?(node) || dot_receiver?(node)
|
212
|
+
end
|
213
|
+
|
214
|
+
private def_node_matcher :hash_element?, <<~PAT
|
215
|
+
[
|
216
|
+
^^(hash ...)
|
217
|
+
^(pair _ equal?(%0))
|
218
|
+
]
|
219
|
+
PAT
|
220
|
+
|
221
|
+
private def high_method_operand? node
|
222
|
+
high_method_operator_receiver?(node) || high_method_operator_arg?(node)
|
223
|
+
end
|
224
|
+
|
225
|
+
private def_node_matcher :high_method_operator_arg?, <<~PAT
|
226
|
+
^[
|
227
|
+
(send
|
228
|
+
!nil?
|
229
|
+
#high_operator?
|
230
|
+
equal?(%0))
|
231
|
+
!dot?
|
232
|
+
]
|
233
|
+
PAT
|
234
|
+
|
235
|
+
private def_node_matcher :high_method_operator_receiver?, <<~PAT
|
236
|
+
^[
|
237
|
+
(send
|
238
|
+
equal?(%0)
|
239
|
+
#high_operator?
|
240
|
+
...)
|
241
|
+
!dot?
|
242
|
+
]
|
243
|
+
PAT
|
244
|
+
|
245
|
+
private def high_operand? node
|
246
|
+
high_method_operand?(node) || high_special_operand?(node)
|
247
|
+
end
|
248
|
+
|
249
|
+
private def high_operator? op
|
250
|
+
HIGH_OPERATORS.include? op.to_sym
|
251
|
+
end
|
252
|
+
|
253
|
+
private def high_special_operand? node
|
254
|
+
op =
|
255
|
+
case
|
256
|
+
when node.parent&.irange_type? then '..'
|
257
|
+
when node.parent&.erange_type? then '...'
|
258
|
+
when special_operand?(node) then node.parent.operator
|
259
|
+
end
|
260
|
+
op && high_operator?(op)
|
261
|
+
end
|
262
|
+
|
263
|
+
private def implicit_call? node
|
264
|
+
node.implicit_call?
|
265
|
+
end
|
266
|
+
|
267
|
+
private def multiline_config
|
268
|
+
@multiline_config ||=
|
269
|
+
(cop_config[MULTILINE_CONFIG_NAME] || :before_newline).to_sym.tap do |a|
|
270
|
+
unless MULTILINE_CONFIG_VALUES.include? a
|
271
|
+
raise "Unknown option: #{MULTILINE_CONFIG_NAME}: #{a}"
|
272
|
+
end
|
273
|
+
end
|
274
|
+
end
|
275
|
+
|
276
|
+
private def parens_allowed? node
|
277
|
+
%i[
|
278
|
+
among_multiple_args?
|
279
|
+
among_multiple_return?
|
280
|
+
array_element?
|
281
|
+
default_of_optarg?
|
282
|
+
explicit_receiver?
|
283
|
+
hash_element?
|
284
|
+
high_operand?
|
285
|
+
implicit_call?
|
286
|
+
splat_like?
|
287
|
+
when_cond?
|
288
|
+
with_arg_s_and_brace_block?
|
289
|
+
].any? do |sym|
|
290
|
+
__send__ sym, node
|
291
|
+
end
|
292
|
+
end
|
293
|
+
|
294
|
+
private def_node_matcher :special_operand?, '^({and or} ...)'
|
295
|
+
|
296
|
+
private def_node_matcher :splat_like?, '^({splat kwsplat block_pass} equal?(%0))'
|
297
|
+
|
298
|
+
private def_node_matcher :when_cond?, '^(when equal?(%0) _)'
|
299
|
+
|
300
|
+
private def_node_matcher :with_arg_s_and_brace_block?, <<~PAT
|
301
|
+
[
|
302
|
+
(send _ _ _ ...) #{'>=1 args' * 0}
|
303
|
+
^[
|
304
|
+
(block ...)
|
305
|
+
braces?
|
306
|
+
]
|
307
|
+
]
|
308
|
+
PAT
|
309
|
+
end
|
310
|
+
end
|
311
|
+
end
|
312
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Forked from:
|
4
|
+
# airbnb/ruby https://github.com/airbnb/ruby/blob/3b049d7523ffd530fcb8005732ff217d4de578d8/rubocop-airbnb/lib/rubocop/airbnb/inject.rb
|
5
|
+
# (c) 2012 Airbnb
|
6
|
+
# MIT License https://github.com/airbnb/ruby/blob/master/rubocop-airbnb/LICENSE.md
|
7
|
+
|
8
|
+
require 'yaml'
|
9
|
+
|
10
|
+
module RuboCop
|
11
|
+
module Expert # :nodoc:
|
12
|
+
# Because RuboCop doesn't yet support plugins, we have to monkey patch in a
|
13
|
+
# bit of our configuration.
|
14
|
+
def self.inject_defaults!
|
15
|
+
path = CONFIG_DEFAULT_PATH
|
16
|
+
hash = ConfigLoader.load_file(path).to_hash
|
17
|
+
config = Config.new hash, path
|
18
|
+
puts "configuration from #{path}" if ConfigLoader.debug?
|
19
|
+
config = ConfigLoader.merge_with_default config, path
|
20
|
+
ConfigLoader.instance_variable_set :@default_configuration, config
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RuboCop
|
4
|
+
module Expert # :nodoc:
|
5
|
+
ROOT_PATH = File.expand_path '../..', __dir__
|
6
|
+
CONFIG_DEFAULT_PATH = File.expand_path 'config/default.yml', ROOT_PATH
|
7
|
+
CONFIG = Psych.safe_load(File.read CONFIG_DEFAULT_PATH).freeze
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
require_relative 'cop/expert/redundant_parentheses_for_method_call'
|
12
|
+
require_relative 'expert/inject'
|
13
|
+
require_relative 'expert/version'
|
data/log/.gitignore
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
lib = File.expand_path 'lib', __dir__
|
4
|
+
$LOAD_PATH.unshift lib unless $LOAD_PATH.include? lib
|
5
|
+
require 'rubocop/expert/version'
|
6
|
+
|
7
|
+
Gem::Specification.new do |spec|
|
8
|
+
spec.name = 'rubocop-expert'
|
9
|
+
spec.version = RuboCop::Expert::VERSION
|
10
|
+
spec.authors = ['akouryy']
|
11
|
+
spec.email = ['akouryy7@gmail.com']
|
12
|
+
|
13
|
+
spec.summary = 'RuboCop custom cops for elegance'
|
14
|
+
spec.description = <<~DESC
|
15
|
+
RuboCop custom cops for elegance.
|
16
|
+
At the moment there is only one cop: Expert/RedundantParenthesesForMethodCall.
|
17
|
+
DESC
|
18
|
+
spec.homepage = 'https://github.com/akouryy/rubocop-expert'
|
19
|
+
spec.license = 'MIT'
|
20
|
+
|
21
|
+
# Specify which files should be added to the gem when it is released.
|
22
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
23
|
+
spec.files = Dir.chdir __dir__ do
|
24
|
+
`git ls-files -z`.split("\x0").reject {|f| f.match(%r{^(test|spec|features)/}) }
|
25
|
+
end
|
26
|
+
spec.bindir = 'exe'
|
27
|
+
spec.executables = spec.files.grep(%r{^exe/}) {|f| File.basename(f) }
|
28
|
+
spec.require_paths = ['lib']
|
29
|
+
|
30
|
+
spec.add_dependency 'rubocop', '~> 0.58.2'
|
31
|
+
spec.add_dependency 'rubocop-rspec', '~> 1.29.0'
|
32
|
+
|
33
|
+
spec.add_development_dependency 'bundler', '~> 1.16'
|
34
|
+
spec.add_development_dependency 'pry-byebug', '~> 3.0'
|
35
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
36
|
+
spec.add_development_dependency 'rspec', '~> 3.0'
|
37
|
+
end
|
metadata
ADDED
@@ -0,0 +1,151 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rubocop-expert
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- akouryy
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-08-30 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rubocop
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.58.2
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.58.2
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rubocop-rspec
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 1.29.0
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 1.29.0
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: bundler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.16'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.16'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: pry-byebug
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '3.0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '3.0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rake
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '10.0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '10.0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rspec
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '3.0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '3.0'
|
97
|
+
description: |
|
98
|
+
RuboCop custom cops for elegance.
|
99
|
+
At the moment there is only one cop: Expert/RedundantParenthesesForMethodCall.
|
100
|
+
email:
|
101
|
+
- akouryy7@gmail.com
|
102
|
+
executables: []
|
103
|
+
extensions: []
|
104
|
+
extra_rdoc_files: []
|
105
|
+
files:
|
106
|
+
- ".editorconfig"
|
107
|
+
- ".gitignore"
|
108
|
+
- ".rspec"
|
109
|
+
- ".rubocop.yml"
|
110
|
+
- ".rubocop_expert.yml"
|
111
|
+
- ".travis.yml"
|
112
|
+
- Gemfile
|
113
|
+
- Gemfile.lock
|
114
|
+
- LICENSE.txt
|
115
|
+
- README.md
|
116
|
+
- Rakefile
|
117
|
+
- bin/console
|
118
|
+
- bin/setup
|
119
|
+
- config/default.yml
|
120
|
+
- lib/rubocop-expert.rb
|
121
|
+
- lib/rubocop/cop/expert/redundant_parentheses_for_method_call.rb
|
122
|
+
- lib/rubocop/expert.rb
|
123
|
+
- lib/rubocop/expert/inject.rb
|
124
|
+
- lib/rubocop/expert/version.rb
|
125
|
+
- log/.gitignore
|
126
|
+
- rubocop-expert.gemspec
|
127
|
+
homepage: https://github.com/akouryy/rubocop-expert
|
128
|
+
licenses:
|
129
|
+
- MIT
|
130
|
+
metadata: {}
|
131
|
+
post_install_message:
|
132
|
+
rdoc_options: []
|
133
|
+
require_paths:
|
134
|
+
- lib
|
135
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
136
|
+
requirements:
|
137
|
+
- - ">="
|
138
|
+
- !ruby/object:Gem::Version
|
139
|
+
version: '0'
|
140
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
141
|
+
requirements:
|
142
|
+
- - ">="
|
143
|
+
- !ruby/object:Gem::Version
|
144
|
+
version: '0'
|
145
|
+
requirements: []
|
146
|
+
rubyforge_project:
|
147
|
+
rubygems_version: 2.7.6
|
148
|
+
signing_key:
|
149
|
+
specification_version: 4
|
150
|
+
summary: RuboCop custom cops for elegance
|
151
|
+
test_files: []
|