Skip to content

Fix Flesch-Kincaid grade 9 threshold - #1856

Merged
pattonwebz merged 2 commits into
equalizedigital:developfrom
benitoalba:fix/1797-flesch-kincaid-grade-threshold
Aug 5, 2026
Merged

Fix Flesch-Kincaid grade 9 threshold#1856
pattonwebz merged 2 commits into
equalizedigital:developfrom
benitoalba:fix/1797-flesch-kincaid-grade-threshold

Conversation

@benitoalba

@benitoalba benitoalba commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Fixes #1797.

Summary

  • Treat Flesch-Kincaid grade 9 as passing and only grades above 9 as readability failures.
  • Align the AJAX post-grade and REST simplified-summary thresholds on > 9.
  • Correct the misleading threshold comment and add grade 9/10 regression coverage for both paths.

Root cause

Two readability paths used boundary conditions equivalent to >= 9, while the related checks and user-facing copy define a failure as a reading level higher than grade 9. A nearby comment also described the correct > 9 comparison as "grade 9+."

Validation

  • Focused PHPUnit suite: 11 tests, 46 assertions.
  • Full PHPUnit suite: 878 tests, 1,880 assertions, 15 skipped.
  • PHPCS on all four changed files.
  • PHP lint across 226 files.
  • git diff --check.

Checklist

  • PR is linked to the main issue in the repo.
  • Tests are added that cover changes.

Summary by CodeRabbit

  • Bug Fixes

    • Updated readability scoring so grade 9 passes the threshold, while only grades above 9 are marked as failing.
    • Applied the corrected threshold consistently across readability messages, icons, and simplified-summary results.
  • Tests

    • Added coverage for grade 9 passing and grade 10 failing in readability checks.

@coderabbitai

coderabbitai Bot commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 9519618b-99ee-4617-b222-1060029f3615

📥 Commits

Reviewing files that changed from the base of the PR and between 0053fb7 and ba28f91.

📒 Files selected for processing (1)
  • tests/phpunit/includes/classes/RestApiSidebarDataTest.php
🚧 Files skipped from review as they are similar to previous changes (1)
  • tests/phpunit/includes/classes/RestApiSidebarDataTest.php

📝 Walkthrough

Walkthrough

Readability failure checks now use a strict grade-above-9 threshold in AJAX and REST responses. PHPUnit tests cover grade 9 as passing and grade 10 as failing.

Changes

Readability threshold alignment

Layer / File(s) Summary
Apply strict grade threshold
admin/class-ajax.php, includes/classes/class-rest-api.php
Readability failures now require a grade above 9, including simplified-summary results. The REST API comment documents the grade 10+ threshold.
Validate grade boundary
tests/phpunit/Admin/AjaxReadabilityTest.php, tests/phpunit/includes/classes/RestApiSidebarDataTest.php
PHPUnit coverage verifies grade 9 passes and grade 10 fails in AJAX and REST readability behavior. Test cleanup removes simplified-summary metadata.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

Suggested reviewers: pattonwebz

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly identifies the Flesch-Kincaid grade 9 threshold fix, which is the primary change.
Linked Issues check ✅ Passed The changes implement issue #1797 by applying >9 comparisons, correcting the comment, and adding grade 9 and 10 regression tests.
Out of Scope Changes check ✅ Passed All code and test changes directly support the readability threshold fix and its regression coverage; no unrelated changes are present.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@benitoalba
benitoalba marked this pull request as ready for review July 29, 2026 22:42

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 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.

Inline comments:
In `@tests/phpunit/includes/classes/RestApiSidebarDataTest.php`:
- Around line 161-163: Update the test cleanup flow in tearDown() for the shared
self::$post_id fixture to delete the _edac_simplified_summary metadata after
each test, ensuring test_get_readability_data_uses_above_ninth_grade_threshold()
cannot affect later tests.
🪄 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: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 0c03123b-c37e-4810-acfe-ccb447df1a8b

📥 Commits

Reviewing files that changed from the base of the PR and between b2fcc98 and 0053fb7.

📒 Files selected for processing (4)
  • admin/class-ajax.php
  • includes/classes/class-rest-api.php
  • tests/phpunit/Admin/AjaxReadabilityTest.php
  • tests/phpunit/includes/classes/RestApiSidebarDataTest.php

Comment thread tests/phpunit/includes/classes/RestApiSidebarDataTest.php
@pattonwebz
pattonwebz merged commit d9e8df3 into equalizedigital:develop Aug 5, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix inconsistent Flesch-Kincaid grade 9 pass/fail threshold across readability checks

2 participants