datamapper/dm-core — Issue #172: dm-core generates excessive warnings
Author: lsiden
Created: 2011-12-28 14:31:41+00:00
State: open

I'm using dm-core 1.2.0 When I enable warnings with "ruby -w", dm-core generates several screen-fulls of warnings. I know that warnings are incredibly useful, but not if they are not dealt with and clutter up my output so badly that I have trouble noticing warnings that are generated by my own code that I need to deal with.

I have been able to suppress warnings generated in DataMapper#setup() by bracketing it with "$VERBOSE=nil" (turn them off) and "$VERBOSE=false" (set them back to default) - see http://www.justskins.com/forums/warnings-33468.html#post97927.

However, there are still at least a dozen warnings and I have not been able to figure out where to turn them off.

.../.rvm/gems/ruby-1.9.2-p290@accounts/gems/dm-core-1.2.0/lib/dm-core/query/conditions/comparison.rb:278: warning: private attribute?
.../.rvm/gems/ruby-1.9.2-p290@accounts/gems/dm-core-1.2.0/lib/dm-core/resource/persistence_state.rb:40: warning: private attribute?
.../.rvm/gems/ruby-1.9.2-p290@accounts/gems/dm-core-1.2.0/lib/dm-core/property/object.rb:19: warning: mismatched indentations at 'end' with 'case' at 14
.../.rvm/gems/ruby-1.9.2-p290@accounts/gems/dm-core-1.2.0/lib/dm-core/model/hook.rb:56: warning: shadowing outer local variable - hooks
.../.rvm/gems/ruby-1.9.2-p290@accounts/gems/dm-core-1.2.0/lib/dm-core/model/property.rb:68: warning: shadowing outer local variable - properties
.../.rvm/gems/ruby-1.9.2-p290@accounts/gems/dm-core-1.2.0/lib/dm-core/model/property.rb:86: warning: shadowing outer local variable - context
.../.rvm/gems/ruby-1.9.2-p290@accounts/gems/dm-core-1.2.0/lib/dm-core/associations/relationship.rb:656: warning: shadowing outer local variable - source
.../.rvm/gems/ruby-1.9.2-p290@accounts/gems/dm-core-1.2.0/lib/dm-core/associations/relationship.rb:433: warning: private attribute?
.../.rvm/gems/ruby-1.9.2-p290@accounts/gems/dm-core-1.2.0/lib/dm-core/associations/relationship.rb:436: warning: private attribute?
.../.rvm/gems/ruby-1.9.2-p290@accounts/gems/dm-core-1.2.0/lib/dm-core/associations/one_to_one.rb:67: warning: private attribute?
.../.rvm/gems/ruby-1.9.2-p290@accounts/gems/dm-core-1.2.0/lib/dm-core/support/logger.rb:71: warning: instance variable @log not initialized
.../.rvm/gems/ruby-1.9.2-p290@accounts/gems/dm-constraints-1.2.0/lib/data_mapper/constraints/relationship/one_to_many.rb:20: warning: shadowing outer local variable - resource
.../.rvm/gems/ruby-1.9.2-p290@accounts/gems/dm-migrations-1.2.0/lib/dm-migrations/sql/table_creator.rb:17: warning: `&' interpreted as argument prefix
.../.rvm/gems/ruby-1.9.2-p290@accounts/gems/dm-migrations-1.2.0/lib/dm-migrations/sql/table_modifier.rb:14: warning: `&' interpreted as argument prefix
.../.rvm/gems/ruby-1.9.2-p290@accounts/gems/dm-validations-1.2.0/lib/dm-validations/formats/email.rb:59: warning: character class has duplicated range

I suppose I can hack the library to throw an exception on each of the warning lines so that I can figure out where in my code they are getting called from and bracket that code as Matz suggested with $VERBOSE=nil etc.

For future releases, could these be suppressed in the "production" version of the gem since there's little that I or anyone can do about them without opening up DataMapper and they make it much harder for me to see warnings generated by my own code?