barsoom / attr_extras

Takes some boilerplate out of Ruby with methods like attr_initialize.
MIT License
560 stars 31 forks source link

Quell ruby warnings #3

Closed teoljungberg closed 10 years ago

henrik commented 10 years ago

Thanks! Exactly what warnings do you get with what version of Ruby running what command?

Without those changes:

09:17:41 attr_extras ruby-1.9.3 master*$ RUBYOPT=-w rake
malloc_limit=1000000000 (8000000)
/Users/henrik/.rvm/gems/ruby-1.9.3-p194-falcon@global/gems/bundler-1.5.1/lib/bundler/vendor/thor/base.rb:592: warning: instance variable @no_commands not initialized
/Users/henrik/.rvm/gems/ruby-1.9.3-p194-falcon@global/gems/bundler-1.5.1/lib/bundler/vendor/thor.rb:382: warning: instance variable @long_desc not initialized
malloc_limit=1000000000 (8000000)
/Users/henrik/Dropbox/Code/attr_extras/lib/attr_extras.rb:37: warning: `*' interpreted as argument prefix
/Users/henrik/Dropbox/Code/attr_extras/lib/attr_extras.rb:42: warning: `*' interpreted as argument prefix
Run options: --seed 44861

# Running tests:

.................../Users/henrik/Dropbox/Code/attr_extras/lib/attr_extras.rb:13: warning: private attribute?
/Users/henrik/Dropbox/Code/attr_extras/lib/attr_extras.rb:13: warning: private attribute?
./Users/henrik/Dropbox/Code/attr_extras/lib/attr_extras.rb:13: warning: private attribute?
/Users/henrik/Dropbox/Code/attr_extras/lib/attr_extras.rb:13: warning: private attribute?
/Users/henrik/Dropbox/Code/attr_extras/lib/attr_extras.rb:13: warning: private attribute?
...

Fabulous tests in 0.005886s, 3907.5773 tests/s, 7985.0493 assertions/s.

23 tests, 47 assertions, 0 failures, 0 errors, 0 skips
09:18:48 attr_extras ruby-1.9.3 master$

With those changes:

09:16:27 attr_extras ruby-1.9.3 master*$ RUBYOPT=-w rake
malloc_limit=1000000000 (8000000)
/Users/henrik/.rvm/gems/ruby-1.9.3-p194-falcon@global/gems/bundler-1.5.1/lib/bundler/vendor/thor/base.rb:592: warning: instance variable @no_commands not initialized
/Users/henrik/.rvm/gems/ruby-1.9.3-p194-falcon@global/gems/bundler-1.5.1/lib/bundler/vendor/thor.rb:382: warning: instance variable @long_desc not initialized
malloc_limit=1000000000 (8000000)
/Users/henrik/Dropbox/Code/attr_extras/lib/attr_extras.rb:37: warning: `*' interpreted as argument prefix
/Users/henrik/Dropbox/Code/attr_extras/lib/attr_extras.rb:42: warning: `*' interpreted as argument prefix
Run options: --seed 37400

# Running tests:

.................../Users/henrik/Dropbox/Code/attr_extras/lib/attr_extras.rb:13: warning: private attribute?
/Users/henrik/Dropbox/Code/attr_extras/lib/attr_extras.rb:13: warning: private attribute?
./Users/henrik/Dropbox/Code/attr_extras/lib/attr_extras.rb:13: warning: private attribute?
/Users/henrik/Dropbox/Code/attr_extras/lib/attr_extras.rb:13: warning: private attribute?
/Users/henrik/Dropbox/Code/attr_extras/lib/attr_extras.rb:13: warning: private attribute?
...

Fabulous tests in 0.006513s, 3531.3987 tests/s, 7216.3366 assertions/s.

23 tests, 47 assertions, 0 failures, 0 errors, 0 skips
teoljungberg commented 10 years ago

My ruby version is 2.1.1

Without my changes

attr_extras master % irb
>> $-w = true
=> true
>> Dir["./spec/**/*_spec.rb"].each {|f| require f }
/Users/teo/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/attr_extras-2.2.1/lib/attr_extras.rb:37: warning: `*' interpreted as argument prefix
/Users/teo/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/attr_extras-2.2.1/lib/attr_extras.rb:42: warning: `*' interpreted as argument prefix
=> ["./spec/attr_extras_spec.rb", "./spec/attr_id_query_spec.rb", "./spec/attr_initialize_spec.rb", "./spec/attr_private_spec.rb", "./spec/attr_query_spec.rb", "./spec/attr_value_spec.rb", "./spec/method_object_spec.rb", "./spec/pattr_initialize_spec.rb", "./spec/vattr_initialize_spec.rb"]
>>
Run options: --seed 38552

# Running:

................E../Users/teo/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/attr_extras-2.2.1/lib/attr_extras.rb:13: warning: private attribute?
/Users/teo/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/attr_extras-2.2.1/lib/attr_extras.rb:13: warning: private attribute?
/Users/teo/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/attr_extras-2.2.1/lib/attr_extras.rb:13: warning: private attribute?
./Users/teo/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/attr_extras-2.2.1/lib/attr_extras.rb:13: warning: private attribute?
/Users/teo/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/attr_extras-2.2.1/lib/attr_extras.rb:13: warning: private attribute?
...

Fabulous run in 0.005404s, 4256.1066 runs/s, 8327.1651 assertions/s.

  1) Error:
Object::.attr_value#test_0006_hashes objects the same if they have the same attributes:
NameError: uninitialized constant Set
    /opt/attr_extras/spec/attr_value_spec.rb:96:in `block (2 levels) in <top (required)>'

23 runs, 45 assertions, 0 failures, 1 errors, 0 skips

So it's not a warning, fixing up my commit message with that

With my changes

attr_extras patch-1 % irb
>> $-w = true
=> true
>> Dir["./spec/**/*_spec.rb"].each {|f| require f }
/opt/attr_extras/lib/attr_extras.rb:37: warning: `*' interpreted as argument prefix
/opt/attr_extras/lib/attr_extras.rb:42: warning: `*' interpreted as argument prefix
=> ["./spec/attr_extras_spec.rb", "./spec/attr_id_query_spec.rb", "./spec/attr_initialize_spec.rb", "./spec/attr_private_spec.rb", "./spec/attr_query_spec.rb", "./spec/attr_value_spec.rb", "./spec/method_object_spec.rb", "./spec/pattr_initialize_spec.rb", "./spec/vattr_initialize_spec.rb"]
>>
Run options: --seed 22814

# Running:

.................../opt/attr_extras/lib/attr_extras.rb:13: warning: private attribute?
/opt/attr_extras/lib/attr_extras.rb:13: warning: private attribute?
./opt/attr_extras/lib/attr_extras.rb:13: warning: private attribute?
/opt/attr_extras/lib/attr_extras.rb:13: warning: private attribute?
/opt/attr_extras/lib/attr_extras.rb:13: warning: private attribute?
...

Fabulous run in 0.005192s, 4429.8921 runs/s, 9052.3883 assertions/s.

23 runs, 47 assertions, 0 failures, 0 errors, 0 skips
henrik commented 10 years ago

Oh yeah, you're right, the tests don't run on their own without that. I was a bit surprised that I didn't need to require "set". Thanks again!