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
Update rubocop dependency to < 2.0 #8
Changes from all commits
96b3833
b03ad86
0d4e5a2
f5be02f
cc3bced
b9066b4
469742b
068f976
93a6f35
39dc3cc
2df866c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,6 @@ | |
# Copied and adapted from: | ||
# https://github.com/rubocop-hq/rubocop-minitest/blob/v0.8.1/test/assertion_helper.rb | ||
# | ||
# | ||
# =========== | ||
# | ||
# | ||
|
@@ -70,10 +69,10 @@ def inspect_source(source, cop, file = nil) | |
end | ||
|
||
def investigate(cop, processed_source) | ||
forces = RuboCop::Cop::Force.all.each_with_object([]) do |klass, instances| | ||
next unless cop.join_force?(klass) | ||
|
||
instances << klass.new([cop]) | ||
needed = Hash.new { |h, k| h[k] = [] } | ||
Array(cop.class.joining_forces).each { |force| needed[force] << cop } | ||
forces = needed.map do |force_class, joining_cops| | ||
force_class.new(joining_cops) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can you comment more on why you needed to make this change? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh yes, sorry! I thought it was in a commit comment but I missed it. Change was introduced in rubocop/rubocop@f8813e7 on v0.87. Details are vague, because it's a big commit/PR, but it removes the In reality, I just copy-pasted the updated version from https://github.com/rubocop/rubocop-minitest/blob/v0.11.0/test/assertion_helper.rb (As noted in the top of this file, the entire file is copied from there) |
||
end | ||
|
||
commissioner = RuboCop::Cop::Commissioner.new([cop], forces, raise_error: true) | ||
|
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.
I'm... not sure why this is needed to be defined like this (v.s.
needed = Hash.new
) 🤔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.
Good question! It's another Ruby nicety
This creates a hash where the default value is a new hash (new as in new every time, not the same array as it'd happen with
Hash.new([])
)This allows to use
<<
in the line below without having to initialize eachneeded[x]
every time.More details: