lib/reek/smells/smell_detector.rb in reek-4.4.0 vs lib/reek/smells/smell_detector.rb in reek-4.4.1
- old
+ new
@@ -11,13 +11,11 @@
# - {file:docs/Basic-Smell-Options.md}
# - {file:docs/Code-Smells.md}
# - {file:README.md}
# for details.
#
- # :reek:TooManyMethods: { max_methods: 19 }
- # :reek:TooManyInstanceVariables: { max_instance_variables: 5 }
- # :reek:UnusedPrivateMethod: { exclude: [ inherited, smell_warning ] }
+ # :reek:UnusedPrivateMethod: { exclude: [ smell_warning ] }
class SmellDetector
attr_reader :config
# 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.
@@ -26,12 +24,11 @@
# The default value for the +EXCLUDE_KEY+ if it isn't specified
# in any configuration file.
DEFAULT_EXCLUDE_SET = [].freeze
def initialize(config = {})
- @config = SmellConfiguration.new self.class.default_config.merge(config)
- @smells_found = []
+ @config = SmellConfiguration.new self.class.default_config.merge(config)
end
def smell_type
self.class.smell_type
end
@@ -39,20 +36,16 @@
def contexts
self.class.contexts
end
def run_for(context)
- return unless enabled_for?(context)
- return if exception?(context)
+ return [] unless enabled_for?(context)
+ return [] if exception?(context)
- self.smells_found = smells_found + sniff(context)
+ sniff(context)
end
- def report_on(collector)
- smells_found.each { |smell| smell.report_on(collector) }
- end
-
def exception?(context)
context.matches?(value(EXCLUDE_KEY, context))
end
def self.todo_configuration_for(smells)
@@ -60,11 +53,9 @@
exclusions = default_exclusions + smells.map(&:context)
{ smell_type => { 'exclude' => exclusions.uniq } }
end
private
-
- attr_accessor :smells_found
def enabled_for?(context)
config.enabled? && config_for(context)[SmellConfiguration::ENABLED_KEY] != false
end