Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Include rubocop-faker autocorrect in deprecation #1724

Conversation

koic
Copy link
Member

@koic koic commented Sep 4, 2019

Follow up #1714.

This is a proposal to make it easy to convert positional arguments to keyword arguments.

This approach is based on the experience that factory_bot has provided for upgrades.

First, I prepared rubocop-faker gem for upgrading with auto-correction.
https://github.com/koic/rubocop-faker

This PR includes rubocop-faker autocorrect in deprecation.
The following is an example.

% cat example.rb
require 'faker'

Faker::Lorem.words(10000, true)

Before

% bundle exec ruby example.rb
example.rb:3: Passing `number` with the 1st argument of `Lorem.words` is
deprecated. Use keyword argument like `Lorem.words(number: ...)`
instead.
example.rb:3: Passing `supplemental` with the 2nd argument of
`Lorem.words` is deprecated. Use keyword argument like
`Lorem.words(supplemental: ...)` instead.

After

% bundle exec ruby example.rb
example.rb:3: Passing `number` with the 1st argument of `words` is
deprecated. Use keyword argument like `words(number: ...)` instead.
example.rb:3: Passing `supplemental` with the 2nd argument of `words` is
deprecated. Use keyword argument like `words(supplemental: ...)`
instead.

To automatically update from positional arguments to keyword arguments,
install rubocop-faker and run:

rubocop \
  --require rubocop-faker \
  --only Faker/DeprecatedArguments \
  --auto-correct

Basically, users can update by copying and pasting the command displayed in the warning, so the upgrade is easy.

I'm not sure if a dependency on 3rd party gem will be accepted.
Can you please kindly consider it?

Follow up faker-ruby#1714.

This is a proposal to make it easy to convert positional arguments to
keyword arguments.

This approach is based on the experience that factory_bot has provided
for upgrades.

- thoughtbot/factory_bot@dabacda
- thoughtbot/factory_bot#1135

First, I prepared rubocop-faker gem for upgrading with auto-correction.
https://github.com/koic/rubocop-faker

This PR includes rubocop-faker autocorrect in deprecation.
The following is an example.

```console
% cat example.rb
require 'faker'

Faker::Lorem.words(10000, true)
```

## Before

```console
% bundle exec ruby example.rb
example.rb:3: Passing `number` with the 1st argument of `Lorem.words` is
deprecated. Use keyword argument like `Lorem.words(number: ...)`
instead.
example.rb:3: Passing `supplemental` with the 2nd argument of
`Lorem.words` is deprecated. Use keyword argument like
`Lorem.words(supplemental: ...)` instead.
```

## After

```console
% bundle exec ruby example.rb
example.rb:3: Passing `number` with the 1st argument of `words` is
deprecated. Use keyword argument like `words(number: ...)` instead.
example.rb:3: Passing `supplemental` with the 2nd argument of `words` is
deprecated. Use keyword argument like `words(supplemental: ...)`
instead.

To automatically update from positional arguments to keyword arguments,
install rubocop-faker and run:

rubocop \
  --require rubocop-faker \
  --only Faker/DeprecatedArguments \
  --auto-correct
```

Basically, users can update by copying and pasting the command displayed
in the warning, so the upgrade is easy.
@koic koic force-pushed the include_rubocop_faker_autocorrect_in_deprecation branch from 8e84063 to 1f7ff9c Compare September 4, 2019 05:17
@vbrazo vbrazo merged commit 5c6f38f into faker-ruby:master Sep 6, 2019
@koic koic deleted the include_rubocop_faker_autocorrect_in_deprecation branch September 6, 2019 02:53
michebble pushed a commit to michebble/faker that referenced this pull request Feb 16, 2020
Follow up faker-ruby#1714.

This is a proposal to make it easy to convert positional arguments to
keyword arguments.

This approach is based on the experience that factory_bot has provided
for upgrades.

- thoughtbot/factory_bot@dabacda
- thoughtbot/factory_bot#1135

First, I prepared rubocop-faker gem for upgrading with auto-correction.
https://github.com/koic/rubocop-faker

This PR includes rubocop-faker autocorrect in deprecation.
The following is an example.

```console
% cat example.rb
require 'faker'

Faker::Lorem.words(10000, true)
```

## Before

```console
% bundle exec ruby example.rb
example.rb:3: Passing `number` with the 1st argument of `Lorem.words` is
deprecated. Use keyword argument like `Lorem.words(number: ...)`
instead.
example.rb:3: Passing `supplemental` with the 2nd argument of
`Lorem.words` is deprecated. Use keyword argument like
`Lorem.words(supplemental: ...)` instead.
```

## After

```console
% bundle exec ruby example.rb
example.rb:3: Passing `number` with the 1st argument of `words` is
deprecated. Use keyword argument like `words(number: ...)` instead.
example.rb:3: Passing `supplemental` with the 2nd argument of `words` is
deprecated. Use keyword argument like `words(supplemental: ...)`
instead.

To automatically update from positional arguments to keyword arguments,
install rubocop-faker and run:

rubocop \
  --require rubocop-faker \
  --only Faker/DeprecatedArguments \
  --auto-correct
```

Basically, users can update by copying and pasting the command displayed
in the warning, so the upgrade is easy.
davidmorton0 pushed a commit to davidmorton0/faker that referenced this pull request Jul 12, 2021
Follow up faker-ruby#1714.

This is a proposal to make it easy to convert positional arguments to
keyword arguments.

This approach is based on the experience that factory_bot has provided
for upgrades.

- thoughtbot/factory_bot@dabacda
- thoughtbot/factory_bot#1135

First, I prepared rubocop-faker gem for upgrading with auto-correction.
https://github.com/koic/rubocop-faker

This PR includes rubocop-faker autocorrect in deprecation.
The following is an example.

```console
% cat example.rb
require 'faker'

Faker::Lorem.words(10000, true)
```

## Before

```console
% bundle exec ruby example.rb
example.rb:3: Passing `number` with the 1st argument of `Lorem.words` is
deprecated. Use keyword argument like `Lorem.words(number: ...)`
instead.
example.rb:3: Passing `supplemental` with the 2nd argument of
`Lorem.words` is deprecated. Use keyword argument like
`Lorem.words(supplemental: ...)` instead.
```

## After

```console
% bundle exec ruby example.rb
example.rb:3: Passing `number` with the 1st argument of `words` is
deprecated. Use keyword argument like `words(number: ...)` instead.
example.rb:3: Passing `supplemental` with the 2nd argument of `words` is
deprecated. Use keyword argument like `words(supplemental: ...)`
instead.

To automatically update from positional arguments to keyword arguments,
install rubocop-faker and run:

rubocop \
  --require rubocop-faker \
  --only Faker/DeprecatedArguments \
  --auto-correct
```

Basically, users can update by copying and pasting the command displayed
in the warning, so the upgrade is easy.
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants