Sha256: 83fdb273ae89b0c15d4d40696d89f104c4a0a94b0af945d74481840e4e564f0d
Contents?: true
Size: 999 Bytes
Versions: 1
Compression:
Stored size: 999 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 return unless exp.source[kw_offset..-1].start_with?(kw.source + '(') add_offense(node, kw) end KEYWORDS.each do |keyword| define_method(:"on_#{keyword}") do |node| on_keyword(node) end end def autocorrect(node) @corrections << lambda do |corrector| corrector.insert_after(node.loc.keyword, ' ') end end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
rubocop-0.22.0 | lib/rubocop/cop/style/space_after_control_keyword.rb |