Skip to content

Rubocop Fixes #1126

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

Merged
merged 9 commits into from
Mar 27, 2018
Merged

Rubocop Fixes #1126

merged 9 commits into from
Mar 27, 2018

Conversation

dks17
Copy link
Contributor

@dks17 dks17 commented Mar 25, 2018

#1124
Folows the #1125
Fixes:

@dks17 dks17 changed the title Rubocop Fix Style/ZeroLengthPredicate Rubocop Fixes Mar 25, 2018
@Evan-M
Copy link
Collaborator

Evan-M commented Mar 26, 2018

@dks17: Thanks for this!

Unfortunately, I had to rebase my branch against the latest HEAD of master, and I did a --force push! (Probably should not have done that, since others have access to this branch repo). I think in doing so, I've introduced some of these conflicts?

I've got a backup branch locally from before I did my rebase, so I'll try doing a force push of that back to the add_rubocop branch, to restore the previous state.

UPDATE: I manually resolved my conflicts (which were totally a result of failing to rebase against master/HEAD prior to pushing the branch). My merge conflict resolution on #1125 seems to have introduced the same merge conflict here on #1126. @dks17: Let me know if you need help resolving this...

This is the code from master/HEAD to use (merged from #1115):

def clean_old_tokens
if tokens.present? && max_client_tokens_exceeded?
# Using Enumerable#sort_by on a Hash will typecast it into an associative
# Array (i.e. an Array of key-value Array pairs). However, since Hashes
# have an internal order in Ruby 1.9+, the resulting sorted associative
# Array can be converted back into a Hash, while maintaining the sorted
# order.
self.tokens = tokens.sort_by { |_cid, v| v[:expiry] || v['expiry'] }.to_h
# Since the tokens are sorted by expiry, shift the oldest client token
# off the Hash until it no longer exceeds the maximum number of clients
tokens.shift while max_client_tokens_exceeded?
end

You may need to manually apply some of the fixes from the Cops you already fixed when resolving. E.g. the Layout/SpaceInsideHashLiteralBraces cop on line 267:

self.tokens = tokens.sort_by { |_cid, v| v[:expiry] || v['expiry'] }.to_h

@Evan-M
Copy link
Collaborator

Evan-M commented Mar 26, 2018

@dks17, could you update either the .rubocop_todo.yml and/or the .rubocop.yml for each cop that you resolved?

The .rubocop_todo.yml (created via rubocop --auto-gen-config --exclude-limit 35) excludes files with offenses for each cop violation. Moreover, since all the cops listed are already enabled by default, you will most likely only need to remove the entire declaration for the resolved/fixed cop from the .rubocop_todo.yml. If you specified / or changed any of the default options for a given cop, then you must also create an entry for that cop in the .rubocop.yml file. I hope this makes sense.

Once the conflicts are resolved, I can merge this onto the add_rubocop branch. (The entire add_rubocop branch and PR #1125 can be reviewed more thoroughly once the cops all pass)

@dks17
Copy link
Contributor Author

dks17 commented Mar 27, 2018

@Evan-M, I encountered only one conflict. It is OK now. I hope I did all properly.

@Evan-M
Copy link
Collaborator

Evan-M commented Mar 27, 2018

I was actually thinking that instead of re-running the auto-gen, you would just manually remove the specific cops from the .rubocop_todo.yml. However, it is curious to me that when you ran rubocop --auto-gen-config --exclude-limit 35 the resulting .rubocop_todo.yml file re-enabled some of the cops that I'd fixed already...

If everyone's run of rubocop is non-deterministic, then this doesn't all quite work right?

What version of ruby are you running rubocop on? I'm using 2.4.2p198 on MacOS 10.13.3 (High Sierra).

I hope I did all properly.

Hey, no worries! We're figuring this out as we go, right? ¯\_(ツ)_/¯

@Evan-M
Copy link
Collaborator

Evan-M commented Mar 27, 2018

@dks17 I'm going to go ahead and merge this into PR #1125.

We'll figure out the specific cop settings afterwards.

@Evan-M Evan-M merged commit 608dcc3 into lynndylanhurley:add_rubocop Mar 27, 2018
@Evan-M Evan-M mentioned this pull request Mar 27, 2018
@dks17
Copy link
Contributor Author

dks17 commented Mar 28, 2018

What version of ruby are you running rubocop on? I'm using 2.4.2p198 on MacOS 10.13.3 (High Sierra).

@Evan-M, I am using ruby 2.5.0p0 (2017-12-25 revision 61468). I think that is not matter in this case.

@dks17 dks17 deleted the add_rubocop branch May 2, 2018 14:20
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.

2 participants