Sha256: 6e89d6aca7976a45fda6f4588da01f14ddd18e751da341e9ac90b6f290595965
Contents?: true
Size: 1.63 KB
Versions: 2
Compression:
Stored size: 1.63 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) 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 elem.is_a?(Parser::AST::Node) on_node(syms, elem, excludes) { |s| yield s } end end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
rubocop-0.8.3 | lib/rubocop/cop/cop.rb |
rubocop-0.8.2 | lib/rubocop/cop/cop.rb |