Sha256: b3d42b7130e659da3ab760450b6a74ccce10588e9bc1dbf539431267aa39ed17

Contents?: true

Size: 750 Bytes

Versions: 22

Compression:

Stored size: 750 Bytes

Contents

# encoding: utf-8
require 'rails_best_practices/core/check'

module RailsBestPractices
  module Lexicals
    # Make sure there are no tabs in files.
    #
    # See the best practice details here http://rails-bestpractices.com/posts/81-remove-tab
    class RemoveTabCheck < Core::Check
      def url
        "http://rails-bestpractices.com/posts/81-remove-tab"
      end

      # check if the content of file contains a tab.
      #
      # @param [String] filename name of the file
      # @param [String] content content of the file
      def check(filename, content)
        if content =~ /\t/m
          line_no = $`.count("\n") + 1
          add_error("remove tab, use spaces instead", filename, line_no)
        end
      end
    end
  end
end

Version data entries

22 entries across 22 versions & 2 rubygems

Version Path
rails_best_practices-0.10.1 lib/rails_best_practices/lexicals/remove_tab_check.rb
rails_best_practices-0.10.0 lib/rails_best_practices/lexicals/remove_tab_check.rb