Reputation: 31074
I was surprised to learn that warnings are apparently disabled by default in rake:
def broken_code
path = '/tmp/foo'
# create empty file
File.open(path, 'w')
# when warnings are enabled you get a warning here- File#new does not take a block
File.new(path) do |f|
puts "never get here..."
end
end
task :no_warnings do |t|
broken_code
end
task :warnings do |t|
$VERBOSE = 1
broken_code
end
Why are they disabled? Is there a simple way to enable them, beyond setting VERBOSE=1
early in your code?
Upvotes: 0
Views: 387
Reputation: 114208
It works for me:
# Rakefile
task :foo do |t|
File.new {}
end
Result:
$ rake foo
(in /tmp)
/tmp/Rakefile:2: warning: File::new() does not take block; use File::open() instead
rake aborted!
Upvotes: 2