Sha256: 926a3269bcce8f210d722d56b0f93a3595c6e68b7928adb25693e1414340f913
Contents?: true
Size: 960 Bytes
Versions: 1
Compression:
Stored size: 960 Bytes
Contents
require 'yaml' require 'private_attr/everywhere' module Reek # # A comment header from an abstract syntax tree; found directly above # module, class and method definitions. # # @api private 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 private private_attr_reader :text end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
reek-3.3.0 | lib/reek/code_comment.rb |