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 Support for classes defined with compact style #364

Merged
merged 1 commit into from
Sep 30, 2020

Conversation

sinsoku
Copy link
Contributor

@sinsoku sinsoku commented Sep 30, 2020

There is a problem that Rails/UniqueValidationWithoutIndex doesn't work
because it can't find the table name in the class defined with compact style.

This commit adds test code to ensure existing behavior and adds support for
classes defined with compact style.


Before submitting the PR make sure the following are checked:

  • 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.
  • Added an entry to the Changelog if the new code introduces user-observable changes. See changelog entry format.
  • The PR relates to only one subject with a clear title
    and description in grammatically correct, complete sentences.
  • Run bundle exec rake default. It executes all tests and RuboCop for itself, and generates the documentation.
  • If this is a new cop, consider making a corresponding update to the Rails Style Guide.

@koic
Copy link
Member

koic commented Sep 30, 2020

Can you rebase with the latest master branch and add a reproduction test case to spec/rubocop/cop/rails/unique_validation_without_index_spec.rb?

@sinsoku sinsoku force-pushed the support_table_name_for_compact_style branch from f91e01f to 26224e5 Compare September 30, 2020 08:06
@sinsoku
Copy link
Contributor Author

sinsoku commented Sep 30, 2020

I rebased and force-pushed.

The test case of "when the class is defined with compact style" is the reproduction test case.
Should I split a commit?

@koic
Copy link
Member

koic commented Sep 30, 2020

I think it's happening the user level issue at Rails/UniqueValidationWithoutIndex cop. spec/rubocop/cop/active_record_helper_spec.rb has written for ActiveRecordHelper internal API test case.
I'm hoping that a test for Rails/UniqueValidationWithoutIndex cop will be added to spec/rubocop/cop/rails/unique_validation_without_index_spec.rb.

There is a problem that `Rails/UniqueValidationWithoutIndex` doesn't work
because it can't find the table name in the class defined with compact style.

This commit adds test code to ensure existing behavior and adds support for
classes defined with compact style.
@sinsoku sinsoku force-pushed the support_table_name_for_compact_style branch from 26224e5 to 8e4a8a9 Compare September 30, 2020 09:41
@sinsoku
Copy link
Contributor Author

sinsoku commented Sep 30, 2020

Thanks for your review comment.
I understood.

I added a test case for Rails/UniqueValidationWithoutIndex and force-pushed it.

@koic koic merged commit 6c9b6e9 into rubocop:master Sep 30, 2020
@koic
Copy link
Member

koic commented Sep 30, 2020

Nice 👍 Great thanks!

@sinsoku sinsoku deleted the support_table_name_for_compact_style branch September 30, 2020 11:49
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