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 expect_offense mark for offense on empty line #8255

Merged

Conversation

biinari
Copy link
Contributor

@biinari biinari commented Jul 7, 2020

Part of #8003

Use ^{} to denote an offense at an empty line in expect_offense. This format was suggested by @marcandre in Issue 8003 comment. I think it has the advantage of familiarity with existing ^ and ^{name} syntax.

Example:

expect_offense(<<~RUBY)

  ^{} Missing frozen string literal comment.
  puts 1
RUBY

I have enabled pending frozen string literal specs as coverage for this change.

Also corrected which line the offense is added to in the frozen string literal
specs (always the first line). As the first line is non-empty in some of these
cases, a normal caret ^ is used to mark the offense.


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.

Part of rubocop#8003

Use `^{}` to denote an offense at an empty line in `expect_offense`.

Example:

```ruby
expect_offense(<<~RUBY)

  ^{} Missing frozen string literal comment.
  puts 1
RUBY
```

Enable pending frozen string literal specs

Correct which line the offense is added to (always the first line).

As the first line is non-empty in these cases, use a normal caret `^` to
mark the offense.
@bbatsov bbatsov merged commit 05feb76 into rubocop:master Jul 7, 2020
@bbatsov
Copy link
Collaborator

bbatsov commented Jul 7, 2020

I like this! Thanks!

@biinari biinari mentioned this pull request Jul 10, 2020
@biinari biinari deleted the feature/expect_offense_empty_marker branch August 7, 2020 21:44
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