rubocop-rails
rubocop-rails copied to clipboard
Add autocorrection for `Rails/ReflectionClassName`
Before submitting the PR make sure the following are checked:
- [x] Wrote good commit messages.
- [ ] Commit message starts with
[Fix #issue-number](if the related issue exists). - [x] Feature branch is up-to-date with
master(if not - rebase it). - [x] Squashed related commits together.
- [x] Added tests.
- [x] Added an entry to the Changelog if the new code introduces user-observable changes. See changelog entry format.
- [ ] If this is a new cop, consider making a corresponding update to the Rails Style Guide.
- [x] The PR relates to only one subject with a clear title and description in grammatically correct, complete sentences.
- [x] Run
bundle exec rake default. It executes all tests and RuboCop for itself, and generates the documentation.
~~Waiting for #302 to be merged to fix the CI.~~ Fixed
@tejasbubane ping.
@koic Sorry for the delay on this one, I've made the changes to autocorrect only for constants or .name or .to_s.
@tejasbubane Can you rebase with the latest master branch?
@koic Rebased.
Thanks!
Is there an advantage to using this rule or is this just a stylistic choice? The advantage I can see to using reflection is that if a class name changes and your relation relies on it, it will be obvious very quickly as your app will fail to start if you have failed to update references to the underlying class.
It will fail both ways, won’t it? I guess to save on cascade class autoloading.
Ah I see. If there's a circular dependency.
Thanks.