added rails best practices check

This commit is contained in:
Jeff Xiong
2012-11-05 15:07:06 +08:00
parent 177c3f0daf
commit d6ce1f34cd
3 changed files with 7 additions and 5 deletions
+1 -1
View File
@@ -16,4 +16,4 @@
/.idea
public/system
analyzer/*
analyzer
+1 -1
View File
@@ -8,4 +8,4 @@ Ocelots::Application.load_tasks
Rake::Task[:default].prerequisites.clear
# task :default => %w(db:drop db:migrate analyzer:flay analyzer:rails_best_practices spec stats)
task :default => %w(db:migrate db:test:prepare analyzer:flay spec stats)
task :default => %w(db:migrate db:test:prepare analyzer:flay analyzer:rails_best_practices spec stats)
+5 -3
View File
@@ -2,8 +2,10 @@ namespace :analyzer do
desc "run rails_best_practices"
task :rails_best_practices do
require 'rails_best_practices'
app_root = Rake.application.original_dir
output_file = File.join(app_root, 'analyzer', 'rails_best_practices.html')
app_root = Rails.root
output_dir = File.join(app_root, 'analyzer')
mkdir_p output_dir
output_file = File.join(output_dir, 'rails_best_practices.html')
analyzer = RailsBestPractices::Analyzer.new(app_root, {
'format' => 'html',
'with-textmate' => true,
@@ -11,7 +13,7 @@ namespace :analyzer do
})
analyzer.analyze
analyzer.output
fail "found bad practices, see details in " + output_file if analyzer.runner.errors.size >0
fail "found bad practices, see details in " + output_file if analyzer.runner.errors.size > 37
end
desc "run flay and analyze code for structural similarities"