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

[#3600] Add new `Bundler/OrderedGems` cop #3657

Merged
merged 1 commit into from Nov 22, 2016

Conversation

Projects
None yet
3 participants
@tdeo
Contributor

tdeo commented Oct 20, 2016

Implementing some part of #3600.

Actually, I couldn't a good wording for the "groups" of gems as groups are a specific Gemfile notion already


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).

This Cop checks that all gem entries belonging in consecutive lines in
the Gemfile appear in alphabetically sorted order.

@tdeo

This comment has been minimized.

Show comment
Hide comment
@tdeo

tdeo Oct 20, 2016

Contributor

I actually couldn't figure out how to run rubocop on the code. Could someone explain that?

Actually found it.

Contributor

tdeo commented Oct 20, 2016

I actually couldn't figure out how to run rubocop on the code. Could someone explain that?

Actually found it.

@tdeo

This comment has been minimized.

Show comment
Hide comment
@tdeo

tdeo Oct 26, 2016

Contributor

Ping @bbatsov

Contributor

tdeo commented Oct 26, 2016

Ping @bbatsov

@mikegee

This comment has been minimized.

Show comment
Hide comment
@mikegee

mikegee Oct 26, 2016

Contributor

I don't see the part that makes this only look at the Gemfile. Multiple calls to a gem method elsewhere would be weird, but still.

Contributor

mikegee commented Oct 26, 2016

I don't see the part that makes this only look at the Gemfile. Multiple calls to a gem method elsewhere would be weird, but still.

Show outdated Hide outdated config/enabled.yml
@@ -581,6 +581,12 @@ Style/OptionalArguments:
StyleGuide: '#optional-arguments'
Enabled: true
Style/OrderedGems:

This comment has been minimized.

@bbatsov

bbatsov Oct 26, 2016

Collaborator

We need some new cop group - e.g. Gemfile or Bundler.

@bbatsov

bbatsov Oct 26, 2016

Collaborator

We need some new cop group - e.g. Gemfile or Bundler.

@bbatsov

This comment has been minimized.

Show comment
Hide comment
@bbatsov

bbatsov Oct 26, 2016

Collaborator

The files the cop operates on should just be listed in the default config under -Include.

Collaborator

bbatsov commented Oct 26, 2016

The files the cop operates on should just be listed in the default config under -Include.

@bbatsov

This comment has been minimized.

Show comment
Hide comment
@bbatsov

bbatsov Oct 30, 2016

Collaborator

See #3638 for reference.

Collaborator

bbatsov commented Oct 30, 2016

See #3638 for reference.

@tdeo

This comment has been minimized.

Show comment
Hide comment
@tdeo

tdeo Nov 1, 2016

Contributor

@bbatsov Just made the changes and rebased onto master. What should I do about the extra doc that doesn't relate to this cop?

Contributor

tdeo commented Nov 1, 2016

@bbatsov Just made the changes and rebased onto master. What should I do about the extra doc that doesn't relate to this cop?

