class RailsBestPractices::Lexicals::RemoveTrailingWhitespaceCheck

Make sure there are no trailing whitespace in codes.

See the best practice details here rails-bestpractices.com/posts/2010/12/02/remove-trailing-whitespace/

Public Instance Methods

check(filename, content) click to toggle source

check if the content of file contain a trailing whitespace.

@param [String] filename name of the file @param [String] content content of the file

# File lib/rails_best_practices/lexicals/remove_trailing_whitespace_check.rb, line 16
def check(filename, content)
  if content =~ / +\n/m
    line_no = $`.count("\n") + 1
    add_error('remove trailing whitespace', filename, line_no)
  end
end