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

[Fix-7777-7776]: Generate valid code if comment exists before closing brace #8237

Conversation

shekhar-patil
Copy link
Contributor

closes #7777 and #7776


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.

@bbatsov bbatsov requested review from Drenmi and jonas054 July 7, 2020 16:34
Copy link
Collaborator

@jonas054 jonas054 left a comment

Choose a reason for hiding this comment

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

Just one comment from me. Looks good otherwise!

)

corrector.remove(range)
Copy link
Collaborator

@jonas054 jonas054 Jul 9, 2020

Choose a reason for hiding this comment

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

If I remove this line, all tests still pass. I suspect that this is because the call to remove is not needed, rather than being related to poor test coverage. But I don't see why it's not needed. 😕

Anyway, it's better if the method only selects a certain source range, like its name says, and not does anything else (single responsibility principle).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jonas054 , Thanks for reviewing, Yes, The mentioned line is needed. I wrote the wrong test case which I have corrected now. Please review now.

@shekhar-patil shekhar-patil force-pushed the Fix-7777-7776-Generate-valid-code-for-comment-exists-before-closing-brace branch from 1d0916c to 49b78e1 Compare July 9, 2020 07:57
@shekhar-patil shekhar-patil force-pushed the Fix-7777-7776-Generate-valid-code-for-comment-exists-before-closing-brace branch from 49b78e1 to 6021b51 Compare July 9, 2020 08:27
@bbatsov bbatsov merged commit 9a2cbf4 into rubocop:master Jul 9, 2020
@bbatsov
Copy link
Collaborator

bbatsov commented Jul 9, 2020

Thanks!

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.

Rubocop places commas into comments, generating invalid ruby code
3 participants