Skip to content

Fix quality gate on main: test asserts and regex backtracking - #500

Merged
AndreasIgel merged 8 commits into
java-helpers:mainfrom
igel-devin-ai:devin/fix-main-quality-gate
Dec 6, 2026
Merged

AndreasIgel merged 8 commits into
java-helpers:mainfrom
igel-devin-ai:devin/fix-main-quality-gate

Conversation

@igel-devin-ai

Copy link
Copy Markdown
Contributor

Fixes the failing quality gate on main (reliability rating was 3/C on new code).

Two root causes, both in recently merged test/test-util code:

  • MethodConflictResolutionTest: 5 java assert statements — they are no-ops unless JVM assertions are enabled, so the tests silently verified nothing in normal CI runs. Replaced with assertEquals/assertTrue keeping the original messages (CRITICAL reliability findings)
  • CodegenTestUtils: nested regex repetitions in PACKAGE_PATTERN/TOP_LEVEL_TYPE_PATTERN risked catastrophic backtracking — made possessive/atomic (*+, (?>...)) without changing what they match (MAJOR reliability findings)

Verified: 7/7 conflict tests green, full reactor 1,259 tests green — and the test semantics genuinely changed: the assertions now actually execute.

… risk

- MethodConflictResolutionTest: replace java assert statements with
  JUnit assertEquals/assertTrue (5 critical reliability findings)
- CodegenTestUtils: make nested regex repetitions possessive/atomic so
  they cannot catastrophically backtrack (2 major reliability findings)
The atomic modifier group could consume the type keyword itself (class,
interface, ...) leaving nothing for the type-declaration alternative to
match, so every modified type failed with 'Cannot determine top-level
type name'. The possessive token repetition is kept, but each token is
now guarded by a lookahead excluding the type keywords — keyword
matching recovered, catastrophic backtracking still impossible
@codecov

codecov Bot commented Dec 5, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ All tests successful. No failed tests found.

📢 Thoughts on this report? Let us know!

@igel-devin-ai

igel-devin-ai commented Dec 6, 2026 •

Copy link
Copy Markdown
Contributor Author

Strict review

changes needed

Reviewed head dffe1987ba736ac56b0c8a4956a5ac74686f5a38 against upstream/main 4b696141058c97b8130c3ce3920a7faeafbb3bbd. The PR has no linked issue. I read the PR body, issue comments, and inline review comments; the old Sonar failure comment is not repeated as a new finding.

  1. minor — verified — codegen-testing/src/main/java/org/javahelpers/codegen/testing/CodegenTestUtils.java:350: the new tokenizer splits on spaces, not whitespace. In a Java string literal, \s denotes one space; therefore split("\s+") passes + to the regex engine. A source text block containing public\tclass\tTabbed {} compiles successfully with javac, but CodegenTestUtils.forSource throws IllegalArgumentException: Cannot determine top-level type name from source. Use split("\\s+") or explicit Java-whitespace tokenization and add focused tests for spaces/tabs/multiple declarations and representative annotation declarations. There are no new tests for the replacement parser or the long-input regex fix. This is a defect in the replacement implementation, not a claim that the old space-based regex supported this input; the old regex also had this limitation. My probe deliberately compiled the input directly to rule out invalid Java as the explanation.

  2. minor — verified — processor/src/test/java/org/javahelpers/simple/builders/processor/MethodConflictResolutionTest.java:123–125,178–183: changed test messages still concatenate strings. These two rewritten assertions retain + conflictWarningCount + ..., contrary to the required text-block/no-concatenation convention. Use text blocks with .formatted(conflictWarningCount); convert the other changed assertion messages to text blocks consistently. The JUnit assertion replacements themselves preserve the original predicates and messages.

Verification

  • Java 17 / Maven 3.9.11: mvn -q install -pl codegen-testing,processor -am exited 0. Surefire XML totals: 1,375 tests, 0 failures, 0 errors, 0 skipped; the seven method-conflict tests passed.
  • That build ran initially at bd7262c. fmt sorted two existing imports in ImportCollector.java; I restored that automatic change. The PR then advanced to dffe198, whose only additional change is precisely that import ordering, and the worktree was moved to the new head. The executable source/test inputs used for the passing build are unchanged by that update; no redundant test rerun was performed.
  • External text-block probe: Direct javac compilation: SUCCESS; forSource exception: IllegalArgumentException: Cannot determine top-level type name from source.
  • Latest git_pr_checks: 5 passed, 0 failed, 0 pending. Retrieved JDK 25 job 146025444217 with git_ci_job_logs; its Maven log reports BUILD SUCCESS.
  • Public Sonar quality-gate API now reports OK, maintainability/reliability/security ratings 1, new coverage 80.9%. This is the PR-level status response, which does not include an analyzed commit SHA; I have not established that it analyzes dffe198 specifically. The earlier failed-gate bot comment is not evidence of the currently returned gate status.
  • No processor output changes are introduced; no generated-example regeneration is warranted by this diff.

Other-PR integration review

Read the bodies/file lists of #430, #480, #482, #483, #484, #492, #497, #498, and #499. Read-only pairwise git merge-tree --write-tree checks against their fetched heads all merge cleanly. In particular, #482 changes another method in MethodConflictResolutionTest; retain its varargs expectations alongside these JUnit assertions. #430's shared conformance suite consumes CodegenTestUtils, so parser regression tests are worthwhile. These checks establish textual compatibility only; combined branch builds were not run. No unrelated changes or new API removals were found in this PR.

Written by Devin


Recheck at a8e4b24a (2026-12-06)

Verdict: minor changes

# Original finding (short) Status Remaining action
1 Space-only tokenizer / parser tests fixed —
2 Test-message text-block convention partially fixed — nit Concatenation removed; convert messages and parser fixtures to text blocks (MethodConflictResolutionTest.java:122–126,178–182; CodegenTestUtilsTest.java:55–84).

Build: Current main inspected; tab probe passes with 0 warnings/errors; identical utility/tests passed #430 full verify; no separate #500 build (supplied 0b8d7920 unresolved locally).


Recheck at a8e4b24a (2026-12-06)

Verdict: minor changes

PR #500 is merged; checked unchanged main a8e4b24a. The remaining nit is still present there.

Severity What is missing Where (file:line)
nit Merged PR: text-block conversion is still missing on unchanged main (assertion messages and escaped parser fixtures). MethodConflictResolutionTest.java:122–126,178–182; CodegenTestUtilsTest.java:55–84

@sonarqubecloud

sonarqubecloud Bot commented Dec 6, 2026

Copy link
Copy Markdown

@AndreasIgel
AndreasIgel merged commit 2e5af63 into java-helpers:main Dec 6, 2026
6 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.

2 participants