Skip to content

Commit

Permalink
Splitting up more code dependent on ParseTree
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinrutherford committed May 11, 2009
1 parent 11aacf7 commit 050fac5
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 58 deletions.
1 change: 0 additions & 1 deletion Manifest.txt
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ spec/reek/name_spec.rb
spec/reek/object_refs_spec.rb
spec/reek/options_spec.rb
spec/reek/report_spec.rb
spec/reek/sexp_formatter_spec.rb
spec/reek/singleton_method_context_spec.rb
spec/reek/smells/control_couple_spec.rb
spec/reek/smells/duplication_spec.rb
Expand Down
23 changes: 0 additions & 23 deletions lib/reek/code_parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,6 @@ def self.unify(sexp) # :nodoc:
return unifier.process(sexp[0])
end

def self.parse_tree_for(code) # :nodoc:
unify(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, smells, ctx = StopContext.new)
Expand All @@ -38,21 +34,6 @@ def initialize(report, smells, ctx = StopContext.new)
@require_empty = @warn_on_default = false
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(CodeParser.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)
sexp = CodeParser.unify(ParseTree.new.parse_tree(obj))
check_parse_tree(sexp)
end

def process_default(exp)
exp[0..-1].each { |sub| process(sub) if Array === sub }
s(exp)
Expand Down Expand Up @@ -211,9 +192,5 @@ def pop(exp)
@element = @element.outer
s(exp)
end

def check_parse_tree(sexp) # :nodoc:
process(sexp)
end
end
end
3 changes: 2 additions & 1 deletion lib/reek/object_source.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ def self.from_object(obj)

class ObjectSource < Source # :nodoc:
def check(parser) # :nodoc:
parser.check_object(@source)
sexp = CodeParser.unify(ParseTree.new.parse_tree(@source))
parser.process(sexp)
end
end
end
Expand Down
3 changes: 2 additions & 1 deletion lib/reek/source.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ def initialize(code, desc, dir = nil) # :nodoc:
end

def check(parser) # :nodoc:
parser.check_source(@source)
sexp = CodeParser.unify(ParseTree.new.parse_tree_for_string(@source))
parser.process(sexp)
end

#
Expand Down
32 changes: 0 additions & 32 deletions spec/reek/sexp_formatter_spec.rb

This file was deleted.

0 comments on commit 050fac5

Please sign in to comment.