mirror of
https://github.com/elastic/logstash.git
synced 2025-04-24 06:37:19 -04:00
parent
493c50c427
commit
b00ca2238e
1 changed files with 32 additions and 0 deletions
32
rakelib/static.rake
Normal file
32
rakelib/static.rake
Normal file
|
@ -0,0 +1,32 @@
|
|||
require 'rubygems'
|
||||
require "bootstrap/environment"
|
||||
|
||||
namespace "test" do
|
||||
namespace "static" do
|
||||
desc "run static analysis tests on i18n calls"
|
||||
task "i18n" do
|
||||
require 'i18n'
|
||||
|
||||
locales_path = File.join(LogStash::Environment::LOGSTASH_HOME, "logstash-core", "locales", "en.yml")
|
||||
I18n.enforce_available_locales = true
|
||||
I18n.load_path << locales_path
|
||||
I18n.reload!
|
||||
|
||||
failed = []
|
||||
|
||||
glob_path = File.join(LogStash::Environment::LOGSTASH_HOME, "logstash-*", "**", "*.rb")
|
||||
Dir.glob(glob_path).each do |file_name|
|
||||
File.foreach(file_name) do |line|
|
||||
match = line.match(/I18n.t\("(.+?)"/)
|
||||
next unless match
|
||||
failed << [file_name, match[1]] unless I18n.exists?(match[1])
|
||||
end
|
||||
end
|
||||
if failed.any?
|
||||
message = ["Static Analysis revealed incorrect calls to I18t! See list below:"]
|
||||
failed.each {|file_name, line_match| message << "* #{file_name}: #{line_match}" }
|
||||
raise Exception.new(message.join("\n"))
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue