Sha256: 547b05fedf4d1f57b77e4e3e2c715e050e2a82f7202c239db1b3c877bd02a6ff
Contents?: true
Size: 851 Bytes
Versions: 5
Compression:
Stored size: 851 Bytes
Contents
# encoding: utf-8 module Rubocop module Cop module Style # Checks for colon (:) not followed by some kind of space. class SpaceAfterColon < Cop include IfNode MSG = 'Space missing after colon.' def on_pair(node) oper = node.loc.operator if oper.is?(':') && oper.source_buffer.source[oper.end_pos] =~ /\S/ add_offense(oper, oper) end end def on_if(node) if ternary_op?(node) colon = node.loc.colon if colon.source_buffer.source[colon.end_pos] =~ /\S/ add_offense(colon, colon) end end end def autocorrect(range) @corrections << lambda do |corrector| corrector.insert_after(range, ' ') end end end end end end
Version data entries
5 entries across 5 versions & 1 rubygems