Ruby / Don't ignore warnings
From WhyNotWiki
eigenclass - Ruby, SEX [Software EXchange and STDs: infectious practices] (http://eigenclass.org/hiki.rb?ruby-warnings-SEX-and-stds).
Here you have lots of warnings. So many that executing with $VERBOSE=nil becomes very tempting.
But public code health is everybody's business, and we must all fight this temptation.
Think about what will happen if we choose to ignore (or to never be shown) the warnings. sqlitespace.rb will add to the pile of infected, noisy code. Now imagine SQLite is fixed and runs cleanly, but sqlitespace.rb isn't. At that point in time, somebody writes a library that requires sqlitespace.rb, and he faces the same situation we did before: he's got a noisy library, and will be likely to disable warnings, easily making his [own] code relatively noisy.
It's clear by now that "shipping a library that issues lots of warnings is likely to result in even more "noisy" code being written".
[edit] Fight it
The first and most effective measure is setting RUBYOPT to -w.
Even if that's not an option because your code requires infected libraries, you can at least try to make sure you're not contributing to further spread the problem. You can also set $VERBOSE=false temporarily while requiring the libs to get rid of some syntactical warnings, if few warnings are generated afterwards.
Most warnings can be anticipated and corrected even without $VERBOSE's help. They typically fall into these categories:
- syntactical issues
- lack of parentheses with *args or &block
- spaces inside parenthesized argument list; missing parentheses again: foo(bar 1)
- uninitialized instance variables
- method redefinition
- constant reassignment
The two last ones can be avoided by removing the pertinent methods (Module#remove_method) or constants (Module#remove_const).
If you get rid of such trivial warnings, the ones you do see will often point you to possible bugs.
