Skip to content

Commit a09eadd

Browse files
committed
Use meaningful message for locals offense
1 parent dfe8f2b commit a09eadd

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

lib/rubocop/cop/github/rails_controller_render_literal.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ class RailsControllerRenderLiteral < Base
1111

1212
MSG = "render must be used with a string literal or an instance of a Class"
1313

14+
LOCALS_MSG = "render must be used with a hash literal for the locals keyword argument"
15+
1416
def_node_matcher :ignore_key?, <<-PATTERN
1517
(pair (sym {
1618
:body
@@ -99,7 +101,7 @@ def on_send(node)
99101
if option_pairs
100102
locals = option_pairs.map { |pair| locals_key?(pair) }.compact.first
101103
if locals && (!locals.hash_type? || !hash_with_literal_keys?(locals))
102-
add_offense(node)
104+
add_offense(node, message: LOCALS_MSG)
103105
end
104106
end
105107
end

0 commit comments

Comments
 (0)