Merge in ability to ignore comments
This commit is contained in:
commit
366d1393c5
@ -208,11 +208,16 @@ module Rails
|
|||||||
# If they're on Windows, they probably don't have grep.
|
# If they're on Windows, they probably don't have grep.
|
||||||
@probably_has_grep ||= (Config::CONFIG['host_os'].downcase =~ /mswin|windows|mingw/).nil?
|
@probably_has_grep ||= (Config::CONFIG['host_os'].downcase =~ /mswin|windows|mingw/).nil?
|
||||||
|
|
||||||
if @probably_has_grep
|
lines = if @probably_has_grep
|
||||||
find_with_grep(text, base_path + where, double_quote)
|
find_with_grep(text, base_path + where, double_quote)
|
||||||
else
|
else
|
||||||
find_with_rak(text, base_path + where, double_quote)
|
find_with_rak(text, base_path + where, double_quote)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# ignore comments
|
||||||
|
lines.gsub! /^\s*#.+$/m, ""
|
||||||
|
|
||||||
|
lines
|
||||||
end
|
end
|
||||||
|
|
||||||
# Sets a base path for finding files; mostly for testing
|
# Sets a base path for finding files; mostly for testing
|
||||||
@ -260,9 +265,10 @@ module Rails
|
|||||||
def extract_filenames_from_grep(output)
|
def extract_filenames_from_grep(output)
|
||||||
return nil if output.empty?
|
return nil if output.empty?
|
||||||
|
|
||||||
# I hate rescue nil as much as the next guy but I have a reason here at least...
|
|
||||||
fnames = output.split("\n").map do |fn|
|
fnames = output.split("\n").map do |fn|
|
||||||
fn.match(/^(.+?):/)[1] rescue nil
|
if m = fn.match(/^(.+?):/)
|
||||||
|
m[1]
|
||||||
|
end
|
||||||
end.compact
|
end.compact
|
||||||
|
|
||||||
fnames.uniq
|
fnames.uniq
|
||||||
|
@ -140,6 +140,13 @@ class ApplicationCheckerTest < ActiveSupport::TestCase
|
|||||||
assert @checker.alerts.has_key?("Known broken plugins")
|
assert @checker.alerts.has_key?("Known broken plugins")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_ignoring_comments
|
||||||
|
make_file("config/", "routes.rb", "# map.connect 'fail'")
|
||||||
|
@checker.check_routes
|
||||||
|
|
||||||
|
assert !@checker.alerts.has_key?("Old router API")
|
||||||
|
end
|
||||||
|
|
||||||
def teardown
|
def teardown
|
||||||
clear_files
|
clear_files
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user