Sha256: caaab8e4290c083ba2eae73c254c8c0ac32e1444f7c17f5cb3cfce4198eb04fb
Contents?: true
Size: 1.66 KB
Versions: 1
Compression:
Stored size: 1.66 KB
Contents
$:.unshift File.dirname(__FILE__) require 'rubygems' require 'parse_tree' require 'sexp_processor' module Reek class Checker < SexpProcessor def self.parse_tree_for(code) # :nodoc: ParseTree.new.parse_tree_for_string(code) end # Creates a new Ruby code checker. Any smells discovered by # +check_source+ or +check_object+ will be stored in +report+. def initialize(report) super() @smells = report @unsupported -= [:cfunc] @default_method = :process_default @require_empty = @warn_on_default = false end def process_default(exp) exp[1..-1].each { |e| process(e) if Array === e} s(exp) end def process_defn(exp) # :nodoc: Reek::MethodChecker.new(@smells, @description).process(exp) s(exp) end def report(smell) # :nodoc: @smells << smell end # Analyses the given Ruby source +code+ looking for smells. # Any smells found are saved in the +Report+ object that # was passed to this object's constructor. def check_source(code) check_parse_tree(Checker.parse_tree_for(code)) end # Analyses the given Ruby object +obj+ looking for smells. # Any smells found are saved in the +Report+ object that # was passed to this object's constructor. def check_object(obj) check_parse_tree ParseTree.new.parse_tree(obj) end def to_s # :nodoc: description end def check_parse_tree(sexp) # :nodoc: sexp.each { |exp| process(exp) } end end end # SMELL: # This is here to resolve a circular dependency -- MethodChecker inherits # Checker, which calls MethodChecker. Yuk! require 'reek/method_checker'
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
reek-0.3.1 | lib/reek/checker.rb |