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 most Ruby 2.7 warnings in Active Record 6.0 #38034
Fix most Ruby 2.7 warnings in Active Record 6.0 #38034
Conversation
ℹ️ I was looking into this as well. A lot of warnings are coming from |
This will mostly break CI on Ruby 2.6 and 2.5. |
Yup, just saw it. Trying to make both work. |
@@ -561,7 +562,7 @@ def column_exists?(column_name, type = nil, options = {}) | |||
# t.index([:branch_id, :party_id], unique: true, name: 'by_branch_party') | |||
# | |||
# See {connection.add_index}[rdoc-ref:SchemaStatements#add_index] for details of the options you can use. | |||
def index(column_name, options = {}) | |||
def index(column_name, options={}) |
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.
Are these changes (options = {}
to options={}
) automatically applied?
Layout/SpaceAroundOperators
is temporarily disabled in #36943 since that cop changed to enforce hard alignment too, but originally we prefer options = {}
over options={}
.
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.
It's my mistake I'll revert those befor easking for review.
This PR is still a WIP at this stage, sorry.
b0e5829
to
af7a486
Compare
Should this be applied to master branch first? Looks like some of change in this PR isn't applied to master yet. |
Oh ? I had no idea. @rafaelfranca asked me to clear 2.7 warnings on the 6.0 branch I though the master one was cleared already. Many of these changes are actually cherry picked from your commits on master, but many need some changes to merge properly |
af7a486
to
d16e6ba
Compare
In master branch, still leave the 2.7 warnings especially for |
Yeah, I saw it wasn't used anywhere, so I assumed it was a no-no. Is it the case? In some instances it would simplify the work a lot, especially on 6-0-stable. |
I suppose we can use |
d16e6ba
to
657520f
Compare
I think this PR should be good to go now. It's big enough already, I'll continue in another one. |
Kinda unrelated, but there's two failures on master:
Looks like the |
It seems it is just the output that changed, the behavior we care about (the sensitive value being filtered) is the same, so we can just update the tests. |
@rafaelfranca will these changes be only released with 6.1? I hoped they will make it to 6.0.2.2, but looks like they didn't. |
6.0.2.2 was a security only release. It’ll be in 6.0.3 or point to the 6-0-stable in your Gemfile to get it now. |
We prefer space around operators, but `Layout/SpaceAroundOperators` cop was temporarily disabled in rails#36943 since that cop changed to check alignment strictly somehow. In RuboCop 1.0.0, that is fixed by rubocop/rubocop#8906. Related rails#38034 (comment), rails#39770 (comment).
In rails/rails#38034 the `save` definition in `ActiveRecord::Validations` was changed from an options hash to keyword arguments to prevent warnings on Ruby 2.7. To prevent future changes to method signatures causing issues use the forwarding shorthand syntax available in 2.7 and later.
In rails/rails#38034 the `save` definition in `ActiveRecord::Validations` was changed from an options hash to keyword arguments to prevent warnings on Ruby 2.7. To prevent future changes to method signatures causing issues use the forwarding shorthand syntax available in 2.7 and later. We have to class_eval the method because even though it's inside the conditional, Ruby < 2.7 still checks the syntax and it raises an error.
In rails/rails#38034 the `save` definition in `ActiveRecord::Validations` was changed from an options hash to keyword arguments to prevent warnings on Ruby 2.7. To prevent future changes to method signatures causing issues use the forwarding shorthand syntax available in 2.7 and later. We have to class_eval the method because even though it's inside the conditional, Ruby < 2.7 still checks the syntax and it raises an error.
There are still plenty left, but I'd like a CI run at this stage to have a better view.