lib/reek/smells/smell_detector.rb in reek-1.3.8 vs lib/reek/smells/smell_detector.rb in reek-1.4.0

- old
+ new

@@ -2,22 +2,20 @@ require 'reek/smell_warning' require 'reek/core/smell_configuration' module Reek module Smells - module ExcludeInitialize def self.default_config super.merge(EXCLUDE_KEY => ['initialize']) end end # # Shared responsibilities of all smell detectors. # class SmellDetector - # The name of the config field that lists the names of code contexts # that should not be checked. Add this field to the config for each # smell that should ignore this code element. EXCLUDE_KEY = 'exclude' @@ -63,14 +61,18 @@ def configure_with(config) @config.merge!(config) end def examine(context) - enabled = @config.enabled? && config_for(context)[Core::SmellConfiguration::ENABLED_KEY] != false - if enabled && !exception?(context) - sm = examine_context(context) - @smells_found += sm - end + return unless enabled_for? context + return if exception?(context) + + sm = examine_context(context) + @smells_found += sm + end + + def enabled_for?(context) + enabled? && config_for(context)[Core::SmellConfiguration::ENABLED_KEY] != false end def exception?(context) context.matches?(value(EXCLUDE_KEY, context, DEFAULT_EXCLUDE_SET)) end