class Reek::CodeComment
A comment header from an abstract syntax tree; found directly above module, class and method definitions.
Constants
- CONFIGURATION_REGEX
- DISABLE_DETECTOR_CONFIGURATION
- MINIMUM_CONTENT_LENGTH
- SANITIZE_REGEX
Attributes
Public Class Methods
Source
# File lib/reek/code_comment.rb, line 34 def initialize(comment:, line: nil, source: nil) @original_comment = comment @line = line @source = source @config = Hash.new { |hash, key| hash[key] = {} } @original_comment.scan(CONFIGURATION_REGEX) do |detector_name, separator, options| escalate_legacy_separator separator validator = CodeCommentValidator.new(detector_name: detector_name, original_comment: original_comment, line: line, source: source, options: options) validator.validate @config.merge! detector_name => validator.parsed_options end end
@param comment [String] the original comment as found in the source code @param line [Integer] start of the expression the comment belongs to @param source [String] Path to source file or “string”
Public Instance Methods
Source
# File lib/reek/code_comment.rb, line 52 def descriptive? sanitized_comment.split(/\s+/).length >= MINIMUM_CONTENT_LENGTH end
Private Instance Methods
Source
# File lib/reek/code_comment.rb, line 67 def escalate_legacy_separator(separator) return unless separator.start_with? ':' raise Errors::LegacyCommentSeparatorError.new(original_comment: original_comment, source: source, line: line) end
Source
# File lib/reek/code_comment.rb, line 60 def sanitized_comment @sanitized_comment ||= original_comment. gsub(CONFIGURATION_REGEX, ''). gsub(SANITIZE_REGEX, ' '). strip end