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 #3646] Add new `Lint/EmptyWhen` cop #3651

Merged
merged 1 commit into from Oct 19, 2016

Conversation

Projects
None yet
3 participants
@Drenmi
Collaborator

Drenmi commented Oct 19, 2016

This cop checks for when branches with empty bodies, e.g.:

case foo
when :bar then 1
when :baz # nothing
end

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).
  • Used the same coding conventions as the rest of the project.
  • 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.
  • All tests are passing.
  • The new code doesn't generate RuboCop offenses.
  • The PR relates to only one subject with a clear title
    and description in grammatically correct, complete sentences.
  • Updated cop documentation with rake generate_cops_documentation (required only when you've added a new cop or changed the configuration/documentation of an existing cop).
@bbatsov

This comment has been minimized.

Show comment
Hide comment
@bbatsov

bbatsov Oct 19, 2016

Collaborator

I don't see any documentation update. Did you run the rake task?

Collaborator

bbatsov commented Oct 19, 2016

I don't see any documentation update. Did you run the rake task?

[Fix #3646] Add new `Lint/EmptyWhen` cop
This cop checks for `when` branches with empty bodies, e.g.:

```
case foo
when :bar then 1
when :baz #nothing
end
```
@Drenmi

This comment has been minimized.

Show comment
Hide comment
@Drenmi

Drenmi Oct 19, 2016

Collaborator

@bbatsov: I did. I also missed that it failed. 😅 Fixed!

It also added some missing updates from #3601, but I didn't include them here. I can open a new PR for it if needed:

--- a/manual/cops_style.md
+++ b/manual/cops_style.md
@@ -3797,7 +3797,7 @@ parameters.

 Attribute | Value
 --- | ---
-Methods | {"reduce"=>["a", "e"]}, {"inject"=>["a", "e"]}
+Methods | {"reduce"=>["acc", "elem"]}, {"inject"=>["acc", "elem"]}
Collaborator

Drenmi commented Oct 19, 2016

@bbatsov: I did. I also missed that it failed. 😅 Fixed!

It also added some missing updates from #3601, but I didn't include them here. I can open a new PR for it if needed:

--- a/manual/cops_style.md
+++ b/manual/cops_style.md
@@ -3797,7 +3797,7 @@ parameters.

 Attribute | Value
 --- | ---
-Methods | {"reduce"=>["a", "e"]}, {"inject"=>["a", "e"]}
+Methods | {"reduce"=>["acc", "elem"]}, {"inject"=>["acc", "elem"]}
@backus

This comment has been minimized.

Show comment
Hide comment
@backus

backus Oct 19, 2016

Contributor

I could do a PR for this later but I'm just commenting quickly now as I chew through this morning's github notifications:

You guys should consider adding a build step on ci like this:

# Generate documentation without invoking yardoc
yes n | bundle exec rake generate_cops_documentation

# Assert that documentation is in sync
git diff --exit-code manual/

I do some similar doc generation for rubocop-rspec and use this to make sure I don't forget to sync up the files: https://github.com/backus/rubocop-rspec/blob/master/Rakefile#L35-L43

Contributor

backus commented Oct 19, 2016

I could do a PR for this later but I'm just commenting quickly now as I chew through this morning's github notifications:

You guys should consider adding a build step on ci like this:

# Generate documentation without invoking yardoc
yes n | bundle exec rake generate_cops_documentation

# Assert that documentation is in sync
git diff --exit-code manual/

I do some similar doc generation for rubocop-rspec and use this to make sure I don't forget to sync up the files: https://github.com/backus/rubocop-rspec/blob/master/Rakefile#L35-L43

@bbatsov bbatsov merged commit 72be0f7 into rubocop-hq:master Oct 19, 2016

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details

@Drenmi Drenmi deleted the Drenmi:feature/empty-when-cop branch Dec 29, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment