lib/rubocop/cop/rspec/indexed_let.rb in rubocop-rspec-3.0.4 vs lib/rubocop/cop/rspec/indexed_let.rb in rubocop-rspec-3.0.5
- old
+ new
@@ -46,12 +46,12 @@
#
class IndexedLet < Base
include AllowedIdentifiers
include AllowedPattern
- MSG = 'This `let` statement uses index in its name. Please give it ' \
- 'a meaningful name.'
+ MSG = 'This `let` statement uses `%<index>s` in its name. ' \
+ 'Please give it a meaningful name.'
# @!method let_name(node)
def_node_matcher :let_name, <<~PATTERN
{
(block (send nil? #Helpers.all ({str sym} $_) ...) ...)
@@ -64,10 +64,11 @@
children = node.body&.child_nodes
return unless children
filter_indexed_lets(children).each do |let_node|
- add_offense(let_node)
+ index = let_name(let_node)[INDEX_REGEX]
+ add_offense(let_node, message: format(MSG, index: index))
end
end
private