rubocop-rails 2.3.0 → 2.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/config/default.yml +13 -14
- data/lib/rubocop/cop/rails/presence.rb +23 -1
- data/lib/rubocop/rails/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 147c7b2462cbfbefa559fc9e6d23b3bad655397784ab1296d2865aede5d41aff
|
4
|
+
data.tar.gz: 1fe87be1d5319fa8687f82e4ece29feedcad65ef1568be8d3f849666f4ba0a5b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 191ef083e5a22f0b8deb9b4918b70cd10556f9db0ff98fdfddc944a40b176050dacdb3a5fbb819abe7a9aaee38c7f4cc06329bd59b82738a98de6c9ffebca7a2
|
7
|
+
data.tar.gz: 4b7b0d972bde8df9df3f8b7b956077d4b895ffcc7f5e0aab1c3885b1f6027244b4b918b0d1f619afb079388a7d2756a70a45fee85ffeca1bae25062370299d41
|
data/config/default.yml
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
# Common configuration.
|
2
2
|
|
3
3
|
AllCops:
|
4
|
+
Exclude:
|
5
|
+
- bin/bundle
|
4
6
|
# What version of Rails is the inspected code using? If a value is specified
|
5
7
|
# for TargetRailsVersion then it is used. Acceptable values are specificed
|
6
8
|
# as a float (i.e. 5.1); the patch version of Rails should not be included.
|
@@ -9,9 +11,6 @@ AllCops:
|
|
9
11
|
# application. If neither of those files exist, RuboCop will use Rails 5.0
|
10
12
|
# as the default.
|
11
13
|
TargetRailsVersion: ~
|
12
|
-
# When specifying style guide URLs, any paths and/or fragments will be
|
13
|
-
# evaluated relative to the base URL.
|
14
|
-
StyleGuideBaseURL: https://rails.rubystyle.guide
|
15
14
|
|
16
15
|
Rails/ActionFilter:
|
17
16
|
Description: 'Enforces consistent use of action filter methods.'
|
@@ -140,7 +139,7 @@ Rails/DelegateAllowBlank:
|
|
140
139
|
|
141
140
|
Rails/DynamicFindBy:
|
142
141
|
Description: 'Use `find_by` instead of dynamic `find_by_*`.'
|
143
|
-
StyleGuide: '#find_by'
|
142
|
+
StyleGuide: 'https://rails.rubystyle.guide#find_by'
|
144
143
|
Enabled: true
|
145
144
|
VersionAdded: '0.44'
|
146
145
|
Whitelist:
|
@@ -148,7 +147,7 @@ Rails/DynamicFindBy:
|
|
148
147
|
|
149
148
|
Rails/EnumHash:
|
150
149
|
Description: 'Prefer hash syntax over array syntax when defining enums.'
|
151
|
-
StyleGuide: '#enums'
|
150
|
+
StyleGuide: 'https://rails.rubystyle.guide#enums'
|
152
151
|
Enabled: true
|
153
152
|
VersionAdded: '2.3'
|
154
153
|
Include:
|
@@ -192,7 +191,7 @@ Rails/FilePath:
|
|
192
191
|
|
193
192
|
Rails/FindBy:
|
194
193
|
Description: 'Prefer find_by over where.first.'
|
195
|
-
StyleGuide: '#find_by'
|
194
|
+
StyleGuide: 'https://rails.rubystyle.guide#find_by'
|
196
195
|
Enabled: true
|
197
196
|
VersionAdded: '0.30'
|
198
197
|
Include:
|
@@ -200,7 +199,7 @@ Rails/FindBy:
|
|
200
199
|
|
201
200
|
Rails/FindEach:
|
202
201
|
Description: 'Prefer all.find_each over all.find.'
|
203
|
-
StyleGuide: '#find-each'
|
202
|
+
StyleGuide: 'https://rails.rubystyle.guide#find-each'
|
204
203
|
Enabled: true
|
205
204
|
VersionAdded: '0.30'
|
206
205
|
Include:
|
@@ -208,7 +207,7 @@ Rails/FindEach:
|
|
208
207
|
|
209
208
|
Rails/HasAndBelongsToMany:
|
210
209
|
Description: 'Prefer has_many :through to has_and_belongs_to_many.'
|
211
|
-
StyleGuide: '#has-many-through'
|
210
|
+
StyleGuide: 'https://rails.rubystyle.guide#has-many-through'
|
212
211
|
Enabled: true
|
213
212
|
VersionAdded: '0.12'
|
214
213
|
Include:
|
@@ -216,7 +215,7 @@ Rails/HasAndBelongsToMany:
|
|
216
215
|
|
217
216
|
Rails/HasManyOrHasOneDependent:
|
218
217
|
Description: 'Define the dependent option to the has_many and has_one associations.'
|
219
|
-
StyleGuide: '#has_many-has_one-dependent-option'
|
218
|
+
StyleGuide: 'https://rails.rubystyle.guide#has_many-has_one-dependent-option'
|
220
219
|
Enabled: true
|
221
220
|
VersionAdded: '0.50'
|
222
221
|
Include:
|
@@ -263,7 +262,7 @@ Rails/InverseOf:
|
|
263
262
|
|
264
263
|
Rails/LexicallyScopedActionFilter:
|
265
264
|
Description: "Checks that methods specified in the filter's `only` or `except` options are explicitly defined in the controller."
|
266
|
-
StyleGuide: '#lexically-scoped-action-filter'
|
265
|
+
StyleGuide: 'https://rails.rubystyle.guide#lexically-scoped-action-filter'
|
267
266
|
Enabled: true
|
268
267
|
Safe: false
|
269
268
|
VersionAdded: '0.52'
|
@@ -328,7 +327,7 @@ Rails/ReadWriteAttribute:
|
|
328
327
|
Description: >-
|
329
328
|
Checks for read_attribute(:attr) and
|
330
329
|
write_attribute(:attr, val).
|
331
|
-
StyleGuide: '#read-attribute'
|
330
|
+
StyleGuide: 'https://rails.rubystyle.guide#read-attribute'
|
332
331
|
Enabled: true
|
333
332
|
VersionAdded: '0.20'
|
334
333
|
VersionChanged: '0.29'
|
@@ -379,7 +378,7 @@ Rails/RequestReferer:
|
|
379
378
|
|
380
379
|
Rails/ReversibleMigration:
|
381
380
|
Description: 'Checks whether the change method of the migration file is reversible.'
|
382
|
-
StyleGuide: '#reversible-migration'
|
381
|
+
StyleGuide: 'https://rails.rubystyle.guide#reversible-migration'
|
383
382
|
Reference: 'https://api.rubyonrails.org/classes/ActiveRecord/Migration/CommandRecorder.html'
|
384
383
|
Enabled: true
|
385
384
|
VersionAdded: '0.47'
|
@@ -398,7 +397,7 @@ Rails/SafeNavigation:
|
|
398
397
|
|
399
398
|
Rails/SaveBang:
|
400
399
|
Description: 'Identifies possible cases where Active Record save! or related should be used.'
|
401
|
-
StyleGuide: '#save-bang'
|
400
|
+
StyleGuide: 'https://rails.rubystyle.guide#save-bang'
|
402
401
|
Enabled: false
|
403
402
|
VersionAdded: '0.42'
|
404
403
|
VersionChanged: '0.59'
|
@@ -437,7 +436,7 @@ Rails/SkipsModelValidations:
|
|
437
436
|
|
438
437
|
Rails/TimeZone:
|
439
438
|
Description: 'Checks the correct usage of time zone aware methods.'
|
440
|
-
StyleGuide: '#time'
|
439
|
+
StyleGuide: 'https://rails.rubystyle.guide#time'
|
441
440
|
Reference: 'http://danilenko.org/2012/7/6/rails_timezones'
|
442
441
|
Enabled: true
|
443
442
|
Safe: false
|
@@ -38,6 +38,8 @@ module RuboCop
|
|
38
38
|
# # good
|
39
39
|
# a.presence || b
|
40
40
|
class Presence < Cop
|
41
|
+
include RangeHelp
|
42
|
+
|
41
43
|
MSG = 'Use `%<prefer>s` instead of `%<current>s`.'
|
42
44
|
|
43
45
|
def_node_matcher :redundant_receiver_and_other, <<-PATTERN
|
@@ -115,9 +117,29 @@ module RuboCop
|
|
115
117
|
end
|
116
118
|
|
117
119
|
def replacement(receiver, other)
|
118
|
-
or_source =
|
120
|
+
or_source = if other&.send_type?
|
121
|
+
build_source_for_or_method(other)
|
122
|
+
else
|
123
|
+
''
|
124
|
+
end
|
125
|
+
|
119
126
|
"#{receiver.source}.presence" + or_source
|
120
127
|
end
|
128
|
+
|
129
|
+
def build_source_for_or_method(other)
|
130
|
+
if other.parenthesized? || !other.arguments?
|
131
|
+
" || #{other.source}"
|
132
|
+
else
|
133
|
+
method = range_between(
|
134
|
+
other.source_range.begin_pos,
|
135
|
+
other.first_argument.source_range.begin_pos - 1
|
136
|
+
).source
|
137
|
+
|
138
|
+
arguments = other.arguments.map(&:source).join(', ')
|
139
|
+
|
140
|
+
" || #{method}(#{arguments})"
|
141
|
+
end
|
142
|
+
end
|
121
143
|
end
|
122
144
|
end
|
123
145
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rubocop-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.3.
|
4
|
+
version: 2.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bozhidar Batsov
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2019-08-
|
13
|
+
date: 2019-08-26 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rack
|
@@ -137,7 +137,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
137
137
|
- !ruby/object:Gem::Version
|
138
138
|
version: '0'
|
139
139
|
requirements: []
|
140
|
-
rubygems_version: 3.0.
|
140
|
+
rubygems_version: 3.0.6
|
141
141
|
signing_key:
|
142
142
|
specification_version: 4
|
143
143
|
summary: Automatic Rails code style checking tool.
|