Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Add new Rails/ToFormattedS cop #691

Merged
merged 1 commit into from
Jun 5, 2022

Conversation

koic
Copy link
Member

@koic koic commented Apr 19, 2022

Follow up rubocop/rails-style-guide#314.

This cop checks for consistent uses of to_fs or to_formatted_s, depending on the cop's configuration.

EnforcedStyle: to_fs (default)

# bad
time.to_formatted_s(:db)

# good
time.to_fs(:db)

EnforcedStyle: to_formatted_s

# bad
time.to_fs(:db)

# good
time.to_formatted_s(:db)

Before submitting the PR make sure the following are checked:

  • The PR relates to only one subject with a clear title and description in grammatically correct, complete sentences.
  • Wrote good commit messages.
  • Commit message starts with [Fix #issue-number] (if the related issue exists).
  • Feature branch is up-to-date with master (if not - rebase it).
  • Squashed related commits together.
  • Added tests.
  • Ran bundle exec rake default. It executes all tests and runs RuboCop on its own code.
  • Added an entry (file) to the changelog folder named {change_type}_{change_description}.md if the new code introduces user-observable changes. See changelog entry format for details.
  • The PR relates to only one subject with a clear title
    and description in grammatically correct, complete sentences.
  • If this is a new cop, consider making a corresponding update to the Rails Style Guide.

@koic koic force-pushed the add_new_rails_to_formatted_s_cop branch 2 times, most recently from e065014 to 18001cf Compare April 19, 2022 06:54
@andyw8
Copy link
Contributor

andyw8 commented Apr 19, 2022

Should this check the version of Rails in use and skip if < 7 ?

@koic koic force-pushed the add_new_rails_to_formatted_s_cop branch from 18001cf to b840311 Compare April 20, 2022 01:46
@koic
Copy link
Member Author

koic commented Apr 20, 2022

I forgot the minimum_target_rails_version. I've updated this PR. Thank you!

@koic koic force-pushed the add_new_rails_to_formatted_s_cop branch from b840311 to e50963b Compare April 20, 2022 01:54
Follow up rubocop/rails-style-guide#314.

This cop checks for consistent uses of `to_fs` or `to_formatted_s`,
depending on the cop's configuration.

## EnforcedStyle: to_fs (default)

```ruby
# bad
time.to_formatted_s(:db)

# good
time.to_fs(:db)
```

## EnforcedStyle: to_formatted_s

```
# bad
time.to_fs(:db)

# good
time.to_formatted_s(:db)
```
@koic koic force-pushed the add_new_rails_to_formatted_s_cop branch from e50963b to 3591a57 Compare April 21, 2022 03:34
@koic koic merged commit 86271f3 into rubocop:master Jun 5, 2022
@koic koic deleted the add_new_rails_to_formatted_s_cop branch June 5, 2022 07:31
@koic koic mentioned this pull request Jul 20, 2022
9 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants