Skip to content

Commit d4df4e2

Browse files
Merge branch 'master' into patch-1
2 parents f4241fb + 9604707 commit d4df4e2

File tree

3 files changed

+17
-8
lines changed

3 files changed

+17
-8
lines changed

lib/rubocop/cop/github/render_literal_helpers.rb

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,6 @@ module RenderLiteralHelpers
2020
(send nil? {:render :render_to_string} ({str sym} $_) $...)
2121
PATTERN
2222

23-
def_node_matcher :render_inst?, <<-PATTERN
24-
(send nil? {:render :render_to_string} (send _ :new ...) ...)
25-
PATTERN
26-
2723
def_node_matcher :render_with_options?, <<-PATTERN
2824
(send nil? {:render :render_to_string} (hash $...) ...)
2925
PATTERN
@@ -32,6 +28,10 @@ module RenderLiteralHelpers
3228
(send nil? {:render :render_to_string} (send _ :new ...) ...)
3329
PATTERN
3430

31+
def_node_matcher :render_view_component_instance_with_content?, <<-PATTERN
32+
(send nil? {:render :render_to_string} (send (send _ :new ...) `:with_content ...))
33+
PATTERN
34+
3535
def_node_matcher :render_view_component_collection?, <<-PATTERN
3636
(send nil? {:render :render_to_string} (send _ :with_collection ...) ...)
3737
PATTERN
@@ -45,7 +45,8 @@ def hash_with_literal_keys?(hash)
4545
end
4646

4747
def render_view_component?(node)
48-
render_view_component_instance?(node) ||
48+
render_view_component_instance_with_content?(node) ||
49+
render_view_component_instance?(node) ||
4950
render_view_component_collection?(node)
5051
end
5152
end

rubocop-github.gemspec

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,16 @@
22

33
Gem::Specification.new do |s|
44
s.name = "rubocop-github"
5-
s.version = "0.16.1"
5+
s.version = "0.16.2"
66
s.summary = "RuboCop GitHub"
77
s.description = "Code style checking for GitHub Ruby repositories "
88
s.homepage = "https://github.com/github/rubocop-github"
99
s.license = "MIT"
1010

1111
s.files = Dir["README.md", "STYLEGUIDE.md", "LICENSE", "config/*.yml", "lib/**/*.rb", "guides/*.md"]
1212

13-
s.add_dependency "rubocop", "<= 1.6.1"
14-
s.add_dependency "rubocop-performance", "<= 1.7.1"
13+
s.add_dependency "rubocop", "<= 1.13.0"
14+
s.add_dependency "rubocop-performance", "<= 1.11.0"
1515
s.add_dependency "rubocop-rails", "<= 2.7.1"
1616

1717
s.add_development_dependency "actionview", "~> 5.0"

test/test_rails_view_render_literal.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,14 @@ def test_render_component_instance_no_offense
6262
assert_equal 0, cop.offenses.count
6363
end
6464

65+
def test_render_component_instance_with_content_no_offense
66+
erb_investigate cop, <<-ERB, "app/views/foo/index.html.erb"
67+
<%= render MyClass.new(title: "foo", bar: "baz").with_content("foo") %>
68+
ERB
69+
70+
assert_equal 0, cop.offenses.count
71+
end
72+
6573
def test_render_component_instance_block_no_offense
6674
erb_investigate cop, <<-ERB, "app/views/foo/index.html.erb"
6775
<%= render Module::MyClass.new(title: "foo", bar: "baz") do %>Content<% end %>

0 commit comments

Comments
 (0)