Sha256: d118221e48ae42b2d5df720ed2c3578419b245fde076a3b84630a9686be2fa75

Contents?: true

Size: 825 Bytes

Versions: 33

Compression:

Stored size: 825 Bytes

Contents

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

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
      def url
        "http://rails-bestpractices.com/posts/60-remove-trailing-whitespace"
      end

      # 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

33 entries across 33 versions & 3 rubygems

Version Path
rails_best_practices-1.10.1 lib/rails_best_practices/lexicals/remove_trailing_whitespace_check.rb
rails_best_practices-gorgeouscode-1.0.0 lib/rails_best_practices/lexicals/remove_trailing_whitespace_check.rb
rails_best_practices-1.10.0 lib/rails_best_practices/lexicals/remove_trailing_whitespace_check.rb
rails_best_practices-1.9.1 lib/rails_best_practices/lexicals/remove_trailing_whitespace_check.rb
rails_best_practices-1.9.0 lib/rails_best_practices/lexicals/remove_trailing_whitespace_check.rb
rails_best_practices-1.8.0 lib/rails_best_practices/lexicals/remove_trailing_whitespace_check.rb
rails_best_practices-1.7.2 lib/rails_best_practices/lexicals/remove_trailing_whitespace_check.rb
rails_best_practices-1.7.1 lib/rails_best_practices/lexicals/remove_trailing_whitespace_check.rb
rails_best_practices-1.7.0 lib/rails_best_practices/lexicals/remove_trailing_whitespace_check.rb
rails_best_practices-1.6.0 lib/rails_best_practices/lexicals/remove_trailing_whitespace_check.rb
rails_best_practices-1.5.3 lib/rails_best_practices/lexicals/remove_trailing_whitespace_check.rb
rails_best_practices-1.5.2 lib/rails_best_practices/lexicals/remove_trailing_whitespace_check.rb
rails_best_practices-1.5.1 lib/rails_best_practices/lexicals/remove_trailing_whitespace_check.rb
rails_best_practices-1.5.0 lib/rails_best_practices/lexicals/remove_trailing_whitespace_check.rb
rails_best_practices-1.4.0 lib/rails_best_practices/lexicals/remove_trailing_whitespace_check.rb
rails_best_practices-1.3.0 lib/rails_best_practices/lexicals/remove_trailing_whitespace_check.rb
rails_best_practices-1.2.0 lib/rails_best_practices/lexicals/remove_trailing_whitespace_check.rb
rails_best_practices-1.1.0 lib/rails_best_practices/lexicals/remove_trailing_whitespace_check.rb
rails_best_practices-1.0.1 lib/rails_best_practices/lexicals/remove_trailing_whitespace_check.rb
rails_best_practices-1.0.0 lib/rails_best_practices/lexicals/remove_trailing_whitespace_check.rb