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
[Fix #7641] Remove Style/BracesAroundHashParameters cop #7643
[Fix #7641] Remove Style/BracesAroundHashParameters cop #7643
Conversation
I'm guessing we'll also need to update the style guide. |
@@ -208,196 +206,58 @@ def batch | |||
let(:comma_style) do | |||
'comma' | |||
end | |||
let(:expected_corrected_source) do |
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 only left Style/BracesAroundHashParameters is disabled
context.
@@ -1010,39 +870,6 @@ def do_something | |||
expect(IO.read('example.rb')).to eq(corrected) | |||
end | |||
|
|||
it 'corrects complicated cases conservatively' do |
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.
The following test cases are for the removed cop, so we can remove it.
f8e25ab
to
b0d06ba
Compare
FYI, I opened #7648 to resolve ruby-head CI failure. |
Can you add the |
I added the cop to the removed cops list in bf79528. |
This looks good to me. Can you rebase with the latest master branch and squash your commits into one? |
bf79528
to
fd6dcac
Compare
Rebased. Thanks for reviewing! |
This cop doesn't have relevance since the move in Ruby 2.7 towards differentiating keyword arguments and hash arguments. It is due to be removed from a future version of Rubocop: rubocop/rubocop#7643
Great work! Thanks! |
@pocke Btw, I was wondering if we actually should just revert the behaviour of the cop, so that people can migrate smoothly to Ruby 2.7+. Sorry that this came to my mind so late! |
Thanks for your comment. But I'm not sure I understand your comment correctly due to my poor English. 🙇♂️ I guess you meant you concerned removing the cop is the best way or not. I guess we can re-implement the cop as meaningful for Ruby 2.7+. Some method can receive both of keyword arguments and a hash, for example, probably ActiveRecord's methods receive both. And I guess re-implementing a useful replacement is difficult without static types. Because the replacement should be able to find a method definition from a method call, but it is difficult without types. Please tell me if I misunderstand something 🙇♂️ Thanks! |
You've got some great ideas, but I had something simpler in mind - I was merely thinking that probably it makes sense to have a lint cop that warns people that their code needs to be updated for Ruby 2.7+ - just do the inverse of what it used to do in the past (suggest using braces instead of omitting them). Anyways, that's definitely not a big deal. Just a random thought I had after merging the PR. Probably my suggestion is flawed in some way, as I haven't thought much about it. |
The `Style/BracesAroundHashParameters` cop would flag "redundant" uses of braces to create hashes in Ruby method arguments. Ruby 2.7 requires these braces to disambiguate hash literals from keyword arguments and will issue warnings. The cop has been removed from RuboCop v0.80.0. See: https://www.ruby-lang.org/en/news/2019/12/12/separation-of-positional-and-keyword-arguments-in-ruby-3-0/ See: rubocop/rubocop#7643
The `Style/BracesAroundHashParameters` cop would flag "redundant" uses of braces to create hashes in Ruby method arguments. Ruby 2.7 requires these braces to disambiguate hash literals from keyword arguments and will issue warnings. The cop has been removed from RuboCop v0.80.0. See: https://www.ruby-lang.org/en/news/2019/12/12/separation-of-positional-and-keyword-arguments-in-ruby-3-0/ See: rubocop/rubocop#7643
The `Style/BracesAroundHashParameters` cop would flag "redundant" uses of braces to create hashes in Ruby method arguments. Ruby 2.7 requires these braces to disambiguate hash literals from keyword arguments and will issue warnings. The cop has been removed from RuboCop v0.80.0. See: https://www.ruby-lang.org/en/news/2019/12/12/separation-of-positional-and-keyword-arguments-in-ruby-3-0/ See: rubocop/rubocop#7643
Fix #7641
This pull request removes
Style/BracesAroundHashParameters
cop. Because keyword arguments behavior will be changed in Ruby 3, and has been warned in Ruby 2.7.For more details, see #7641 and https://www.ruby-lang.org/en/news/2019/12/12/separation-of-positional-and-keyword-arguments-in-ruby-3-0/
This pull request removes the cop, and related code. Because we had hacks to avoid auto-correction generates wrong code by the cop and others.
Before submitting the PR make sure the following are checked:
[Fix #issue-number]
(if the related issue exists).master
(if not - rebase it).bundle exec rake default
. It executes all tests and RuboCop for itself, and generates the documentation.