-
Notifications
You must be signed in to change notification settings - Fork 322
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
RuboCop upgrade #548
RuboCop upgrade #548
Conversation
In an attempt to do some house keeping this pushed the rubocop version up by ten and fixes everything that is correctable from an auto-fix standpoint. These changes should be safe if we assume that rubocop's auto-fix changes are safe.
This black hole method should not call up to super. That is the purpose of a black hole object.
Do not take the Unfreeze string cop because it is only supported in Ruby 2.3 and above.
This came up in Style::EvalWithLocation. It makes backtraces easier to follow.
127cdc8
to
4a05be6
Compare
Thanks for the pointer @mikegee, I've made the recommended changes. |
Awesome! I didn't comment on |
4a05be6
to
338aebf
Compare
Rubocop now requires that cops are scoped tighter. This reformats it so that only the specific method or class has the cop disabled.
338aebf
to
4ceb3ee
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: 0 of 24 files reviewed, 4 unresolved discussions (waiting on @ixti and @natesholland)
.rubocop.yml, line 65 at r2 (raw file):
Performance/UnfreezeString: Enabled: false
What it will take to keep this one enabled?
lib/http/client.rb, line 96 at r2 (raw file):
res rescue StandardError
Please change rubocop config to enforce implicit style:
Style/RescueStandardError:
EnforcedStyle: implicit
lib/http/options.rb, line 21 at r2 (raw file):
def new(options = {}) return options if options.is_a?(self)
We can make this a ternary:
options.is_a?(self) ? options : super
lib/http/mime_type/adapter.rb, line 18 at r2 (raw file):
%w[encode decode].each do |operation| class_eval <<-RUBY, __FILE__, __LINE__ + 1
What cop is this enforced by? I think we should disable it. I find it looking ugly this __LINE__ + 1
.
Per ixti's code review, the maintainers prefer this enforced style so I am changing to the requested style.
This code could easily be collapsed to a ternary per ixti's request so that is what I am doing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: 0 of 24 files reviewed, 4 unresolved discussions (waiting on @ixti and @natesholland)
.rubocop.yml, line 65 at r2 (raw file):
Previously, ixti (Alexey Zapparov) wrote…
What it will take to keep this one enabled?
The spec for this one is here: https://www.rubydoc.info/gems/rubocop/RuboCop/Cop/Performance/UnfreezeString
It has a note that states: Note: String.new
(without operator) is not exactly the same as +''
. These differ in encoding. String.new.encoding
is always ASCII-8BIT
. However, (+'').encoding
is the same as script encoding(e.g. UTF-8
). So, if you expect ASCII-8BIT
encoding, disable this cop.
Since we explicitly care about encoding in many of these specs enabling this cop causes those specs to break. I don't think it's worth it since most of these are only in the specs and not in lib.
lib/http/client.rb, line 96 at r2 (raw file):
Previously, ixti (Alexey Zapparov) wrote…
Please change rubocop config to enforce implicit style:
Style/RescueStandardError: EnforcedStyle: implicit
will do
lib/http/options.rb, line 21 at r2 (raw file):
Previously, ixti (Alexey Zapparov) wrote…
We can make this a ternary:
options.is_a?(self) ? options : super
yes, will do.
lib/http/mime_type/adapter.rb, line 18 at r2 (raw file):
Previously, ixti (Alexey Zapparov) wrote…
What cop is this enforced by? I think we should disable it. I find it looking ugly this
__LINE__ + 1
.
This comes from this cop: https://www.rubydoc.info/gems/rubocop/RuboCop/Cop/Style/EvalWithLocation
The reason that rubocop suggests we do this is that if you add the __LINE__ + 1
then the formatting of the backtrace is more usable and accurate.
If you don't think the benefit of the better backtraces is useful this can easily be changed as it is all wrapped up in commit fb6d66e
@natesholland Honestly I just wanted to try our reviewable ;)) Re Style/EvalWithLocation - I'm totally fine with the requirement of file/line. I don't like |
That PR needs more work to be done. I will get to it as soon as I will have time for that. Thus merging this prior that change. |
@ixti if I have time, would you like me to upgrade RuboCop again in the future? The version I bumped to now is much more recent, but still a ways behind the latest version. |
@natesholland Sure, feel free to do this. I'm all for keeping rubocop to the latest. |
I am trying to get more involved in open source code maintenance. In order to do this I figured I would try upgrading RuboCop for a few gems I use frequently to help them stay up to date. RuboCop on this project was very out of date so I started by upgrading it by ten minor versions to
0.59.2
but I can go further if the maintainers want.I broke this PR into different commits based on what work I was doing. The first commit is the update and auto-fixes. The commits after that are the commits where I made judgement calls on what to do.
Please let me know if there's anything I can do to help or improve.
This change is