Sha256: ca5ae4c94ef70226f15a662e3e5980be0183b654ea83cf4f53654ff30201a274

Contents?: true

Size: 794 Bytes

Versions: 10

Compression:

Stored size: 794 Bytes

Contents

# encoding: utf-8
module RailsBestPractices
  module Lexicals
    # Make sure there are no trailing whitespace in codes.
    #
    # See the best practice details here http://rails-bestpractices.com/posts/60-remove-trailing-whitespace
    class RemoveTrailingWhitespaceCheck < Core::Check
      interesting_files ALL_FILES
      url "http://rails-bestpractices.com/posts/60-remove-trailing-whitespace"

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

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
rails_best_practices-1.15.6 lib/rails_best_practices/lexicals/remove_trailing_whitespace_check.rb
rails_best_practices-1.15.4 lib/rails_best_practices/lexicals/remove_trailing_whitespace_check.rb
rails_best_practices-1.15.3 lib/rails_best_practices/lexicals/remove_trailing_whitespace_check.rb
rails_best_practices-1.15.2 lib/rails_best_practices/lexicals/remove_trailing_whitespace_check.rb
rails_best_practices-1.15.1 lib/rails_best_practices/lexicals/remove_trailing_whitespace_check.rb
rails_best_practices-1.14.4 lib/rails_best_practices/lexicals/remove_trailing_whitespace_check.rb
rails_best_practices-1.14.3 lib/rails_best_practices/lexicals/remove_trailing_whitespace_check.rb
rails_best_practices-1.14.2 lib/rails_best_practices/lexicals/remove_trailing_whitespace_check.rb
rails_best_practices-1.14.1 lib/rails_best_practices/lexicals/remove_trailing_whitespace_check.rb
rails_best_practices-1.14.0 lib/rails_best_practices/lexicals/remove_trailing_whitespace_check.rb