Sha256: baca8717f8c0d357362ac0d1eecae6b488af49621ffd8af431428fb2975f7a9e
Contents?: true
Size: 1.03 KB
Versions: 1
Compression:
Stored size: 1.03 KB
Contents
# Warning for insufficient space between inline comments and code class Wool::InlineCommentSpaceWarning < Wool::LineWarning OPTION_KEY = :inline_comment_space DEFAULT_SPACE = 2 type :style short_desc 'Inline comment spacing error' desc { "Inline comments must be at least #{@settings[OPTION_KEY]} spaces from code." } opt OPTION_KEY, 'Number of spaces between code and inline comments', :default => DEFAULT_SPACE def match?(line = self.body) return false unless comment_token = find_token(:on_comment) comment_pos = comment_token.col - 1 left_of_comment = line[0..comment_pos] stripped = left_of_comment.rstrip return false if stripped.empty? padding_size = left_of_comment.size - stripped.size return spacing != padding_size end def fix comment_token = find_token(:on_comment) comment_pos = comment_token.col - 1 left_of_comment = line[0..comment_pos].rstrip left_of_comment + (' ' * spacing) + comment_token.body end def spacing @settings[OPTION_KEY] || DEFAULT_SPACE end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
wool-0.5.1 | lib/wool/warnings/comment_spacing.rb |