Skip to content

Commit

Permalink
Removed conditional construction from Source
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinrutherford committed Jun 15, 2009
1 parent 8d5e4b8 commit b3f2406
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions lib/reek/sniffer.rb
Expand Up @@ -67,8 +67,8 @@ def smell_listeners()
@detectors
end

def load_local(file)
path = File.expand_path(file)
def configure_using(filename)
path = File.expand_path(File.dirname(filename))
all_reekfiles(path).each do |rfile|
YAML.load_file(rfile).push_keys(@config)
end
Expand Down
8 changes: 4 additions & 4 deletions lib/reek/source.rb
Expand Up @@ -46,7 +46,8 @@ def self.from_f(file)
#
def self.from_path(filename)
code = IO.readlines(filename).join
return new(code, filename, File.dirname(filename))
sniffer = Sniffer.new.configure_using(filename)
return new(code, filename, sniffer)
end

#
Expand All @@ -58,11 +59,10 @@ def self.from_pathlist(paths)
SourceList.new(sources)
end

def initialize(code, desc, dir = nil) # :nodoc:
def initialize(code, desc, sniffer = Sniffer.new) # :nodoc:
@source = code
@desc = desc
@sniffer = Sniffer.new
@sniffer = @sniffer.load_local(dir) if dir
@sniffer = sniffer
end

def generate_syntax_tree
Expand Down

0 comments on commit b3f2406

Please sign in to comment.