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 InternalAffairs/ExampleHeredocDelimiter cop #11094

Merged
merged 1 commit into from Oct 22, 2022

Conversation

r7kamura
Copy link
Contributor

@r7kamura r7kamura commented Oct 21, 2022

In response to the following review comment, I have created a cop to consistently use RUBY delimiter for heredocs in cop tests.

cc: @koic


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.

@r7kamura r7kamura force-pushed the feature/example-heredoc-delimiter branch from 327b2cb to 4709e85 Compare October 21, 2022 02:21
#
# @safety
# This cop is unsafe because the heredoc body may also contain a `RUBY` line,
# in which case this word cannot be used for the delimiter.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this is detectable, it should be able to be made safe. Can you add tests and adjust the implementation? An approach could be that this case is only detected and not auto-corrected.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's right. Looking at some existing codes, there are cases where we really want to use a RUBY line in heredoc body, so I decided not to make such a case an offense.

@r7kamura r7kamura force-pushed the feature/example-heredoc-delimiter branch from 4709e85 to 7502a9e Compare October 21, 2022 02:48
@r7kamura r7kamura requested a review from koic October 21, 2022 02:52
@koic
Copy link
Member

koic commented Oct 22, 2022

Note: I'm going to merge this new InternalAffairs cop because the internal cop is not for general users. So, even if the next release is a bugfix release, it can be merged I think.

@koic koic merged commit 339d50d into rubocop:master Oct 22, 2022
@koic
Copy link
Member

koic commented Oct 22, 2022

Thanks!

@r7kamura r7kamura deleted the feature/example-heredoc-delimiter branch October 22, 2022 20:35
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.

None yet

2 participants