rubocop-standard 1.12.0 → 1.14.0
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 +11 -10
- data/lib/rubocop/cop/standard.rb +10 -10
- data/lib/rubocop/cop/standard/rails_application_record.rb +2 -2
- data/lib/rubocop/cop/standard/rails_controller_render_action_symbol.rb +2 -2
- data/lib/rubocop/cop/standard/rails_controller_render_literal.rb +2 -2
- data/lib/rubocop/cop/standard/rails_controller_render_paths_exist.rb +7 -7
- data/lib/rubocop/cop/standard/rails_controller_render_shorthand.rb +5 -5
- data/lib/rubocop/cop/standard/rails_render_inline.rb +2 -2
- data/lib/rubocop/cop/standard/rails_render_object_collection.rb +3 -3
- data/lib/rubocop/cop/standard/rails_view_render_literal.rb +2 -2
- data/lib/rubocop/cop/standard/rails_view_render_paths_exist.rb +6 -6
- data/lib/rubocop/cop/standard/rails_view_render_shorthand.rb +2 -2
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c0c408c8483f108e7f01e3aeabc27edfd600de157f1f1a2420cf28c3296496c8
|
4
|
+
data.tar.gz: ca41d2d7a619d1008351ffc30a287d6142529babcb170a259d7acc298d24c712
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 617cab056ab07550c3657a2f37298a9dbd92fc40fdfdd170065c876e0332adeca1e40de8067dcf421bbb30e5d5efb3218b2bfd9a60752add06dedd9cb821939a
|
7
|
+
data.tar.gz: 86e4d63d7df020c2d870372013c434b0c5daca8ba0a8c239155ce9c61a2550766a055507bee405d8fdef9c2dff5588b6b6adf01a655252965562785d40a290f4
|
data/config/default.yml
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require: rubocop/cop/standard
|
2
|
+
require: rubocop-performance
|
2
3
|
|
3
4
|
AllCops:
|
4
5
|
DisabledByDefault: true
|
@@ -229,9 +230,6 @@ Performance/EndWith:
|
|
229
230
|
Performance/FlatMap:
|
230
231
|
Enabled: true
|
231
232
|
|
232
|
-
Performance/LstripRstrip:
|
233
|
-
Enabled: true
|
234
|
-
|
235
233
|
Performance/RangeInclude:
|
236
234
|
Enabled: false
|
237
235
|
|
@@ -242,15 +240,9 @@ Performance/RedundantMerge:
|
|
242
240
|
Enabled: true
|
243
241
|
MaxKeyValuePairs: 1
|
244
242
|
|
245
|
-
Performance/RedundantSortBy:
|
246
|
-
Enabled: true
|
247
|
-
|
248
243
|
Performance/ReverseEach:
|
249
244
|
Enabled: true
|
250
245
|
|
251
|
-
Performance/Sample:
|
252
|
-
Enabled: true
|
253
|
-
|
254
246
|
Performance/Size:
|
255
247
|
Enabled: true
|
256
248
|
|
@@ -318,9 +310,18 @@ Style/Not:
|
|
318
310
|
Style/OneLineConditional:
|
319
311
|
Enabled: true
|
320
312
|
|
313
|
+
Style/RedundantSortBy:
|
314
|
+
Enabled: true
|
315
|
+
|
316
|
+
Style/Sample:
|
317
|
+
Enabled: true
|
318
|
+
|
321
319
|
Style/StabbyLambdaParentheses:
|
322
320
|
Enabled: true
|
323
321
|
|
324
322
|
Style/StringLiterals:
|
325
323
|
Enabled: true
|
326
|
-
EnforcedStyle:
|
324
|
+
EnforcedStyle: single_quotes
|
325
|
+
|
326
|
+
Style/Strip:
|
327
|
+
Enabled: true
|
data/lib/rubocop/cop/standard.rb
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
4
|
-
require
|
5
|
-
require
|
6
|
-
require
|
7
|
-
require
|
8
|
-
require
|
9
|
-
require
|
10
|
-
require
|
11
|
-
require
|
12
|
-
require
|
3
|
+
require 'rubocop/cop/standard/rails_application_record'
|
4
|
+
require 'rubocop/cop/standard/rails_controller_render_action_symbol'
|
5
|
+
require 'rubocop/cop/standard/rails_controller_render_literal'
|
6
|
+
require 'rubocop/cop/standard/rails_controller_render_paths_exist'
|
7
|
+
require 'rubocop/cop/standard/rails_controller_render_shorthand'
|
8
|
+
require 'rubocop/cop/standard/rails_render_inline'
|
9
|
+
require 'rubocop/cop/standard/rails_render_object_collection'
|
10
|
+
require 'rubocop/cop/standard/rails_view_render_literal'
|
11
|
+
require 'rubocop/cop/standard/rails_view_render_paths_exist'
|
12
|
+
require 'rubocop/cop/standard/rails_view_render_shorthand'
|
@@ -1,12 +1,12 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
3
|
+
require 'rubocop'
|
4
4
|
|
5
5
|
module RuboCop
|
6
6
|
module Cop
|
7
7
|
module Standard
|
8
8
|
class RailsApplicationRecord < Cop
|
9
|
-
MSG =
|
9
|
+
MSG = 'Models should subclass from ApplicationRecord'
|
10
10
|
|
11
11
|
def_node_matcher :active_record_base_const?, <<-PATTERN
|
12
12
|
(const (const nil? :ActiveRecord) :Base)
|
@@ -1,12 +1,12 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
3
|
+
require 'rubocop'
|
4
4
|
|
5
5
|
module RuboCop
|
6
6
|
module Cop
|
7
7
|
module Standard
|
8
8
|
class RailsControllerRenderActionSymbol < Cop
|
9
|
-
MSG =
|
9
|
+
MSG = 'Prefer `render` with string instead of symbol'
|
10
10
|
|
11
11
|
def_node_matcher :render_sym?, <<-PATTERN
|
12
12
|
(send nil? :render $(sym _))
|
@@ -1,12 +1,12 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
3
|
+
require 'rubocop'
|
4
4
|
|
5
5
|
module RuboCop
|
6
6
|
module Cop
|
7
7
|
module Standard
|
8
8
|
class RailsControllerRenderLiteral < Cop
|
9
|
-
MSG =
|
9
|
+
MSG = 'render must be used with a string literal'
|
10
10
|
|
11
11
|
def_node_matcher :literal?, <<-PATTERN
|
12
12
|
({str sym true false nil?} ...)
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
3
|
+
require 'rubocop'
|
4
4
|
|
5
5
|
module RuboCop
|
6
6
|
module Cop
|
@@ -23,12 +23,12 @@ module RuboCop
|
|
23
23
|
PATTERN
|
24
24
|
|
25
25
|
def on_send(node)
|
26
|
-
return unless cop_config[
|
26
|
+
return unless cop_config['ViewPath']
|
27
27
|
|
28
28
|
if args = render_str?(node)
|
29
29
|
node, path = args
|
30
30
|
unless resolve_template(path.to_s)
|
31
|
-
add_offense(node, location: :expression, message:
|
31
|
+
add_offense(node, location: :expression, message: 'Template could not be found')
|
32
32
|
end
|
33
33
|
elsif pairs = render_options?(node)
|
34
34
|
if pair = pairs.detect { |p| render_key?(p) }
|
@@ -37,11 +37,11 @@ module RuboCop
|
|
37
37
|
case key
|
38
38
|
when :action, :template
|
39
39
|
unless resolve_template(path.to_s)
|
40
|
-
add_offense(node, location: :expression, message:
|
40
|
+
add_offense(node, location: :expression, message: 'Template could not be found')
|
41
41
|
end
|
42
42
|
when :partial
|
43
43
|
unless resolve_partial(path.to_s)
|
44
|
-
add_offense(node, location: :expression, message:
|
44
|
+
add_offense(node, location: :expression, message: 'Partial template could not be found')
|
45
45
|
end
|
46
46
|
end
|
47
47
|
end
|
@@ -49,8 +49,8 @@ module RuboCop
|
|
49
49
|
end
|
50
50
|
|
51
51
|
def resolve_template(path)
|
52
|
-
cop_config[
|
53
|
-
if m = Dir[File.join(config.path_relative_to_config(view_path), path) +
|
52
|
+
cop_config['ViewPath'].each do |view_path|
|
53
|
+
if m = Dir[File.join(config.path_relative_to_config(view_path), path) + '*'].first
|
54
54
|
return m
|
55
55
|
end
|
56
56
|
end
|
@@ -1,12 +1,12 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
3
|
+
require 'rubocop'
|
4
4
|
|
5
5
|
module RuboCop
|
6
6
|
module Cop
|
7
7
|
module Standard
|
8
8
|
class RailsControllerRenderShorthand < Cop
|
9
|
-
MSG =
|
9
|
+
MSG = 'Prefer `render` template shorthand'
|
10
10
|
|
11
11
|
def_node_matcher :render_with_options?, <<-PATTERN
|
12
12
|
(send nil? :render (hash $...))
|
@@ -32,10 +32,10 @@ module RuboCop
|
|
32
32
|
if option_pairs = render_with_options?(node)
|
33
33
|
option_pairs.each do |pair|
|
34
34
|
if value_node = action_key?(pair)
|
35
|
-
comma = option_pairs.length > 1 ?
|
35
|
+
comma = option_pairs.length > 1 ? ', ' : ''
|
36
36
|
corrected_source = node.source
|
37
|
-
.sub(/#{pair.source}(,\s*)?/,
|
38
|
-
.sub(
|
37
|
+
.sub(/#{pair.source}(,\s*)?/, '')
|
38
|
+
.sub('render ', "render \"#{str(value_node)}\"#{comma}")
|
39
39
|
|
40
40
|
@autocorrect[node] = lambda do |corrector|
|
41
41
|
corrector.replace(node.source_range, corrected_source)
|
@@ -1,12 +1,12 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
3
|
+
require 'rubocop'
|
4
4
|
|
5
5
|
module RuboCop
|
6
6
|
module Cop
|
7
7
|
module Standard
|
8
8
|
class RailsRenderInline < Cop
|
9
|
-
MSG =
|
9
|
+
MSG = 'Avoid `render inline:`'
|
10
10
|
|
11
11
|
def_node_matcher :render_with_options?, <<-PATTERN
|
12
12
|
(send nil? :render (hash $...))
|
@@ -1,12 +1,12 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
3
|
+
require 'rubocop'
|
4
4
|
|
5
5
|
module RuboCop
|
6
6
|
module Cop
|
7
7
|
module Standard
|
8
8
|
class RailsRenderObjectCollection < Cop
|
9
|
-
MSG =
|
9
|
+
MSG = 'Avoid `render object:`'
|
10
10
|
|
11
11
|
def_node_matcher :render_with_options?, <<-PATTERN
|
12
12
|
(send nil? :render (hash $...) ...)
|
@@ -36,7 +36,7 @@ module RuboCop
|
|
36
36
|
end
|
37
37
|
add_offense(node, location: :expression, message: "Avoid `render object:`#{suggestion}")
|
38
38
|
when :collection, :spacer_template
|
39
|
-
add_offense(node, location: :expression, message:
|
39
|
+
add_offense(node, location: :expression, message: 'Avoid `render collection:`')
|
40
40
|
end
|
41
41
|
end
|
42
42
|
end
|
@@ -1,12 +1,12 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
3
|
+
require 'rubocop'
|
4
4
|
|
5
5
|
module RuboCop
|
6
6
|
module Cop
|
7
7
|
module Standard
|
8
8
|
class RailsViewRenderLiteral < Cop
|
9
|
-
MSG =
|
9
|
+
MSG = 'render must be used with a string literal'
|
10
10
|
|
11
11
|
def_node_matcher :literal?, <<-PATTERN
|
12
12
|
({str sym true false nil?} ...)
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
3
|
+
require 'rubocop'
|
4
4
|
|
5
5
|
module RuboCop
|
6
6
|
module Cop
|
@@ -23,19 +23,19 @@ module RuboCop
|
|
23
23
|
PATTERN
|
24
24
|
|
25
25
|
def on_send(node)
|
26
|
-
return unless cop_config[
|
26
|
+
return unless cop_config['ViewPath']
|
27
27
|
|
28
28
|
if args = render_str?(node)
|
29
29
|
node, path = args
|
30
30
|
unless resolve_partial(path.to_s)
|
31
|
-
add_offense(node, location: :expression, message:
|
31
|
+
add_offense(node, location: :expression, message: 'Partial template could not be found')
|
32
32
|
end
|
33
33
|
elsif pairs = render_options?(node)
|
34
34
|
if pair = pairs.detect { |p| partial_key?(p) }
|
35
35
|
node, path = partial_key?(pair)
|
36
36
|
|
37
37
|
unless resolve_partial(path.to_s)
|
38
|
-
add_offense(node, location: :expression, message:
|
38
|
+
add_offense(node, location: :expression, message: 'Partial template could not be found')
|
39
39
|
end
|
40
40
|
end
|
41
41
|
end
|
@@ -46,8 +46,8 @@ module RuboCop
|
|
46
46
|
parts << "_#{parts.pop}"
|
47
47
|
path = parts.join(File::SEPARATOR)
|
48
48
|
|
49
|
-
cop_config[
|
50
|
-
if m = Dir[File.join(config.path_relative_to_config(view_path), path) +
|
49
|
+
cop_config['ViewPath'].each do |view_path|
|
50
|
+
if m = Dir[File.join(config.path_relative_to_config(view_path), path) + '*'].first
|
51
51
|
return m
|
52
52
|
end
|
53
53
|
end
|
@@ -1,12 +1,12 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
3
|
+
require 'rubocop'
|
4
4
|
|
5
5
|
module RuboCop
|
6
6
|
module Cop
|
7
7
|
module Standard
|
8
8
|
class RailsViewRenderShorthand < Cop
|
9
|
-
MSG =
|
9
|
+
MSG = 'Prefer `render` partial shorthand'
|
10
10
|
|
11
11
|
def_node_matcher :render_with_options?, <<-PATTERN
|
12
12
|
(send nil? :render (hash $...))
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rubocop-standard
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.14.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Garen Torikian
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-04-
|
11
|
+
date: 2019-04-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rubocop
|
@@ -24,6 +24,20 @@ dependencies:
|
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0.63'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rubocop-performance
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 1.1.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.1.0
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: actionview
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|