Sha256: ac666b02fc730a287b39f3410ac971d51a00e4fa803045007a528902d75a61c7
Contents?: true
Size: 876 Bytes
Versions: 3
Compression:
Stored size: 876 Bytes
Contents
# encoding: utf-8 module Rubocop module Cop module Style # Checks for various control keywords missing a space after them. class SpaceAfterControlKeyword < Cop MSG = 'Use space after control keywords.' # elsif and unless are handled by on_if. KEYWORDS = %w(if case when while until) def on_keyword(node) return if node.loc.is_a?(Parser::Source::Map::Ternary) exp = node.loc.expression kw = node.loc.keyword kw_offset = kw.begin_pos - exp.begin_pos if exp.source[kw_offset..-1].start_with?(kw.source + '(') add_offence(:convention, kw, MSG) end end KEYWORDS.each do |keyword| define_method(:"on_#{keyword}") do |node| on_keyword(node) super(node) end end end end end end
Version data entries
3 entries across 3 versions & 2 rubygems