Sha256: 6bd356547b43d0892e895a178617fa110e0b2caa22d6908780d58bde7be0395c
Contents?: true
Size: 609 Bytes
Versions: 10
Compression:
Stored size: 609 Bytes
Contents
# encoding: utf-8 module RuboCop module Cop module Style # This cop looks for uses of Perl-style regexp match # backreferences like $1, $2, etc. class PerlBackrefs < Cop MSG = 'Avoid the use of Perl-style backrefs.' def on_nth_ref(node) add_offense(node, :expression) end def autocorrect(node) @corrections << lambda do |corrector| backref, = *node corrector.replace(node.loc.expression, "Regexp.last_match[#{backref}]") end end end end end end
Version data entries
10 entries across 10 versions & 2 rubygems