Trying to update the gem to 2.2.0 and we get a lot of deprecation warnings from inside the gem:
/.../vendor/bundle/ruby/2.6.0/gems/faker-2.2.0/lib/helpers/unique_generator.rb:22: Passing `number` with the 1st argument of `Lorem.words` is deprecated. Use keyword argument like `Lorem.words(number: ...)` instead.
We've spend a significant amount of time trying to fix all these warnings, which also translated to errors in some places (which is highly unsual for a minor gem update). Now we're seeing warnings coming from the gem itself. I would recommend being a bit more careful when releasing changes like these, since they affect quite a big number of apps, which may or may not have the time to spend on something less then non-critical 馃槉
@koic
@linkyndy which version were you using before? < 2?
We had 1.9.3.
We knew that switching from positional parameters to keywords parameters would be painful, but we believed that keyword parameters would help us by providing self documentation.
We also changed the Faker::Number generator and made it start returning integer instead of string.
Thanks for raising this issue. We've received other pieces of feedback, we consider all of them and are always happy to discuss and evolve Faker together 馃憤
FYI, I created RuboCop Faker gem.
https://github.com/koic/rubocop-faker
The following command can be used to check and auto-correct the Faker 2 argument style.
Check positional argument style before Faker 2.
% rubocop --require rubocop-faker --only Faker/DeprecatedArguments
Auto-correction to keyword argument style on Faker 2.
% rubocop --require rubocop-faker --only Faker/DeprecatedArguments --auto-correct
This is the approach that factory_bot used to change APIs. The migration command was displayed with a deprecation warning at runtime.
https://github.com/thoughtbot/factory_bot/commit/dabacdace6ccde067438a72b3336769c052fb621
Dear @koic , dear @vbrazo
I am having the same problem and it comes from a file within _Faker_, not in my own code. Not much I can do to fix it in my project.
/Users/adeynack/.rvm/gems/ruby-2.6.5/gems/faker-2.10.1/lib/helpers/unique_generator.rb:22: Passing `number` with the 1st argument of `sentences` is deprecated. Use keyword argument like `sentences(number: ...)` instead.
To automatically update from positional arguments to keyword arguments,
install rubocop-faker and run:
rubocop \
--require rubocop-faker \
--only Faker/DeprecatedArguments \
--auto-correct