Sha256: 9a700a3876874158bc9c141fbc8eb30bad26dc3efcdc53d5a9577e97f85c7341
Contents?: true
Size: 698 Bytes
Versions: 1
Compression:
Stored size: 698 Bytes
Contents
# Warning for using semicolons outside of class declarations. class Wool::SemicolonWarning < Wool::LineWarning type :style short_desc 'Semicolon for multiple statements' desc 'The line uses a semicolon to separate multiple statements outside of a class declaration.' def initialize(*args) super self.severity = line =~ /['"]/ ? 2 : 4 end def match?(line = self.body) !!(find_token(line, :on_semicolon) && !find_keyword(line, :class)) end def fix(line = self.body) left, right = split_on_token(line, :on_semicolon) return line if right.empty? return right[1..-1] if left.empty? right = fix(right[1..-1]) "#{indent left}\n#{indent right}" end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
wool-0.5.1 | lib/wool/warnings/semicolon.rb |