rubocop-github 0.4.0 → 0.4.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
  SHA1:
3
- metadata.gz: ab0b671ded0342a09ab6abaed49ead04d5e8d998
4
- data.tar.gz: 3f7fba786bcab859beab172f8cd873b31053a816
3
+ metadata.gz: 207be109d4ce7854620ccad83592f04fe8cdb06e
4
+ data.tar.gz: a11cca89a562cc3c7c7518a094f7f3063d400d20
5
5
  SHA512:
6
- metadata.gz: 64db71077a7663685feaeb399caf49fce7b190471f1df6a17b5f40623134bf3edf1aded0bd10bcdb913a57c85e32c43d966232cf6ff42adbb58b0fa76a471950
7
- data.tar.gz: 823c96ff8f71694450d79de94cb5479a92c7d734646b18023f2e6044c940a8e1f1a7bf28af8e45b074b5ce80410b2985aba2a244ff7fd0144562553e8f3fc5c0
6
+ metadata.gz: 3f75e2f6854f25ab19a62e5e371e2d068df4ea91f0c7deb6631ea7e4f4d416f7258017f2e4cb0b06aaf00cc7e4b9c424e19ffcf16d45d7106c82505e9d1b3d63
7
+ data.tar.gz: c4efb68eb56ae3f49f6656437d1bb81c72b4a22b069f96a22af90077b9e8ac6d30b591eff9337609dd0c0cf6059e89a259282def47c9a0a68c2866737d16fd2a
@@ -28,12 +28,6 @@ GitHub/RailsControllerRenderActionSymbol:
28
28
  Include:
29
29
  - 'app/controllers/**/*.rb'
30
30
 
31
- GitHub/RailsControllerRenderInline:
32
- Enabled: true
33
- StyleGuide: https://github.com/github/rubocop-github/blob/master/guides/rails-controller-render-inline.md
34
- Include:
35
- - 'app/controllers/**/*.rb'
36
-
37
31
  GitHub/RailsControllerRenderLiteral:
38
32
  Enabled: true
39
33
  StyleGuide: https://github.com/github/rubocop-github/blob/master/guides/rails-render-literal.md
@@ -53,6 +47,15 @@ GitHub/RailsControllerRenderShorthand:
53
47
  Include:
54
48
  - 'app/controllers/**/*.rb'
55
49
 
50
+ GitHub/RailsRenderInline:
51
+ Enabled: true
52
+ StyleGuide: https://github.com/github/rubocop-github/blob/master/guides/rails-controller-render-inline.md
53
+ Include:
54
+ - 'app/controllers/**/*.rb'
55
+ - 'app/helpers/**/*.rb'
56
+ - 'app/view_models/**/*.rb'
57
+ - 'app/views/**/*.erb'
58
+
56
59
  GitHub/RailsRenderObjectCollection:
57
60
  Enabled: false
58
61
 
@@ -1,9 +1,9 @@
1
1
  require "rubocop/cop/github/rails_application_record"
2
2
  require "rubocop/cop/github/rails_controller_render_action_symbol"
3
- require "rubocop/cop/github/rails_controller_render_inline"
4
3
  require "rubocop/cop/github/rails_controller_render_literal"
5
4
  require "rubocop/cop/github/rails_controller_render_paths_exist"
6
5
  require "rubocop/cop/github/rails_controller_render_shorthand"
6
+ require "rubocop/cop/github/rails_render_inline"
7
7
  require "rubocop/cop/github/rails_render_object_collection"
8
8
  require "rubocop/cop/github/rails_view_render_literal"
9
9
  require "rubocop/cop/github/rails_view_render_paths_exist"
@@ -29,6 +29,7 @@ module RuboCop
29
29
  :body
30
30
  :file
31
31
  :html
32
+ :inline
32
33
  :js
33
34
  :json
34
35
  :nothing
@@ -5,7 +5,7 @@ require "rubocop"
5
5
  module RuboCop
6
6
  module Cop
7
7
  module GitHub
8
- class RailsControllerRenderInline < Cop
8
+ class RailsRenderInline < Cop
9
9
  MSG = "Avoid `render inline:`"
10
10
 
11
11
  def_node_matcher :render_with_options?, <<-PATTERN
@@ -21,7 +21,13 @@ module RuboCop
21
21
  PATTERN
22
22
 
23
23
  def_node_matcher :render_with_options?, <<-PATTERN
24
- (send nil :render (hash $...))
24
+ (send nil :render (hash $...) ...)
25
+ PATTERN
26
+
27
+ def_node_matcher :ignore_key?, <<-PATTERN
28
+ (pair (sym {
29
+ :inline
30
+ }) $_)
25
31
  PATTERN
26
32
 
27
33
  def_node_matcher :partial_key?, <<-PATTERN
@@ -37,6 +43,10 @@ module RuboCop
37
43
 
38
44
  if render_literal?(node)
39
45
  elsif option_pairs = render_with_options?(node)
46
+ if option_pairs.any? { |pair| ignore_key?(pair) }
47
+ return
48
+ end
49
+
40
50
  if partial_node = option_pairs.map { |pair| partial_key?(pair) }.compact.first
41
51
  if !literal?(partial_node)
42
52
  add_offense(node, :expression)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubocop-github
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - GitHub
@@ -80,10 +80,10 @@ files:
80
80
  - lib/rubocop/cop/github.rb
81
81
  - lib/rubocop/cop/github/rails_application_record.rb
82
82
  - lib/rubocop/cop/github/rails_controller_render_action_symbol.rb
83
- - lib/rubocop/cop/github/rails_controller_render_inline.rb
84
83
  - lib/rubocop/cop/github/rails_controller_render_literal.rb
85
84
  - lib/rubocop/cop/github/rails_controller_render_paths_exist.rb
86
85
  - lib/rubocop/cop/github/rails_controller_render_shorthand.rb
86
+ - lib/rubocop/cop/github/rails_render_inline.rb
87
87
  - lib/rubocop/cop/github/rails_render_object_collection.rb
88
88
  - lib/rubocop/cop/github/rails_view_render_literal.rb
89
89
  - lib/rubocop/cop/github/rails_view_render_paths_exist.rb