Add code review prevention checklist#1836
Add code review prevention checklist#1836arifulhoque7 wants to merge 1 commit intoweDevsOfficial:developfrom
Conversation
Add a mandatory Code Review Prevention Checklist to developer docs. The detailed checklist in .claude/skills/wpuf-backend-dev/SKILL.md covers top rejection causes and required practices (strict ===/!== comparisons, in_array/array_search with strict true, wp_unslash() + sanitization for superglobals, output escaping, $wpdb->prepare() for SQL, nonce verification, permission checks, snake_case method naming, @SInCE docblocks, translator comments, hook prefixes, spacing rules, and a pre-PR mental checklist). A condensed summary of these rules was also added to CLAUDE.md with guidance to run composer phpcs before submitting changes.
WalkthroughDocumentation files updated to establish code review prevention standards. Added comprehensive checklists and mandatory coding conventions covering strict comparisons, sanitization, SQL safety, security verification, naming patterns, and WordPress standards. Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~4 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
.claude/skills/wpuf-backend-dev/SKILL.md (1)
391-405: Clarify SQL rule wording to avoid unsafe interpretation.“Use prepare or allowlist” can be read as either/or for dynamic SQL. Safer wording: allowlist identifiers (e.g., ORDER BY columns/direction) and use
$wpdb->prepare()for values.✏️ Suggested doc wording tweak
-**Even for ORDER BY / LIMIT — use prepare or allowlist:** +**Even for ORDER BY / LIMIT — allowlist identifiers, and use `$wpdb->prepare()` for values:**🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In @.claude/skills/wpuf-backend-dev/SKILL.md around lines 391 - 405, Update the guidance text to avoid "prepare or allowlist" ambiguity by explicitly instructing developers to allowlist SQL identifiers (e.g., ORDER BY column names and sort direction using the example variables $allowed_orderby, $orderby, $order) and separately use $wpdb->prepare() for user-supplied values (e.g., LIMIT/offset parameters such as $args['offset'] and $args['number']); make the example and wording state that identifiers must be validated against the allowlist and only values should be passed through $wpdb->prepare().
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@CLAUDE.md`:
- Line 193: The rule is too broad—don't require check_ajax_referer() +
current_user_can(wpuf_admin_role()) for every form/AJAX; instead, scope checks
by context: use check_ajax_referer() for AJAX endpoints and wp_verify_nonce()
(or form-specific nonce verification) for standard form handlers, and only call
current_user_can(...) / wpuf_admin_role() when the operation is privileged
(e.g., modifying other users, admin-only settings); ensure guest/frontend
submissions use appropriate nonce-only validation or alternate flow instead of
admin capability checks, and consider adding a small helper (e.g.,
verify_form_nonce_and_capability) or documenting the pattern to enforce
context-aware checks.
---
Nitpick comments:
In @.claude/skills/wpuf-backend-dev/SKILL.md:
- Around line 391-405: Update the guidance text to avoid "prepare or allowlist"
ambiguity by explicitly instructing developers to allowlist SQL identifiers
(e.g., ORDER BY column names and sort direction using the example variables
$allowed_orderby, $orderby, $order) and separately use $wpdb->prepare() for
user-supplied values (e.g., LIMIT/offset parameters such as $args['offset'] and
$args['number']); make the example and wording state that identifiers must be
validated against the allowlist and only values should be passed through
$wpdb->prepare().
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: d7a57d05-f538-4b62-8e04-41701680489e
📒 Files selected for processing (2)
.claude/skills/wpuf-backend-dev/SKILL.mdCLAUDE.md
| 3. **Superglobals** — `wp_unslash()` + sanitize every `$_POST/$_GET/$_REQUEST/$_SERVER` access. Use `sanitize_text_field(wp_unslash(...))`, `absint()`, `sanitize_email(wp_unslash(...))`, `esc_url_raw(wp_unslash(...))`, `sanitize_key(wp_unslash(...))` | ||
| 4. **Escape all output** — `esc_html()` for text, `esc_attr()` for attributes, `esc_url()` for URLs, `wp_kses_post()` for HTML | ||
| 5. **SQL safety** — `$wpdb->prepare()` for ALL dynamic values. Allowlist column names for ORDER BY | ||
| 6. **Nonce + permission** — every form/AJAX: `check_ajax_referer()` + `current_user_can(wpuf_admin_role())` |
There was a problem hiding this comment.
This rule is too broad and may cause incorrect auth handling.
Requiring check_ajax_referer() + current_user_can( wpuf_admin_role() ) for every form/AJAX is not universally correct (e.g., non-AJAX form handlers, frontend/guest submissions). Recommend scoping it to: nonce verification per context (form vs AJAX), plus capability checks for sensitive operations only.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@CLAUDE.md` at line 193, The rule is too broad—don't require
check_ajax_referer() + current_user_can(wpuf_admin_role()) for every form/AJAX;
instead, scope checks by context: use check_ajax_referer() for AJAX endpoints
and wp_verify_nonce() (or form-specific nonce verification) for standard form
handlers, and only call current_user_can(...) / wpuf_admin_role() when the
operation is privileged (e.g., modifying other users, admin-only settings);
ensure guest/frontend submissions use appropriate nonce-only validation or
alternate flow instead of admin capability checks, and consider adding a small
helper (e.g., verify_form_nonce_and_capability) or documenting the pattern to
enforce context-aware checks.
Add a mandatory Code Review Prevention Checklist to developer docs. The detailed checklist in .claude/skills/wpuf-backend-dev/SKILL.md covers top rejection causes and required practices (strict ===/!== comparisons, in_array/array_search with strict true, wp_unslash() + sanitization for superglobals, output escaping, $wpdb->prepare() for SQL, nonce verification, permission checks, snake_case method naming, @SInCE docblocks, translator comments, hook prefixes, spacing rules, and a pre-PR mental checklist). A condensed summary of these rules was also added to CLAUDE.md with guidance to run composer phpcs before submitting changes.
Summary by CodeRabbit