floere/phony — pull request #147 by franckverrot (2014-03-12 09:18:01+00:00)
Title: Verbose mode and warning fixes

Hello there,

I am the author of [ActiveValidators](https://github.com/franckverrot/activevalidators) and I bundle your (awesome) gem with mine for phone validations.

I run the test suite with the `-w` flag making Ruby more verbose about a lot of things: syntax, ambiguous calls, etc. and I was seeing a lot of warnings lately, which I just addressed.

Before my changes:

```shell
tmp/phony dac7d26 [±] λ bundle exec rake
/Users/cesario/.rubies/ruby-2.1.0/bin/ruby -w -S rspec ./spec/functional/error_spec.rb ./spec/functional/normalize_spec.rb ./spec/functional/plausibility_spec.rb ./spec/lib/phony/countries_spec.rb ./spec/lib/phony/country_codes_spec.rb ./spec/lib/phony/country_spec.rb ./spec/lib/phony/dsl_spec.rb ./spec/lib/phony/local_splitters/fixed_spec.rb ./spec/lib/phony/local_splitters/regex_spec.rb ./spec/lib/phony/national_code_spec.rb ./spec/lib/phony/national_splitters/fixed_spec.rb ./spec/lib/phony/national_splitters/none_spec.rb ./spec/lib/phony/national_splitters/regex_spec.rb ./spec/lib/phony/national_splitters/variable_spec.rb ./spec/lib/phony/vanity_spec.rb ./spec/lib/phony_spec.rb
/Users/cesario/.gem/ruby/2.1.0/gems/rspec-core-2.14.7/lib/rspec/core/ruby_project.rb:27: warning: File.exists? is a deprecated name, use File.exist? instead
/private/tmp/phony/spec/spec_helper.rb:3: warning: assigned but unused variable - e
/Users/cesario/.gem/ruby/2.1.0/gems/rest-client-1.6.7/lib/restclient/exceptions.rb:157: warning: assigned but unused variable - message
/Users/cesario/.gem/ruby/2.1.0/gems/rest-client-1.6.7/lib/restclient/exceptions.rb:167: warning: assigned but unused variable - message
/Users/cesario/.gem/ruby/2.1.0/gems/rest-client-1.6.7/lib/restclient/response.rb:11: warning: method redefined; discarding old body
/Users/cesario/.gem/ruby/2.1.0/gems/rest-client-1.6.7/lib/restclient/payload.rb:47: warning: mismatched indentations at 'end' with 'case' at 40
/Users/cesario/.gem/ruby/2.1.0/gems/docile-1.1.1/lib/docile/fallback_context_proxy.rb:57: warning: assigned but unused variable - e
/Users/cesario/.gem/ruby/2.1.0/gems/simplecov-html-0.8.0/lib/simplecov-html.rb:58: warning: possibly useless use of a variable in void context
[Coveralls] Set up the SimpleCov formatter.
[Coveralls] Using SimpleCov's default settings.
/private/tmp/phony/lib/phony/vanity.rb:19: warning: `*' interpreted as argument prefix
/private/tmp/phony/lib/phony/vanity.rb:32: warning: character class has duplicated range: /^0*|[^\d\w]/
/private/tmp/phony/lib/phony/national_code.rb:30: warning: ambiguous first argument; put parentheses or even spaces
/private/tmp/phony/lib/phony/country.rb:115: warning: assigned but unused variable - zero
/private/tmp/phony/lib/phony/country_codes.rb:53: warning: ambiguous first argument; put parentheses or even spaces
/private/tmp/phony/lib/phony/country_codes.rb:130: warning: assigned but unused variable - cc
/private/tmp/phony/lib/phony/country_codes.rb:134: warning: assigned but unused variable - cc
/private/tmp/phony/lib/phony/country_codes.rb:138: warning: assigned but unused variable - cc
/private/tmp/phony/lib/phony/country_codes.rb:182: warning: assigned but unused variable - e
/private/tmp/phony/lib/phony/dsl.rb:41: warning: `&' interpreted as argument prefix
/private/tmp/phony/lib/phony/countries/ireland.rb:12: warning: assigned but unused variable - handlers
/private/tmp/phony/lib/phony/countries/malaysia.rb:15: warning: assigned but unused variable - service
/private/tmp/phony/spec/spec_helper_extensions.rb:20: warning: `&' interpreted as argument prefix
/private/tmp/phony/spec/spec_helper_extensions.rb:15: warning: assigned but unused variable - e
/private/tmp/phony/spec/functional/plausibility_spec.rb:23: warning: assigned but unused variable - longest
/private/tmp/phony/spec/lib/phony/country_codes_spec.rb:17: warning: possibly useless use of == in void context
/private/tmp/phony/spec/lib/phony/country_codes_spec.rb:30: warning: possibly useless use of == in void context
/private/tmp/phony/spec/lib/phony/country_codes_spec.rb:43: warning: possibly useless use of == in void context
/private/tmp/phony/spec/lib/phony/local_splitters/regex_spec.rb:15: warning: ambiguous first argument; put parentheses or even spaces
/private/tmp/phony/spec/lib/phony/local_splitters/regex_spec.rb:61: warning: ambiguous first argument; put parentheses or even spaces
/private/tmp/phony/spec/lib/phony/local_splitters/regex_spec.rb:68: warning: ambiguous first argument; put parentheses or even spaces
/private/tmp/phony/spec/lib/phony/local_splitters/regex_spec.rb:75: warning: ambiguous first argument; put parentheses or even spaces
/private/tmp/phony/spec/lib/phony/local_splitters/regex_spec.rb:82: warning: ambiguous first argument; put parentheses or even spaces
/private/tmp/phony/spec/lib/phony_spec.rb:85: warning: possibly useless use of == in void context
/private/tmp/phony/spec/lib/phony_spec.rb:86: warning: possibly useless use of == in void context
/private/tmp/phony/spec/lib/phony_spec.rb:90: warning: possibly useless use of == in void context
......./private/tmp/phony/lib/phony/trunk_code.rb:23: warning: instance variable @code not initialized
../private/tmp/phony/lib/phony/trunk_code.rb:23: warning: instance variable @code not initialized
...................................../private/tmp/phony/lib/phony/trunk_code.rb:23: warning: instance variable @code not initialized
/private/tmp/phony/lib/phony/trunk_code.rb:23: warning: instance variable @code not initialized
/private/tmp/phony/lib/phony/trunk_code.rb:23: warning: instance variable @code not initialized
/private/tmp/phony/lib/phony/trunk_code.rb:23: warning: instance variable @code not initialized
/private/tmp/phony/lib/phony/trunk_code.rb:23: warning: instance variable @code not initialized
/private/tmp/phony/lib/phony/trunk_code.rb:23: warning: instance variable @code not initialized
/private/tmp/phony/lib/phony/trunk_code.rb:23: warning: instance variable @code not initialized
...../private/tmp/phony/lib/phony/trunk_code.rb:23: warning: instance variable @code not initialized
/private/tmp/phony/lib/phony/trunk_code.rb:23: warning: instance variable @code not initialized
/private/tmp/phony/lib/phony/trunk_code.rb:23: warning: instance variable @code not initialized
/private/tmp/phony/lib/phony/trunk_code.rb:23: warning: instance variable @code not initialized
../private/tmp/phony/lib/phony/trunk_code.rb:23: warning: instance variable @code not initialized
/private/tmp/phony/lib/phony/trunk_code.rb:23: warning: instance variable @code not initialized
/private/tmp/phony/lib/phony/trunk_code.rb:23: warning: instance variable @code not initialized
/private/tmp/phony/lib/phony/trunk_code.rb:23: warning: instance variable @code not initialized
/private/tmp/phony/lib/phony/trunk_code.rb:23: warning: instance variable @code not initialized
/private/tmp/phony/lib/phony/trunk_code.rb:23: warning: instance variable @code not initialized
/private/tmp/phony/lib/phony/trunk_code.rb:23: warning: instance variable @code not initialized
/private/tmp/phony/lib/phony/trunk_code.rb:23: warning: instance variable @code not initialized
/private/tmp/phony/lib/phony/trunk_code.rb:23: warning: instance variable @code not initialized
/private/tmp/phony/lib/phony/trunk_code.rb:23: warning: instance variable @code not initialized
/private/tmp/phony/lib/phony/trunk_code.rb:23: warning: instance variable @code not initialized
/private/tmp/phony/lib/phony/trunk_code.rb:23: warning: instance variable @code not initialized
....................................../private/tmp/phony/lib/phony/trunk_code.rb:23: warning: instance variable @code not initialized
/private/tmp/phony/lib/phony/trunk_code.rb:23: warning: instance variable @code not initialized
/private/tmp/phony/lib/phony/trunk_code.rb:23: warning: instance variable @code not initialized
/private/tmp/phony/lib/phony/trunk_code.rb:23: warning: instance variable @code not initialized
/private/tmp/phony/lib/phony/trunk_code.rb:23: warning: instance variable @code not initialized
/private/tmp/phony/lib/phony/trunk_code.rb:23: warning: instance variable @code not initialized
/private/tmp/phony/lib/phony/trunk_code.rb:23: warning: instance variable @code not initialized
/private/tmp/phony/lib/phony/trunk_code.rb:23: warning: instance variable @code not initialized
/private/tmp/phony/lib/phony/trunk_code.rb:23: warning: instance variable @code not initialized
/private/tmp/phony/lib/phony/trunk_code.rb:23: warning: instance variable @code not initialized
/private/tmp/phony/lib/phony/trunk_code.rb:23: warning: instance variable @code not initialized
/private/tmp/phony/lib/phony/trunk_code.rb:23: warning: instance variable @code not initialized
/private/tmp/phony/lib/phony/trunk_code.rb:23: warning: instance variable @code not initialized
/private/tmp/phony/lib/phony/trunk_code.rb:23: warning: instance variable @code not initialized
/private/tmp/phony/lib/phony/trunk_code.rb:23: warning: instance variable @code not initialized
/private/tmp/phony/lib/phony/trunk_code.rb:23: warning: instance variable @code not initialized
/private/tmp/phony/lib/phony/trunk_code.rb:23: warning: instance variable @code not initialized
/private/tmp/phony/lib/phony/trunk_code.rb:23: warning: instance variable @code not initialized
/private/tmp/phony/lib/phony/trunk_code.rb:23: warning: instance variable @code not initialized
/private/tmp/phony/lib/phony/trunk_code.rb:23: warning: instance variable @code not initialized
/private/tmp/phony/lib/phony/trunk_code.rb:23: warning: instance variable @code not initialized
/private/tmp/phony/lib/phony/trunk_code.rb:23: warning: instance variable @code not initialized
.............../private/tmp/phony/lib/phony/trunk_code.rb:23: warning: instance variable @code not initialized
/private/tmp/phony/lib/phony/trunk_code.rb:23: warning: instance variable @code not initialized
/private/tmp/phony/lib/phony/trunk_code.rb:23: warning: instance variable @code not initialized
/private/tmp/phony/lib/phony/trunk_code.rb:23: warning: instance variable @code not initialized
/private/tmp/phony/lib/phony/trunk_code.rb:23: warning: instance variable @code not initialized
/private/tmp/phony/lib/phony/trunk_code.rb:23: warning: instance variable @code not initialized
/private/tmp/phony/lib/phony/trunk_code.rb:23: warning: instance variable @code not initialized
/private/tmp/phony/lib/phony/trunk_code.rb:23: warning: instance variable @code not initialized
/private/tmp/phony/lib/phony/trunk_code.rb:23: warning: instance variable @code not initialized
/private/tmp/phony/lib/phony/trunk_code.rb:23: warning: instance variable @code not initialized
.../private/tmp/phony/lib/phony/trunk_code.rb:23: warning: instance variable @code not initialized
/private/tmp/phony/lib/phony/trunk_code.rb:23: warning: instance variable @code not initialized
/private/tmp/phony/lib/phony/trunk_code.rb:23: warning: instance variable @code not initialized
/private/tmp/phony/lib/phony/trunk_code.rb:23: warning: instance variable @code not initialized
/private/tmp/phony/lib/phony/trunk_code.rb:23: warning: instance variable @code not initialized
/private/tmp/phony/lib/phony/trunk_code.rb:23: warning: instance variable @code not initialized
............................................../private/tmp/phony/lib/phony/trunk_code.rb:23: warning: instance variable @code not initialized
/private/tmp/phony/lib/phony/trunk_code.rb:23: warning: instance variable @code not initialized
/private/tmp/phony/lib/phony/trunk_code.rb:23: warning: instance variable @code not initialized
/private/tmp/phony/lib/phony/trunk_code.rb:23: warning: instance variable @code not initialized
/private/tmp/phony/lib/phony/trunk_code.rb:23: warning: instance variable @code not initialized
/private/tmp/phony/lib/phony/trunk_code.rb:23: warning: instance variable @code not initialized
/private/tmp/phony/lib/phony/trunk_code.rb:23: warning: instance variable @code not initialized
/private/tmp/phony/lib/phony/trunk_code.rb:23: warning: instance variable @code not initialized
/private/tmp/phony/lib/phony/trunk_code.rb:23: warning: instance variable @code not initialized
/private/tmp/phony/lib/phony/trunk_code.rb:23: warning: instance variable @code not initialized
/private/tmp/phony/lib/phony/trunk_code.rb:23: warning: instance variable @code not initialized
/private/tmp/phony/lib/phony/trunk_code.rb:23: warning: instance variable @code not initialized
...../private/tmp/phony/lib/phony/trunk_code.rb:23: warning: instance variable @code not initialized
/private/tmp/phony/lib/phony/trunk_code.rb:23: warning: instance variable @code not initialized
/private/tmp/phony/lib/phony/trunk_code.rb:23: warning: instance variable @code not initialized
/private/tmp/phony/lib/phony/trunk_code.rb:23: warning: instance variable @code not initialized
/private/tmp/phony/lib/phony/trunk_code.rb:23: warning: instance variable @code not initialized
/private/tmp/phony/lib/phony/trunk_code.rb:23: warning: instance variable @code not initialized
/private/tmp/phony/lib/phony/trunk_code.rb:23: warning: instance variable @code not initialized
/private/tmp/phony/lib/phony/trunk_code.rb:23: warning: instance variable @code not initialized
.........................................................................................................................................................../private/tmp/phony/lib/phony/trunk_code.rb:23: warning: instance variable @code not initialized
./private/tmp/phony/lib/phony/trunk_code.rb:23: warning: instance variable @code not initialized
./private/tmp/phony/lib/phony/trunk_code.rb:23: warning: instance variable @code not initialized
./private/tmp/phony/lib/phony/trunk_code.rb:23: warning: instance variable @code not initialized
./private/tmp/phony/lib/phony/trunk_code.rb:23: warning: instance variable @code not initialized
./private/tmp/phony/lib/phony/trunk_code.rb:23: warning: instance variable @code not initialized
./private/tmp/phony/lib/phony/trunk_code.rb:23: warning: instance variable @code not initialized
./private/tmp/phony/lib/phony/trunk_code.rb:23: warning: instance variable @code not initialized
./private/tmp/phony/lib/phony/trunk_code.rb:23: warning: instance variable @code not initialized
./private/tmp/phony/lib/phony/trunk_code.rb:23: warning: instance variable @code not initialized
./private/tmp/phony/lib/phony/trunk_code.rb:23: warning: instance variable @code not initialized
.../private/tmp/phony/lib/phony/trunk_code.rb:23: warning: instance variable @code not initialized
./private/tmp/phony/lib/phony/trunk_code.rb:23: warning: instance variable @code not initialized
................................................................./private/tmp/phony/lib/phony/trunk_code.rb:23: warning: instance variable @code not initialized
./private/tmp/phony/lib/phony/trunk_code.rb:23: warning: instance variable @code not initialized
./private/tmp/phony/lib/phony/trunk_code.rb:23: warning: instance variable @code not initialized
./private/tmp/phony/lib/phony/trunk_code.rb:23: warning: instance variable @code not initialized
./private/tmp/phony/lib/phony/trunk_code.rb:23: warning: instance variable @code not initialized
./private/tmp/phony/lib/phony/trunk_code.rb:23: warning: instance variable @code not initialized
./private/tmp/phony/lib/phony/trunk_code.rb:23: warning: instance variable @code not initialized
./private/tmp/phony/lib/phony/trunk_code.rb:23: warning: instance variable @code not initialized
......./private/tmp/phony/lib/phony/trunk_code.rb:23: warning: instance variable @code not initialized
./private/tmp/phony/lib/phony/trunk_code.rb:23: warning: instance variable @code not initialized
./private/tmp/phony/lib/phony/trunk_code.rb:23: warning: instance variable @code not initialized
........./private/tmp/phony/lib/phony/trunk_code.rb:23: warning: instance variable @code not initialized
./private/tmp/phony/lib/phony/trunk_code.rb:23: warning: instance variable @code not initialized
./private/tmp/phony/lib/phony/trunk_code.rb:23: warning: instance variable @code not initialized
./private/tmp/phony/lib/phony/trunk_code.rb:23: warning: instance variable @code not initialized
./private/tmp/phony/lib/phony/trunk_code.rb:23: warning: instance variable @code not initialized
...................................................................................../private/tmp/phony/lib/phony/trunk_code.rb:23: warning: instance variable @code not initialized
./private/tmp/phony/lib/phony/trunk_code.rb:23: warning: instance variable @code not initialized
./private/tmp/phony/lib/phony/trunk_code.rb:23: warning: instance variable @code not initialized
./private/tmp/phony/lib/phony/trunk_code.rb:23: warning: instance variable @code not initialized
./private/tmp/phony/lib/phony/trunk_code.rb:23: warning: instance variable @code not initialized
./private/tmp/phony/lib/phony/trunk_code.rb:23: warning: instance variable @code not initialized
./private/tmp/phony/lib/phony/trunk_code.rb:23: warning: instance variable @code not initialized
./private/tmp/phony/lib/phony/trunk_code.rb:23: warning: instance variable @code not initialized
............................................................................................./private/tmp/phony/lib/phony/trunk_code.rb:23: warning: instance variable @code not initialized
................................................................./private/tmp/phony/lib/phony/trunk_code.rb:23: warning: instance variable @code not initialized
./private/tmp/phony/lib/phony/trunk_code.rb:23: warning: instance variable @code not initialized
./private/tmp/phony/lib/phony/trunk_code.rb:23: warning: instance variable @code not initialized
................................................................................................................................../private/tmp/phony/lib/phony/trunk_code.rb:23: warning: instance variable @code not initialized
./private/tmp/phony/lib/phony/trunk_code.rb:23: warning: instance variable @code not initialized
./private/tmp/phony/lib/phony/trunk_code.rb:23: warning: instance variable @code not initialized
./private/tmp/phony/lib/phony/trunk_code.rb:23: warning: instance variable @code not initialized
./private/tmp/phony/lib/phony/trunk_code.rb:23: warning: instance variable @code not initialized
./private/tmp/phony/lib/phony/trunk_code.rb:23: warning: instance variable @code not initialized
......./private/tmp/phony/lib/phony/trunk_code.rb:23: warning: instance variable @code not initialized
./private/tmp/phony/lib/phony/trunk_code.rb:23: warning: instance variable @code not initialized
./private/tmp/phony/lib/phony/trunk_code.rb:23: warning: instance variable @code not initialized
./private/tmp/phony/lib/phony/trunk_code.rb:23: warning: instance variable @code not initialized
......................................../private/tmp/phony/lib/phony/trunk_code.rb:23: warning: instance variable @code not initialized
........../private/tmp/phony/lib/phony/trunk_code.rb:23: warning: instance variable @code not initialized
../private/tmp/phony/lib/phony/trunk_code.rb:23: warning: instance variable @code not initialized
................/private/tmp/phony/lib/phony/trunk_code.rb:23: warning: instance variable @code not initialized
......./private/tmp/phony/lib/phony/trunk_code.rb:23: warning: instance variable @code not initialized
......................................................................./private/tmp/phony/lib/phony/trunk_code.rb:23: warning: instance variable @code not initialized
........................../private/tmp/phony/lib/phony/trunk_code.rb:23: warning: instance variable @code not initialized
..../private/tmp/phony/lib/phony/trunk_code.rb:23: warning: instance variable @code not initialized
....../private/tmp/phony/lib/phony/trunk_code.rb:23: warning: instance variable @code not initialized
......./private/tmp/phony/lib/phony/trunk_code.rb:23: warning: instance variable @code not initialized
............./private/tmp/phony/lib/phony/trunk_code.rb:23: warning: instance variable @code not initialized
............../private/tmp/phony/lib/phony/trunk_code.rb:23: warning: instance variable @code not initialized
..../private/tmp/phony/lib/phony/trunk_code.rb:23: warning: instance variable @code not initialized
...........

Finished in 0.46914 seconds
1051 examples, 0 failures
[Coveralls] Outside the Travis environment, not sending data.
```

After:

```shell
Users/cesario/.rubies/ruby-2.1.0/bin/ruby -w -S rspec ./spec/functional/error_spec.rb ./spec/functional/normalize_spec.rb ./spec/functional/plausibility_spec.rb ./spec/lib/phony/countries_spec.rb ./spec/lib/phony/country_codes_spec.rb ./spec/lib/phony/country_spec.rb ./spec/lib/phony/dsl_spec.rb ./spec/lib/phony/local_splitters/fixed_spec.rb ./spec/lib/phony/local_splitters/regex_spec.rb ./spec/lib/phony/national_code_spec.rb ./spec/lib/phony/national_splitters/fixed_spec.rb ./spec/lib/phony/national_splitters/none_spec.rb ./spec/lib/phony/national_splitters/regex_spec.rb ./spec/lib/phony/national_splitters/variable_spec.rb ./spec/lib/phony/vanity_spec.rb ./spec/lib/phony_spec.rb
/Users/cesario/.gem/ruby/2.1.0/gems/rspec-core-2.14.7/lib/rspec/core/ruby_project.rb:27: warning: File.exists? is a deprecated name, use File.exist? instead
/private/tmp/phony/spec/spec_helper.rb:3: warning: assigned but unused variable - e
/Users/cesario/.gem/ruby/2.1.0/gems/rest-client-1.6.7/lib/restclient/exceptions.rb:157: warning: assigned but unused variable - message
/Users/cesario/.gem/ruby/2.1.0/gems/rest-client-1.6.7/lib/restclient/exceptions.rb:167: warning: assigned but unused variable - message
/Users/cesario/.gem/ruby/2.1.0/gems/rest-client-1.6.7/lib/restclient/response.rb:11: warning: method redefined; discarding old body
/Users/cesario/.gem/ruby/2.1.0/gems/rest-client-1.6.7/lib/restclient/payload.rb:47: warning: mismatched indentations at 'end' with 'case' at 40
/Users/cesario/.gem/ruby/2.1.0/gems/docile-1.1.1/lib/docile/fallback_context_proxy.rb:57: warning: assigned but unused variable - e
/Users/cesario/.gem/ruby/2.1.0/gems/simplecov-html-0.8.0/lib/simplecov-html.rb:58: warning: possibly useless use of a variable in void context
[Coveralls] Set up the SimpleCov formatter.
[Coveralls] Using SimpleCov's default settings.
...........................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................

Finished in 0.37272 seconds
1051 examples, 0 failures
[Coveralls] Outside the Travis environment, not sending data.
```

As you can see now, the remaining warnings are not coming from phony anymore.

I have not squashed the commits so that it will be easy to bisect thru them if anything goes wrong in the future. Don't hesitate to ask me if you have any question about the changes I have introduced.

Thanks again for your gem.

Franck