Eliminating warnings from rails

I am developing my first rails app and I am quite shocked at the
amount of warnings the rails source spits out.

Please guys, try running the rails source with '-w' as a RUBYOPT and
addressing the warnings. Rails spits out tons of warnings and this is
definitively a pain for doing proper ruby development.

Please guys, try running the rails source with '-w' as a RUBYOPT and
addressing the warnings. Rails spits out tons of warnings and this is
definitively a pain for doing proper ruby development.

Patches go to http://dev.rubyonrails.org. Knock yourself out!

I know Eric Hodel put in patches for this atleast twice and they were
ignored. Would a patch making Rails -w safe be welcomed at this point?

Sure, any patches which apply cleanly and don't have any side effects
will be greatfully received.

the best way to ensure they'll apply cleanly is not to provide one
massive patch for the entirety of rails.

Does anyone know of the best way to remove the warnings like this?
For the method redef, is it just do an undef right before the new
method is created?

...vendor/rails/actionpack/lib/action_controller/assertions/../vendor/html-scanner/html/node.rb:299:
warning: method redefined; discarding old []

....vendor/rails/activerecord/lib/active_record/reflection.rb:133:
warning: instance variable @primary_key_name not initialized

- Rob

Sure; they’ve always been welcome. Eric’s ticket 1792 was addressed in r3124-3135 and r3169.

“-w safety” is a bikeshedder’s dream, unfortunately. There are some warnings, such as for uninitialized instance variables, that I won’t bend over backward to fix just for the warning’s sake. Nor will I cry over red herrings like double requires due to Ruby not resolving full paths (require “foo/…/bar” and require “bar” loads bar.rb twice.)

Ultimately I’m happy to apply patches, though more to quiet the FUD than the warnings.

jeremy

Yes. Do an undef before it. Most of the warnings do not come from
rails itself but from some of its libraries (active record, action
pack, etc).

Here's the full page of warnings I get on starting a server, for
example, with latest rails 1.1.6:
./script/../config/boot.rb:28:Warning: require_gem is obsolete. Use
gem instead.
/usr/lib/ruby/gems/1.8/gems/activerecord-1.14.4/lib/active_record/
validations.rb:334: warning: `*' interpreted as argument prefix
/usr/lib/ruby/gems/1.8/gems/activerecord-1.14.4/lib/active_record/
validations.rb:363: warning: `*' interpreted as argument prefix
/usr/lib/ruby/gems/1.8/gems/activerecord-1.14.4/lib/active_record/
migration.rb:224: warning: instance variable @ignore_new_methods not
initialized
/usr/lib/ruby/gems/1.8/gems/activerecord-1.14.4/lib/active_record/
migration.rb:224: warning: instance variable @ignore_new_methods not
initialized
/usr/lib/ruby/gems/1.8/gems/activerecord-1.14.4/lib/active_record/
connection_adapters/abstract/connection_specification.rb:41: warning:
method redefined; discarding old allow_concurrency=
/usr/lib/ruby/gems/1.8/gems/activerecord-1.14.4/lib/active_record/
connection_adapters/sqlserver_adapter.rb:456: warning: method
redefined; discarding old remove_column
/usr/lib/ruby/gems/1.8/gems/activerecord-1.14.4/lib/active_record/
connection_adapters/oracle_adapter.rb:119: warning: (...) interpreted
as grouped expression
/usr/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/
request.rb:171: warning: method redefined; discarding old
relative_url_root
/usr/lib/ruby/1.8/cgi/session/pstore.rb:17: warning: method redefined;
discarding old []=
/usr/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/
cgi_ext/raw_post_data_fix.rb:57: warning: ambiguous first argument;
put parentheses or even spaces
/usr/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/
cgi_ext/raw_post_data_fix.rb:8: warning: method redefined; discarding
old initialize_query
/usr/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/
session/active_record_store.rb:129: warning: private attribute?
/usr/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/
session/active_record_store.rb:179: warning: method redefined;
discarding old connection
/usr/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_view/helpers/
prototype_helper.rb:641: warning: ambiguous first argument; put
parentheses or even spaces
/usr/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_view/helpers/
prototype_helper.rb:874: warning: `*' interpreted as argument prefix
/usr/lib/ruby/gems/1.8/gems/actionmailer-1.2.5/lib/action_mailer/
vendor/tmail/facade.rb:486: warning: method redefined; discarding old
create_reply
/usr/lib/ruby/gems/1.8/gems/actionwebservice-1.1.6/lib/
action_web_service/protocol/xmlrpc_protocol.rb:6: warning: discarding
old message
/usr/lib/ruby/gems/1.8/gems/rails-1.1.6/lib/initializer.rb:581:
warning: method redefined; discarding old []=
/usr/lib/ruby/gems/1.8/gems/rails-1.1.6/lib/initializer.rb:590:
warning: method redefined; discarding old []
/usr/lib/ruby/gems/1.8/gems/rails-1.1.6/lib/initializer.rb:595:
warning: method redefined; discarding old keys
/usr/lib/ruby/gems/1.8/gems/rails-1.1.6/lib/initializer.rb:600:
warning: method redefined; discarding old find_pair
/usr/lib/ruby/gems/1.8/gems/rails-1.1.6/lib/initializer.rb:607:
warning: method redefined; discarding old []=
/usr/lib/ruby/gems/1.8/gems/rails-1.1.6/lib/initializer.rb:611:
warning: method redefined; discarding old []
/usr/lib/ruby/gems/1.8/gems/rails-1.1.6/lib/initializer.rb:615:
warning: method redefined; discarding old method_missing
=> Booting WEBrick...
/usr/lib/ruby/gems/1.8/gems/rails-1.1.6/lib/initializer.rb:483:
warning: instance variable @after_initialize_block not initialized
/usr/lib/ruby/gems/1.8/gems/rails-1.1.6/lib/webrick_server.rb:12:
warning: method redefined; discarding old stdinput
/usr/lib/ruby/gems/1.8/gems/rails-1.1.6/lib/webrick_server.rb:16:
warning: method redefined; discarding old env_table
/usr/lib/ruby/gems/1.8/gems/rails-1.1.6/lib/webrick_server.rb:20:
warning: method redefined; discarding old initialize