Last active
July 24, 2018 16:49
-
-
Save kplawver/2883bc48c7f07dda7a405439d5ee66ab to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
desc "Checks ruby syntax on all files" | |
task :syntax_check do | |
puts "#{Dir.pwd}" | |
current_dir = Dir.pwd | |
files = [] | |
["app", "config", "lib", "experiments", "spec"].each do |dir| | |
files = files + Dir.glob("#{current_dir}/#{dir}/**/*.rb") | |
end | |
puts "Testing #{files.length} files:" | |
success = 0 | |
failed = 0 | |
puts "--------" | |
files.each do |path| | |
out = `ruby -c #{path}`.strip | |
if !out.include?("Syntax OK") | |
puts "- #{path.remove(current_dir)}: #{out}" | |
failed += 1 | |
else | |
success += 1 | |
end | |
end | |
puts "--------" | |
puts "#{success} Successful, #{failed} Failed" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I ran into an issue where I was getting a stack trace way farther down than the actual error with rspec. So, I wrote this thing to syntax check every file that matters in a Rails app. It only prints files that fail, but will give you a total of successful checks.