Sha256: b8e85fc39d1c6b55e38a744a6e95bcb088c36bd8264710a38716aa5f538c02b1
Contents?: true
Size: 859 Bytes
Versions: 11
Compression:
Stored size: 859 Bytes
Contents
# encoding: utf-8 module RuboCop module Cop module Style # This cop checks for tabs inside the source code. class Tab < Cop MSG = 'Tab detected.' def investigate(processed_source) processed_source.lines.each_with_index do |line, index| match = line.match(/^( *)[\t ]*\t/) next unless match spaces = match.captures[0] range = source_range(processed_source.buffer, index + 1, (spaces.length)...(match.end(0))) add_offense(range, range, MSG) end end private def autocorrect(range) @corrections << lambda do |corrector| corrector.replace(range, range.source.gsub(/\t/, ' ')) end end end end end end
Version data entries
11 entries across 11 versions & 2 rubygems