Class: Rubocop::Cop::AvoidPerlBackrefs

Inherits:
Cop
  • Object
show all
Defined in:
lib/rubocop/cop/avoid_perl_backrefs.rb

Instance Attribute Summary

Attributes inherited from Cop

#correlations, #offences

Instance Method Summary collapse

Methods inherited from Cop

#add_offence, #has_report?, inherited, #initialize

Constructor Details

This class inherits a constructor from Rubocop::Cop::Cop

Instance Method Details

#inspect(file, source, tokens, sexp) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/rubocop/cop/avoid_perl_backrefs.rb', line 6

def inspect(file, source, tokens, sexp)
  each(:@backref, sexp) do |s|
    backref = s[1]
    lineno = s[2].lineno

    add_offence(
      :convention,
      lineno,
      "Prefer the use of MatchData over #{backref}."
    )
  end
end