Sha256: c1ee8ab2d5f92436e1bd428df800c5a9a685223cf52e35f004d3107eb613d8dd
Contents?: true
Size: 1.21 KB
Versions: 1
Compression:
Stored size: 1.21 KB
Contents
require 'reek/adapters/source' require 'reek/configuration' require 'reek/smells/large_class' include Reek::Smells module Reek class ObjectSource < Source # :nodoc: def self.unify(sexp) # :nodoc: unifier = Unifier.new unifier.processors.each do |proc| proc.unsupported.delete :cfunc # HACK end return unifier.process(sexp[0]) end def configure(sniffer) super disabled_config = {Reek::SmellConfiguration::ENABLED_KEY => false} sniffer.configure(LargeClass, disabled_config) end def self.can_parse_objects? return true if Object.const_defined?(:ParseTree) begin require 'parse_tree' true rescue LoadError false end end def syntax_tree if ObjectSource.can_parse_objects? ObjectSource.unify(ParseTree.new.parse_tree(@source)) else throw ArgumentError.new('You must install the ParseTree gem to use this feature') end end end end class Object # # Constructs a Sniffer which examines this object for code smells. # (This feature is only enabled if you have the ParseTree gem installed.) # def to_reek_source ObjectSource.new(self, self.to_s) end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
reek-1.2.1 | lib/reek/adapters/object_source.rb |