Fix code quality issues (AI findings)#308
Conversation
application_controller.rb:
- CGI.unescape: guard with is_a?(String) to handle non-string param values
- admin_for_all_hubs?: use admin? to guarantee boolean return (admin && ...
returns nil instead of false when admin is nil)
devise.rb:
- Remove commented-out secret_key and pepper values (sensitive data in VCS)
- Remove Devise 4.x Warden no-op strategy workaround; now on Devise 5.0.3
Skipped (not actionable):
- redirect_to "#{request.path}?..." flagged as open redirect, but request.path
is the server's own path and can never redirect to an external domain
- application_helper.rb current_end_date inconsistency is intentional:
@end_date is always set by DateSetter; the missing params guard in
current_end_date is deliberate (end date defaults to today, not earliest)
metadata_completeness.rb:
- Rename sThree_response -> s3_response (inconsistent capitalization)
- Fix comment typo: "data" -> "date" in min_date docstring
contributors/index.html.erb:
- Simplify element.checked == true -> element.checked
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
📝 WalkthroughWalkthroughThe PR updates application controller parameter handling and authorization checks, renames an S3 helper method across metadata completeness calls, simplifies boolean logic in a view template, and removes unused Devise configuration entries and strategy block. ChangesCode Modernization and Configuration Cleanup
Possibly related PRs
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
app/controllers/application_controller.rb (1)
63-68: 💤 Low valueInconsistent usage:
require_admin!still usescurrent_user.admin.For consistency with the fix at line 50, consider updating this method to also use
admin?:def require_admin! - unless current_user.admin + unless current_user.admin? flash[:alert] = "You don't have permission to do that." redirect_to admin_user_path(current_user) end endWhile the current code works (nil is falsy), using
admin?consistently across the codebase improves clarity and avoids potential confusion.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@app/controllers/application_controller.rb` around lines 63 - 68, The require_admin! method currently checks current_user.admin; update it to call current_user.admin? for consistency with the change at line 50 and to use the predicate style; modify the require_admin! method (the redirect/flash logic remains the same) so the conditional uses current_user.admin? instead of current_user.admin.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@app/controllers/application_controller.rb`:
- Around line 63-68: The require_admin! method currently checks
current_user.admin; update it to call current_user.admin? for consistency with
the change at line 50 and to use the predicate style; modify the require_admin!
method (the redirect/flash logic remains the same) so the conditional uses
current_user.admin? instead of current_user.admin.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 2c01cbf0-8e30-42b5-9d89-fb7b5bcf141d
📒 Files selected for processing (4)
app/controllers/application_controller.rbapp/lib/metadata_completeness.rbapp/views/contributors/index.html.erbconfig/initializers/devise.rb
Summary
application_controller.rb: GuardCGI.unescapewithis_a?(String)to handle non-string param values; useadmin?inadmin_for_all_hubs?to guarantee boolean return (admin &&returnsnilinstead offalsewhen the column is nil)devise.rb: Remove commented-outsecret_keyandpeppervalues (sensitive data in VCS); remove Devise 4.x Warden no-op strategy workaround — now on Devise 5.0.3metadata_completeness.rb: RenamesThree_response→s3_response(inconsistent camelCase); fix comment typo "data" → "date"contributors/index.html.erb: Simplifyelement.checked == true→element.checkedNot actioned
redirect_to "#{request.path}?..."flagged as open redirect — false positive;request.pathis always the server's own/-prefixed path and cannot redirect to an external domaincurrent_end_datemissingparams[:end_date].present?guard — intentional;@end_dateis always set byDateSetter(defaults to today), so the asymmetry withcurrent_start_dateis by designTest plan
admin_for_all_hubs?returnsfalse(notnil) for non-admin userss3_responserename)🤖 Generated with Claude Code
Summary by CodeRabbit
Release Notes
Bug Fixes
Refactor