Skip to content

Conversation

@MaximPlusov
Copy link
Contributor

@MaximPlusov MaximPlusov commented Nov 21, 2025

Summary by CodeRabbit

  • New Features

    • Added WCAG 2.2 compliance validation for PDF 2.0 with two new flavours: machine and human variants.
  • Removals

    • Removed public WCAG-specific utility methods previously used for standard structure type validation.
  • Refactor

    • Simplified internal WCAG specification mappings and streamlined validation logic by removing redundant WCAG-specific branching across multiple components.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link

coderabbitai bot commented Nov 21, 2025

Walkthrough

The changes introduce WCAG 2.2 PDF 2.0 flavour variants while refactoring WCAG-specific logic across multiple classes. Two new PDFFlavour constants are added, the Specification enum is updated to separate WCAG 2.2 from PDF 2.0 specs, and WCAG-specific conditional branches are removed from structure element and helper classes.

Changes

Cohort / File(s) Summary
WCAG 2.2 PDF 2.0 Flavour Definitions
src/main/java/org/verapdf/parser/PDFFlavour.java
Adds two new enum constants WCAG_2_2_PDF_2_0_MACHINE and WCAG_2_2_PDF_2_0_HUMAN. Updates Specification enum: changes WCAG_2_2 from ISO_32000_2_0 to ISO_32000_1_7, and introduces new WCAG_2_2_PDF_2_0 specification mapped to ISO_32000_2_0.
WCAG Logic Simplification
src/main/java/org/verapdf/pd/structure/PDStructElem.java, src/main/java/org/verapdf/tools/TaggedPDFRoleMapHelper.java
Removes WCAG-specific conditional branches from getStructureTypeStandardStructureType(), isStandardStructureType(), and getCurrentStandardTypes(). Simplifies logic to depend solely on PDF specification version checks rather than WCAG family conditions.
WCAG Helper Field and Method Removals
src/main/java/org/verapdf/tools/TaggedPDFHelper.java
Removes WCAG_STANDARD_ROLE_TYPES field, isWCAGStandardType() method, and getWcagStandardRoleTypes() public getter. Eliminates WCAG-based standard type checks and accessors.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Key areas requiring attention:

  • Verify that removal of WCAG-specific conditional logic in PDStructElem.java and TaggedPDFRoleMapHelper.java does not alter validation behavior for existing WCAG flavours (especially WCAG_2_2)
  • Confirm that removal of public methods isWCAGStandardType() and getWcagStandardRoleTypes() from TaggedPDFHelper has no external callers
  • Validate the separation of WCAG_2_2 (now ISO_32000_1_7) from the new WCAG_2_2_PDF_2_0 specification (ISO_32000_2_0) does not introduce inconsistencies

Poem

🐰 New flavours bloom in PDF's garden,
WCAG_2_2 finds a PDF 2.0 pardon,
Branches trimmed, logic made clean,
Sweetest spec separation I've seen!

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 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 main change: adding WCAG 2.2 PDF 2.0 flavours (WCAG_2_2_PDF_2_0_MACHINE and WCAG_2_2_PDF_2_0_HUMAN) to the PDFFlavour enum.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch wcag_2_0

Tip

📝 Customizable high-level summaries are now available in beta!

You can now customize how CodeRabbit generates the high-level summary in your pull requests — including its content, structure, tone, and formatting.

  • Provide your own instructions using the high_level_summary_instructions setting.
  • Format the summary however you like (bullet lists, tables, multi-section layouts, contributor stats, etc.).
  • Use high_level_summary_in_walkthrough to move the summary from the description to the walkthrough section.

Example instruction:

"Divide the high-level summary into five sections:

  1. 📝 Description — Summarize the main change in 50–60 words, explaining what was done.
  2. 📓 References — List relevant issues, discussions, documentation, or related PRs.
  3. 📦 Dependencies & Requirements — Mention any new/updated dependencies, environment variable changes, or configuration updates.
  4. 📊 Contributor Summary — Include a Markdown table showing contributions:
    | Contributor | Lines Added | Lines Removed | Files Changed |
  5. ✔️ Additional Notes — Add any extra reviewer context.
    Keep each section concise (under 200 words) and use bullet or numbered lists for clarity."

Note: This feature is currently in beta for Pro-tier users, and pricing will be announced later.


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

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
src/main/java/org/verapdf/pd/structure/PDStructElem.java (1)

157-166: Simplify the assignment operator for clarity.

On line 163, the |= operator is misleading. Since isStandard is initialized to false on line 159 and the if-else structure ensures only one branch executes, isStandard is always false when reaching line 163. Therefore, isStandard |= TaggedPDFRoleMapHelper.isStandardType(type) is functionally equivalent to isStandard = TaggedPDFRoleMapHelper.isStandardType(type).

Apply this diff to simplify the operator:

 	} else if (type != null) {
-		isStandard |= TaggedPDFRoleMapHelper.isStandardType(type);
+		isStandard = TaggedPDFRoleMapHelper.isStandardType(type);
 	}
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c95f61f and f20e36a.

📒 Files selected for processing (4)
  • src/main/java/org/verapdf/parser/PDFFlavour.java (2 hunks)
  • src/main/java/org/verapdf/pd/structure/PDStructElem.java (2 hunks)
  • src/main/java/org/verapdf/tools/TaggedPDFHelper.java (0 hunks)
  • src/main/java/org/verapdf/tools/TaggedPDFRoleMapHelper.java (0 hunks)
💤 Files with no reviewable changes (2)
  • src/main/java/org/verapdf/tools/TaggedPDFRoleMapHelper.java
  • src/main/java/org/verapdf/tools/TaggedPDFHelper.java
🧰 Additional context used
🧬 Code graph analysis (1)
src/main/java/org/verapdf/pd/structure/PDStructElem.java (1)
src/main/java/org/verapdf/tools/TaggedPDFRoleMapHelper.java (1)
  • TaggedPDFRoleMapHelper (32-115)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Quality Assurance
  • GitHub Check: Codacy Static Code Analysis
🔇 Additional comments (4)
src/main/java/org/verapdf/parser/PDFFlavour.java (3)

45-46: LGTM! New WCAG 2.2 PDF 2.0 flavours added correctly.

The new flavours follow the established naming convention and are properly mapped to the new WCAG_2_2_PDF_2_0 specification.


79-79: LGTM! New specification correctly maps WCAG 2.2 to PDF 2.0.

The new WCAG_2_2_PDF_2_0 specification is properly defined with the correct family and PDF specification.


78-78: Specification change intentionally splits WCAG 2.2 support across two flavors with backward-compatible migration path.

The change shows:

  • WCAG_2_2 enum now maps to PDF 1.7 (line 78)
  • New WCAG_2_2_PDF_2_0 enum added for PDF 2.0 (line 79)
  • New flavour constants WCAG_2_2_PDF_2_0_MACHINE and WCAG_2_2_PDF_2_0_HUMAN added (lines 45-46)

Verification findings:

  • ✓ No direct code references to WCAG_2_2 enum constant found outside PDFFlavour.java
  • ✓ Specification checks in PDStructElem.java correctly route based on ISO_32000_2_0, so both variants work correctly
  • ✓ No configuration files hard-code WCAG flavor selection
  • ✓ Migration path provided for those needing PDF 2.0 validation

Remaining concern: This is a user-facing default change — applications explicitly selecting WCAG_2_2 flavor will now validate against PDF 1.7 instead of PDF 2.0. Verify that this aligns with WCAG 2.2 specification requirements and that users selecting the old behavior can switch to WCAG_2_2_PDF_2_0.

src/main/java/org/verapdf/pd/structure/PDStructElem.java (1)

130-145: Verify the behavioral change for WCAG 2.2 PDF 2.0 documents—test coverage not found.

No test coverage exists in the repository for the modified methods getStructureTypeStandardStructureType or isStandardStructureType. The PR introduces a significant behavioral change: WCAG 2.2 PDF 2.0 documents (which map to ISO_32000_2_0) now follow the ISO path exclusively, skipping role map helper mapping.

Additionally, line 162 uses the |= operator in an else-if branch where isStandard is always false, making it functionally equivalent to =. This suggests incomplete refactoring of prior WCAG-specific conditional branches.

Ensure this behavioral change is intentional, tested separately, or covered by external test infrastructure, and verify that role map helper mapping is correctly skipped for PDF 2.0 documents.

@MaximPlusov MaximPlusov merged commit a2e6db5 into integration Nov 27, 2025
9 checks passed
@MaximPlusov MaximPlusov deleted the wcag_2_0 branch December 3, 2025 21:33
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.

2 participants