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

Bundler/OrderedGems cop should respect ASCII order when gem name has symbols #3923

Closed
lucascaton opened this issue Jan 17, 2017 · 3 comments · Fixed by #3932
Closed

Bundler/OrderedGems cop should respect ASCII order when gem name has symbols #3923

lucascaton opened this issue Jan 17, 2017 · 3 comments · Fixed by #3932
Labels

Comments

@lucascaton
Copy link

lucascaton commented Jan 17, 2017

Expected behavior

Bundler/OrderedGems cop (PR) should respect ASCII order.

Actual behavior

I have the following gems in my Gemfile:

gem 'paper_trail'
gem 'paperclip'

Vim sorts it this way, which is correct: _ symbol comes before letters in ASCII table. However, this cop complains: Gemfile:27:1: C: Bundler/OrderedGems: Gems should be sorted in an alphabetical order within their section of the Gemfile. Gem paperclip should appear before paper_trail.

Reference:

Steps to reproduce the problem

Add the gems in the same order mentioned in the previous step and run $ rubocop.

RuboCop version

$ rubocop -V
0.47.0 (using Parser 2.3.3.1, running on ruby 2.3.3 x86_64-darwin16)
@mikegee
Copy link
Contributor

mikegee commented Jan 17, 2017

Reverting #3810 would fix this issue. But then we wouldn't have case-insensitive comparisons, which was considered desirable in #3802.

🤔 I suppose a custom comparison algorithm could be written.

@bbatsov
Copy link
Collaborator

bbatsov commented Jan 18, 2017

I suppose a custom comparison algorithm could be written.

Guess so.

@bbatsov bbatsov added the bug label Jan 18, 2017
mikegee added a commit to mikegee/rubocop that referenced this issue Jan 18, 2017
The underscore character is between the uppercase and lowercase
alphabetical characters in ASCII.

Folks expect "_" to come before "a", but `String#casecmp` is implemented
by uppercasing the inputs before comparing them. This leads to "_"
coming after alphabetical characters.
bbatsov pushed a commit that referenced this issue Jan 18, 2017
The underscore character is between the uppercase and lowercase
alphabetical characters in ASCII.

Folks expect "_" to come before "a", but `String#casecmp` is implemented
by uppercasing the inputs before comparing them. This leads to "_"
coming after alphabetical characters.
@lucascaton
Copy link
Author

Thanks @mikegee and @bbatsov!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants