Sha256: a1ecdb519263c21aa4c81e2303de3d391d0d922d5652a634dd95c9fb2b170a8f
Contents?: true
Size: 1.71 KB
Versions: 1
Compression:
Stored size: 1.71 KB
Contents
# encoding: utf-8 module Rubocop module Cop class Token attr_reader :pos, :type, :text def initialize(pos, type, text) @pos, @type, @text = pos, type, text end def to_s "[[#{@pos.line}, #{@pos.column}], #{@type}, #{@text.inspect}]" end end class Cop < Parser::AST::Processor extend AST::Sexp attr_accessor :offences attr_accessor :debug attr_writer :disabled_lines @all = [] @config = {} class << self attr_accessor :all attr_accessor :config end def self.inherited(subclass) all << subclass end def self.cop_name name.to_s.split('::').last end def initialize @offences = [] @debug = false end def has_report? !@offences.empty? end def inspect(source, tokens, ast, comments) process(ast) comments.each { |c| on_comment(c) } end def on_comment(comment) end def ignore_node(node) end def add_offence(severity, line_number, message) unless @disabled_lines && @disabled_lines.include?(line_number) message = debug ? "#{name}: #{message}" : message @offences << Offence.new(severity, line_number, message) end end def name self.class.cop_name end private def on_node(syms, sexp, excludes = []) yield sexp if Array(syms).include?(sexp.type) return if Array(excludes).include?(sexp.type) sexp.children.each do |elem| if Parser::AST::Node === elem on_node(syms, elem, excludes) { |s| yield s } end end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
rubocop-0.8.1 | lib/rubocop/cop/cop.rb |