Show outdated Hide outdated CHANGELOG.md
@@ -17,6 +17,7 @@
* [#3570](https://github.com/bbatsov/rubocop/issues/3570): Add new `MultilineIfModifier` cop to avoid usage of if/unless-modifiers on multiline statements. ([@tessi][])
* [#3631](https://github.com/bbatsov/rubocop/issues/3631): Add new `Style/SpaceInLambdaLiteral` cop to check for spaces in lambda literals. ([@swcraig][])
* Add new `Lint/EmptyExpression` cop. ([@drenmi][])
* [#3600](https://github.com/bbatsov/rubocop/issues/3600): Add new `Style/OrderedGems` cop. ([@tdeo][])

This comment has been minimized.

@bbatsov

bbatsov Nov 1, 2016

Collaborator

This should be moved to the proper section of the changelog (we did a gem release recently). Also style should be replaced with Bundler.

@bbatsov

bbatsov Nov 1, 2016

Collaborator

This should be moved to the proper section of the changelog (we did a gem release recently). Also style should be replaced with Bundler.

@bbatsov

This comment has been minimized.

Show comment
Hide comment
@bbatsov

bbatsov Nov 1, 2016

Collaborator

What should I do about the extra doc that doesn't relate to this cop?

Rebase on top of the current master and add those to a separate commit.

Collaborator

bbatsov commented Nov 1, 2016

What should I do about the extra doc that doesn't relate to this cop?

Rebase on top of the current master and add those to a separate commit.

@tdeo tdeo changed the title from [Fix #3600] Add new `Style/OrderedGems` cop to [#3600] Add new `Bundler/OrderedGems` cop Nov 1, 2016

@tdeo

This comment has been minimized.

Show comment
Hide comment
@tdeo

tdeo Nov 8, 2016

Contributor

@bbatsov I just rebased that on master again

Contributor

tdeo commented Nov 8, 2016

@bbatsov I just rebased that on master again

@bbatsov

This comment has been minimized.

Show comment
Hide comment
@bbatsov

bbatsov Nov 21, 2016

Collaborator

The doc is out-of-sync. Now we finally check for this automatically. Drop the second commit and rebase one more time. Sorry about this.

Collaborator

bbatsov commented Nov 21, 2016

The doc is out-of-sync. Now we finally check for this automatically. Drop the second commit and rebase one more time. Sorry about this.

@tdeo

This comment has been minimized.

Show comment
Hide comment
@tdeo

tdeo Nov 22, 2016

Contributor

@bbatsov Just droped the extra documentation changes.

Contributor

tdeo commented Nov 22, 2016

@bbatsov Just droped the extra documentation changes.

@bbatsov bbatsov merged commit bfa08d8 into rubocop-hq:master Nov 22, 2016

1 check passed

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

@tdeo tdeo deleted the tdeo:sort_gems_in_gemfile branch Nov 22, 2016

pocke added a commit to pocke/rubocop that referenced this pull request Dec 1, 2016

Add Auto-Correct for `Bundler/OrderedGems` cop
See also #3657 #3600

Goal
----

Auto Correct not sorted gems.

e.g.

```ruby
gem 'b'
gem 'd'
gem 'c'
gem 'a'

gem 'a'
gem 'b'
gem 'c'
gem 'd'
```

Note
-----

I added `autocorrect_source_with_loop` test helper method to execute auto-correction with loop.
This method is based on do_inspection_loop.
https://github.com/bbatsov/rubocop/blob/ed4aeb845bfcaaff0648d365c5b46a2e725347f7/lib/rubocop/runner.rb#L179-L202

pocke added a commit to pocke/rubocop that referenced this pull request Dec 1, 2016

Add Auto-Correct for `Bundler/OrderedGems` cop
See also #3657 #3600

Goal
----

Auto Correct not sorted gems.

e.g.

```ruby
gem 'b'
gem 'd'
gem 'c'
gem 'a'

gem 'a'
gem 'b'
gem 'c'
gem 'd'
```

Note
-----

I added `autocorrect_source_with_loop` test helper method to execute auto-correction with loop.
This method is based on do_inspection_loop.
https://github.com/bbatsov/rubocop/blob/ed4aeb845bfcaaff0648d365c5b46a2e725347f7/lib/rubocop/runner.rb#L179-L202

@pocke pocke referenced this pull request Dec 1, 2016

Merged

Add Auto-Correct for `Bundler/OrderedGems` cop #3757

9 of 11 tasks complete

pocke added a commit to pocke/rubocop that referenced this pull request Dec 1, 2016

Add Auto-Correct for `Bundler/OrderedGems` cop
See also #3657 #3600

Goal
----

Auto Correct not sorted gems.

e.g.

```ruby
gem 'b'
gem 'd'
gem 'c'
gem 'a'

gem 'a'
gem 'b'
gem 'c'
gem 'd'
```

Note
-----

I added `autocorrect_source_with_loop` test helper method to execute auto-correction with loop.
This method is based on do_inspection_loop.
https://github.com/bbatsov/rubocop/blob/ed4aeb845bfcaaff0648d365c5b46a2e725347f7/lib/rubocop/runner.rb#L179-L202

pocke added a commit to pocke/rubocop that referenced this pull request Dec 1, 2016

Add Auto-Correct for `Bundler/OrderedGems` cop
See also #3657 #3600

Goal
----

Auto Correct not sorted gems.

e.g.

```ruby
gem 'b'
gem 'd'
gem 'c'
gem 'a'

gem 'a'
gem 'b'
gem 'c'
gem 'd'
```

Note
-----

I added `autocorrect_source_with_loop` test helper method to execute auto-correction with loop.
This method is based on do_inspection_loop.
https://github.com/bbatsov/rubocop/blob/ed4aeb845bfcaaff0648d365c5b46a2e725347f7/lib/rubocop/runner.rb#L179-L202

bbatsov added a commit that referenced this pull request Dec 1, 2016

Add Auto-Correct for `Bundler/OrderedGems` cop
See also #3657 #3600

Goal
----

Auto Correct not sorted gems.

e.g.

```ruby
gem 'b'
gem 'd'
gem 'c'
gem 'a'

gem 'a'
gem 'b'
gem 'c'
gem 'd'
```

Note
-----

I added `autocorrect_source_with_loop` test helper method to execute auto-correction with loop.
This method is based on do_inspection_loop.
https://github.com/bbatsov/rubocop/blob/ed4aeb845bfcaaff0648d365c5b46a2e725347f7/lib/rubocop/runner.rb#L179-L202
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment