Skip to content

Commit

Permalink
Fixed a NestedIterators and a FeatureEnvy within Sniffer
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinrutherford committed Jun 15, 2009
1 parent 790e498 commit 8d5e4b8
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 14 deletions.
2 changes: 1 addition & 1 deletion Manifest.txt
Expand Up @@ -30,9 +30,9 @@ lib/reek/smells/long_parameter_list.rb
lib/reek/smells/long_yield_list.rb
lib/reek/smells/nested_iterators.rb
lib/reek/smells/smell_detector.rb
lib/reek/smells/smells.rb
lib/reek/smells/uncommunicative_name.rb
lib/reek/smells/utility_function.rb
lib/reek/sniffer.rb
lib/reek/source.rb
lib/reek/spec.rb
lib/reek/stop_context.rb
Expand Down
1 change: 1 addition & 0 deletions lib/reek/smells/smell_detector.rb
Expand Up @@ -37,6 +37,7 @@ def self.default_config
def self.listen(hooks, config)
detector = new(config[class_name])
contexts.each { |ctx| hooks[ctx] << detector }
detector
end

def initialize(config)
Expand Down
20 changes: 7 additions & 13 deletions lib/reek/sniffer.rb
Expand Up @@ -55,15 +55,16 @@ class Sniffer
def initialize
defaults_file = File.join(File.dirname(__FILE__), '..', '..', 'config', 'defaults.reek')
@config = YAML.load_file(defaults_file)
@listeners = nil
@detectors = nil
@listeners = []
end

def smell_listeners()
unless @listeners
@listeners = Hash.new {|hash,key| hash[key] = [] }
SMELL_CLASSES.each { |smell| smell.listen(@listeners, @config) }
unless @detectors
@detectors = Hash.new {|hash,key| hash[key] = [] }
SMELL_CLASSES.each { |smell| @listeners << smell.listen(@detectors, @config) }
end
@listeners
@detectors
end

def load_local(file)
Expand All @@ -86,14 +87,7 @@ def disable(smell)
end

def report_on(report)
smell_listeners.each_value do |group|
report_group(group, report)
end
end

def report_group(group, report)
group.each {|smell| smell.report_on(report)}
@listeners # BUG -- this line only needed to shut up FeatureEnvy
@listeners.each {|smell| smell.report_on(report)}
end

def examine(scope, type)
Expand Down

0 comments on commit 8d5e4b8

Please sign in to comment.