Sha256: 4034eeeadac261ae515379becc35005ce4feca61a9fe3d7ed864266fa0d1526c
Contents?: true
Size: 940 Bytes
Versions: 13
Compression:
Stored size: 940 Bytes
Contents
require 'yaml' module Reek module Source # # A comment header from an abstract syntax tree; found directly above # module, class and method definitions. # class CodeComment CONFIG_REGEX = /:reek:(\w+)(:\s*\{.*?\})?/ def initialize(text) @text = text.gsub(CONFIG_REGEX) do add_to_config($1, $2) '' end.gsub(/#/, '').gsub(/\n/, '').strip end def config @config ||= Hash.new { |hash, key| hash[key] = {} } end def descriptive? @text.split(/\s+/).length >= 2 end protected def add_to_config(smell, options) options ||= ': { enabled: false }' config.merge! YAML.load(smell.gsub(/(?:^|_)(.)/) { $1.upcase } + options) # TODO: extend this to all configs -------------------^ # TODO: extend to allow configuration of whole smell class, not just subclass end end end end
Version data entries
13 entries across 13 versions & 1 rubygems