-
-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Use safe navigation for pundit_default_policy
#8530
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
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #8530 +/- ##
=======================================
Coverage 99.11% 99.11%
=======================================
Files 141 141
Lines 4076 4076
=======================================
Hits 4040 4040
Misses 36 36 ☔ View full report in Codecov by Sentry. |
91ecbe7
to
e18c341
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.
Thanks! I think there is another instance on line 26 that can be changed too.
Use the safe navigation operator (`&.`) to streamline the `pundit_default_policy` constantization check, removing the need for a redundant `&&`. This change is now possible as the codebase no longer requires Ruby 2.3 support, which did not yet support safe navigation. The previous implementation was added in commit c93f6f4 to ensure compatibility with older Ruby versions. Also add the safe navigation operator to a subsequent usage of `default_policy_class`
e18c341
to
774c7f4
Compare
Replace a logic `&&` with safe navigation operator now that Ruby < 2.3 support is not required anymore Ref: #8530
Replace a logic `&&` with safe navigation operator now that Ruby < 2.3 support is not required anymore Benchmark (Ruby 3.3.5 x64 / M1 Pro): ``` Comparison (not `nil`): &.: 18787752.0 i/s &&: 17963968.8 i/s - 1.05x (± 0.00) slower Comparison (`nil`): &&: 21343215.5 i/s &.: 20910008.5 i/s - 1.02x (± 0.00) slower ``` Ref: #8530
Replace a logic `&&` with safe navigation operator now that Ruby < 2.3 support is not required anymore Benchmark (Ruby 3.3.5 x64 / M1 Pro): ``` Comparison (not `nil`): &.: 18787752.0 i/s &&: 17963968.8 i/s - 1.05x (± 0.00) slower Comparison (`nil`): &&: 21343215.5 i/s &.: 20910008.5 i/s - 1.02x (± 0.00) slower ``` Ref: #8530
Replace a logic `&&` with safe navigation operator now that Ruby < 2.3 support is not required anymore Benchmark (Ruby 3.3.5 x64 / M1 Pro): ``` Comparison (not `nil`): &.: 18787752.0 i/s &&: 17963968.8 i/s - 1.05x (± 0.00) slower Comparison (`nil`): &&: 21343215.5 i/s &.: 20910008.5 i/s - 1.02x (± 0.00) slower ``` Ref: #8530
Use the safe navigation operator (
&.
) to streamline thepundit_default_policy
constantization check, removing the need for aredundant
&&
.This change is now possible as the codebase no longer requires Ruby 2.3
support, which did not yet support safe navigation.
The previous implementation was added in commit c93f6f4 to ensure
compatibility with older Ruby versions.