lib/reek/configuration/app_configuration.rb in reek-2.2.1 vs lib/reek/configuration/app_configuration.rb in reek-3.0.0

- old
+ new

@@ -1,15 +1,20 @@ require_relative './configuration_file_finder' module Reek + # @api private module Configuration + # @api private class ConfigFileException < StandardError; end # # Reek's singleton configuration instance. # + # @api private module AppConfiguration - @configuration = {} + NON_SMELL_TYPE_KEYS = %w(exclude_paths) + EXCLUDE_PATHS_KEY = 'exclude_paths' + @configuration = {} @has_been_initialized = false class << self attr_reader :configuration @@ -22,11 +27,11 @@ def configure_smell_repository(smell_repository) # Let users call this method directly without having initialized AppConfiguration before # and if they do, initialize it without application context initialize_with(nil) unless @has_been_initialized - @configuration.each do |klass_name, config| + for_smell_types.each do |klass_name, config| klass = load_smell_type(klass_name) smell_repository.configure(klass, config) if klass end end @@ -47,10 +52,20 @@ def reset @configuration.clear end + def exclude_paths + @exclude_paths ||= @configuration. + fetch(EXCLUDE_PATHS_KEY, []). + map { |path| path.chomp('/') } + end + private + + def for_smell_types + @configuration.reject { |key, _value| NON_SMELL_TYPE_KEYS.include?(key) } + end def load_smell_type(name) Reek::Smells.const_get(name) rescue NameError report_problem("\"#{name}\" is not a code smell")