Skip to content

Improve isset before not empty sniff#3073

Merged
Crabcyborg merged 1 commit into
masterfrom
improve_isset_before_not_empty_sniff
Apr 10, 2026
Merged

Improve isset before not empty sniff#3073
Crabcyborg merged 1 commit into
masterfrom
improve_isset_before_not_empty_sniff

Conversation

@Crabcyborg

@Crabcyborg Crabcyborg commented Apr 10, 2026

Copy link
Copy Markdown
Contributor

No idea why it has this array check. It's totally inaccurate.

Summary by CodeRabbit

  • Bug Fixes
    • Enhanced detection of redundant isset() checks, including patterns with array access
    • Improved formatting of automatically injected security guard code

@coderabbitai

coderabbitai Bot commented Apr 10, 2026

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 938bcb76-c471-490b-ba8e-9708f4b0671e

📥 Commits

Reviewing files that changed from the base of the PR and between 73a1acc and 22c11de.

📒 Files selected for processing (2)
  • phpcs-sniffs/Formidable/Sniffs/CodeAnalysis/RedundantIssetBeforeNotEmptySniff.php
  • phpcs-sniffs/Formidable/Sniffs/Security/AddDirectFileAccessCheckSniff.php
💤 Files with no reviewable changes (1)
  • phpcs-sniffs/Formidable/Sniffs/CodeAnalysis/RedundantIssetBeforeNotEmptySniff.php

📝 Walkthrough

Walkthrough

Two PHP_CodeSniffer sniff files were modified. One sniff's guard condition preventing fixes for array-access patterns was removed, enabling broader fixing capabilities. Another sniff's injected code string was updated to include a trailing newline for formatting consistency.

Changes

Cohort / File(s) Summary
Sniff Guard Removal
phpcs-sniffs/Formidable/Sniffs/CodeAnalysis/RedundantIssetBeforeNotEmptySniff.php
Removed 7-line guard condition that previously skipped fixes for isset() expressions containing array-access syntax, allowing patterns like isset( $array['key'] ) && ! empty( $array['key'] ) to be flagged and fixed.
ABSPATH Guard Formatting
phpcs-sniffs/Formidable/Sniffs/Security/AddDirectFileAccessCheckSniff.php
Added trailing newline character (\n) to the ABSPATH guard string injection, affecting the formatting of the inserted die(...) statement in fixed code.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~5 minutes

Poem

🐰 A rabbit bounds through sniffs with cheer,
Guards removed, the path is clear!
Array keys now properly fixed,
With newlines fresh, the logic mixed!

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately reflects the primary change in the PR, which is improving the RedundantIssetBeforeNotEmptySniff by removing a guard condition.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch improve_isset_before_not_empty_sniff

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@deepsource-io

deepsource-io Bot commented Apr 10, 2026

Copy link
Copy Markdown

DeepSource Code Review

We reviewed changes in 73a1acc...22c11de on this pull request. Below is the summary for the review, and you can see the individual issues we found as inline review comments.

See full review on DeepSource ↗

Important

Some issues found as part of this review are outside of the diff in this pull request and aren't shown in the inline review comments due to GitHub's API limitations. You can see those issues on the DeepSource dashboard.

PR Report Card

Overall Grade   Security  

Reliability  

Complexity  

Hygiene  

Code Review Summary

Analyzer Status Updated (UTC) Details
PHP Apr 10, 2026 7:57p.m. Review ↗
JavaScript Apr 10, 2026 7:57p.m. Review ↗

Important

AI Review is run only on demand for your team. We're only showing results of static analysis review right now. To trigger AI Review, comment @deepsourcebot review on this thread.

@Crabcyborg Crabcyborg merged commit 082f19d into master Apr 10, 2026
47 of 48 checks passed
@Crabcyborg Crabcyborg deleted the improve_isset_before_not_empty_sniff branch April 10, 2026 20:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant