Reject HTML formatting tags in Markdown Javadoc via checkstyle - #16793
Conversation
Extends the checkstyle guard for /// comments to also reject HTML formatting tags (<code>, <tt>, <b>, <i>, <em>, <strong>), converts the existing occurrences to backticks/fenced code blocks, and documents the rule in AGENTS.md. Tags quoted in backticks stay allowed. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016GE6gwvvDoVDcuakywqunj
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016GE6gwvvDoVDcuakywqunj
PR Summary by QodoEnforce Markdown formatting in Markdown Javadoc
AI Description
Diagram
High-Level Assessment
Files changed (34)
|
Code Review by Qodo
1. Backtick adjacency bypasses rule
|
Extends the checkstyle rule to line/paragraph-break tags and converts the existing occurrences to Markdown paragraph breaks; the HTML table in PreferencesMigrations becomes a Markdown table. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016GE6gwvvDoVDcuakywqunj
…itive The rule now also matches uppercase multi-letter tags (<CODE> etc.) and <pre>; single-letter tags stay lowercase-only because uppercase <B>/<I>/<P> are generic type parameters in @PARAM tags. A tag directly followed by a backtick is exempt, so quoted spans like `<code>value</code>` pass. Converts the remaining <CODE> and <pre> occurrences. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016GE6gwvvDoVDcuakywqunj
| <module name="RegexpSingleline"> | ||
| <property name="id" value="MarkdownJavadocNoHtmlFormattingTags"/> | ||
| <property name="message" value="Markdown Javadoc (///) must use Markdown syntax, not HTML formatting tags: `code` instead of <code>code</code>, fenced code blocks (```) instead of <pre><code>." /> | ||
| <property name="format" value="^\s*///.*(?<!`)</?((?i:code|tt|em|strong|br|pre)|b|i|p)\s*/?>(?!`)" /> |
There was a problem hiding this comment.
1. Backtick adjacency bypasses rule 📘 Rule violation ≡ Correctness
The regex exempts a forbidden HTML tag when either neighboring character is a backtick, even when that backtick belongs to a separate Markdown code span. Thus a line such as ``/// prefix<code>value</code>suffix `` passes while still using active HTML formatting.
Agent Prompt
## Issue description
The HTML-tag check treats any immediately adjacent backtick as proof that a tag is inside a Markdown code span. Separate code spans can therefore surround active HTML and bypass enforcement.
## Issue Context
Literal HTML/XML tags should remain allowed only when the complete tag occurrence is actually enclosed within a Markdown code span. Keep the normal and reviewdog Checkstyle configurations synchronized and add regression coverage for both legitimate literal tags and adjacency bypasses.
## Fix Focus Areas
- config/checkstyle/checkstyle.xml[93-103]
- config/checkstyle/checkstyle_reviewdog.xml[82-92]
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
| <module name="RegexpSingleline"> | ||
| <property name="id" value="MarkdownJavadocNoHtmlFormattingTags"/> | ||
| <property name="message" value="Markdown Javadoc (///) must use Markdown syntax, not HTML formatting tags: `code` instead of <code>code</code>, fenced code blocks (```) instead of <pre><code>." /> | ||
| <property name="format" value="^\s*///.*(?<!`)</?((?i:code|tt|em|strong|br|pre)|b|i|p)\s*/?>(?!`)" /> |
There was a problem hiding this comment.
2. Checker behavior lacks tests 📘 Rule violation ☼ Reliability
The PR adds nontrivial Checkstyle behavior and documented exceptions but no deterministic tests for rejected tags, allowed literal tags, or edge cases. Configuration loading only proves that current sources pass; it does not protect the rule's intended behavior from regressions.
Agent Prompt
## Issue description
The new Markdown Javadoc HTML-tag enforcement has no automated positive and negative behavior tests.
## Issue Context
Add deterministic coverage that verifies prohibited formatting tags fail, backtick-quoted literal HTML/XML passes, supported casing behaves intentionally, and both Checkstyle configurations retain equivalent enforcement.
## Fix Focus Areas
- config/checkstyle/checkstyle.xml[93-103]
- config/checkstyle/checkstyle_reviewdog.xml[82-92]
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
|
Code review by qodo was updated up to the latest commit 7fe48ea |
# Conflicts: # jablib/src/main/java/org/jabref/model/entry/AuthorList.java
|
🤖 Generated with Claude Code Merged
Generated by Claude Code |
| - Boolean method parameters (for public methods) should be avoided. Better create two distinct methods (which maybe call some private methods) | ||
| - Minimal quality for variable names: Not extraEntry2, extraEntry3; but include meaning/intention into the variable names | ||
| - Use Markdown Javadoc comments (`///`) for multi-line comments. Within them, use Markdown syntax, not JavaDoc inline tags: `` `code` `` instead of `{@code code}`, and `[ClassName]` instead of `{@link ClassName}`. | ||
| - Use Markdown Javadoc comments (`///`) for multi-line comments. Within them, use Markdown syntax — neither JavaDoc inline tags nor HTML formatting tags: `` `code` `` instead of `{@code code}` or `<code>code</code>`, `[ClassName]` instead of `{@link ClassName}`, and fenced code blocks (```` ``` ````) instead of `<pre><code>`. |
There was a problem hiding this comment.
'syntax — neither' tell me you used ai without saying, that you used ai... ;-)
less em, more direct
* upstream/fix-sync: Drop all former default entry editor tabs on upgrade (#16780) Chore(deps): Bump org.yaml:snakeyaml from 2.6 to 2.7 in /versions (#16796) Reject HTML formatting tags in Markdown Javadoc via checkstyle (#16793) Update GitVersion to 6.x (#16789) New Crowdin updates (#16794) Rename @FetcherTest to @ExternalServicesTest (#16783) Ignore line-wrapping whitespace in person names integrity check (#16761) Enable OpenJ9 shared classes cache for Semeru builds (#16775) Fix requirements concerning the text field focus and clipboard paste (#16773) Replace leftover <ol> HTML tags in Markdown doc comments with numbered lists (#16785) Fix Add file link dialog focus on macOS (#16706) Fix invisible keyboard shortcut filter text (#16749) Instruct sorting CHANGELOG entries next to related ones (#16751) Catch "Fix for #xyz" PR titles in the title format check (#16786) Make LinkedFileViewModelTest download tests hermetic via a local HTTP stub (#16781)
🤖 Summary
Markdown Javadoc (
///) comments kept accumulating HTML formatting tags (<code>,<tt>, …) — especially from AI-assisted edits — instead of Markdown. A new checkstyle rule now rejects HTML formatting tags in///comments (backtick-quoted tags documenting literal HTML/XML stay allowed), the existing occurrences are converted, and AGENTS.md states the rule.Analogies: Like honey, this PR preserves what is already good and keeps it from spoiling; like chocolate, it is a small piece with a disproportionate effect on wellbeing; and like the moon, it does not shine by itself — it only reflects the style rules already written down.
jabref-contrib-policy:4.2:reviewed:okSteps to test
/// returns <code>true</code>to any Java file../gradlew :jablib:checkstyleMain— it fails withMarkdownJavadocNoHtmlFormattingTags.Related issues and pull requests
None — follow-up to #16765 (which banned JavaDoc inline tags in
///comments).AI usage
Claude Code (model claude-fable-5), AIL4 (AI-authored, human-directed and reviewed).
AI CHECKLIST.md walkthrough
Nullability and control flow
== null/!= nullchecks — comment/config-only change.Objects.requireNonNull(...).@NullMarked.Optionalconsumed withifPresent/ifPresentOrElse/map/orElseThrow.StringUtil.isBlank(...)used.Exceptions
catch (Exception e)— not applicable to this group (no executable code touched).throw new RuntimeException(...)/IllegalStateException(...).Style and idioms
BibEntryobjects built with withers — not applicable to this group.Pattern.compile(...)constant.BackgroundTask.///) uses Markdown syntax, not JavaDoc inline tags.User-facing text
Security
Tests
Verification commands
./gradlew :jablib:check— not run in full; checkstyle + javadoc run instead (comment-only change)../gradlew checkstyleMain checkstyleTest— all modules pass, including the new rule../gradlew modernizer— no executable code changed../gradlew rewriteRunrun; no further changes../gradlew :jablib:javadocpasses on the converted comments.npx markdownlint-cli2— AGENTS.md edit is a single list-item rewording..idea/codeStyles/Project.xml, IU-253).Documentation
CHANGELOG.md— not visible to users (one "not applicable" note for this group).Pull request
gh pr create --body-file.TODOplaceholder used.Checklist
CHANGELOG.mddescribing the change from the user's point of view (if the change is visible to the user)🤖 Generated with Claude Code