Skip to content

refactor: clear the SonarCloud new-code findings on main - #703

Merged
devops-thiago merged 6 commits into
mainfrom
refactor/sonar-new-code-smells
Aug 13, 2026
Merged

refactor: clear the SonarCloud new-code findings on main#703
devops-thiago merged 6 commits into
mainfrom
refactor/sonar-new-code-smells

Conversation

@devops-thiago

Copy link
Copy Markdown
Owner

What type of PR is this?

  • 🐛 Bug fix
  • ✨ Feature
  • 📝 Documentation
  • 🔧 Refactor
  • 🚀 Performance
  • ✅ Test
  • 🔒 Security
  • 📦 Dependency update
  • 🏗️ CI/CD

Description

Clears all 14 SonarCloud new-code findings on main — every one fixed at the source, no suppressions, no rule exclusions, and behavior-neutral throughout (every fix below was verified against the existing test suite, and the regex splits were additionally fuzz-checked for exact input/output equivalence against the original patterns).

java:S5843 / java:S6353 — over-budget regexes (FindingVerificationService ×2 + S6353, GitHubApiError ×1)

  • MITIGATION_ASSERTED (complexity 50, and the {0,1} S6353) is split into MITIGATION_ASSERTED_BE, MITIGATION_ASSERTED_GET and MITIGATION_ASSERTED_SUBJECT, following the file's established split-into-a-union pattern. assertsMitigation walks the three as ONE alternation (leftmost match wins, position tie in declared order, scan resumes after the match) so the defeater reads exactly the matches the single pattern read — a plain per-pattern pass would also surface matches the one-alternation scan stepped over.
  • MITIGATION_ABSENT_SUBJECT (complexity 30) becomes three anchored patterns (ABSENCE_SUBJECT_VERB, NEGATING_SUBJECT_BEFORE_VERB, DEFENSE_OBJECT_AFTER_VERB) joined in claimsAbsenceAsSubject, which checks every verb token against the verbatim prefix and trailing-lookahead bodies of the one-pattern form — deciding exactly the parses the original decided through backtracking, including the fix(review): floor unmitigated-injection-sink findings at high risk #594/fix(review): close three under-fire gaps in the injection-sink floor's defeaters #676/fix(review): close three under-fire gaps in the injection-sink floor's defeaters #685-pinned phrasings ("Nothing sanitizes…", "Nothing escapes validation", do-support, protasis coordinators). All existing pattern-pinning tests pass unchanged.
  • CREDENTIAL_SHAPED (complexity 24) splits into CREDENTIAL_SHAPED_PREFIX and CREDENTIAL_SHAPED_VALUE, and redactCredentials re-implements the exact one-pass replaceAll semantics as a leftmost-match merge across both patterns (position tie → prefix shapes, i.e. the original alternative order), preserving the overlap behavior the javadoc pins. Two new tests pin the two documented overlap cases.

java:S5785 — BlockingStrictnessTest:64/89: assertTrue(a == b, …)assertEquals(expected, actual, …).

java:S3398 — move private methods into their only-caller inner classes

  • FindingPipeline#heuristicFailureModesForBatchPrompts, ReviewDiffFormatter#compileGlobMatchersIgnoreGlobs. Both methods emit operator-facing WARNs whose category the build-time Log facade would have silently relabeled to the nested class; each class now carries an explicit org.jboss.logging.Logger pinned to the outer class, so the category, level and rendered message are unchanged.
  • HeuristicCodeDetector#isTestPathFileScope (no logging involved).

java:S1075 — JacocoCoverageReport:202: the "/" literal becomes the documented constant BINARY_PACKAGE_SEPARATOR (it is the class-file binary-name separator, deliberately not File.separator).

java:S135 — RepoSettingsParser:268: the sanitize loop's two continues are extracted into the isKeepablePattern predicate (which keeps the over-long warn), leaving a single break — warn ordering and outcomes are byte-identical.

java:S9016 — AuthResourceTestFixtures:67-69: the three inline mock(…) calls inside thenReturn(…) are extracted to local variables.

Related Issues

N/A

How Has This Been Tested?

  • Unit tests
  • Integration tests
  • Manual testing

./mvnw verify green locally (Spotless, SpotBugs, full test suite, JaCoCo). The three regex splits were additionally fuzz-tested (500k randomized inputs per pattern family) against the original patterns with zero divergences, and the redaction overlap cases documented in the javadoc are now pinned by tests.

Checklist

  • My code follows the project's coding standards
  • I have performed a self-review of my own code
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • I have updated the documentation accordingly
  • My changes generate no new warnings or errors

Screenshots / Logs

N/A

Additional Notes

No changelog entry: internal smell cleanup with no user-visible change, following #631#634 precedent.

@github-actions

Copy link
Copy Markdown
Contributor

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Scanned Files

None

@codecov

codecov Bot commented Aug 13, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

devops-thiago added a commit that referenced this pull request Aug 13, 2026
…efeaters

Rebased onto the #703 split shapes. DEFENSE_OBJECT_AFTER_VERB gains the
parameteriz stem the verb group already had and accepts clause-break
punctuation (semicolon, colon, dashes) as a separator, so "Nothing
escapes parameterization" and "Nothing escapes; the sanitizer runs on
render" read as the mitigations they assert instead of over-firing the
floor; the comma is deliberately excluded so comma-coordinated absence
verbs and appositive denials stay absence claims, and the denied
defense across a clause break is documented as accepted residual
under-fire. A new ABSENCE_MODAL_VERB token registers modal absence
claims ("Nothing can sanitize the value", one non-negator adverb
admitted), MITIGATION_DO_SUPPORTED admits one non-negator gap word so
"does always escape" defeats the floor while "does not escape" stays an
absence claim, and MITIGATION_ASSERTED_SUBJECT excludes coordinators
from its subject slot so "Nothing escapes, sanitizes, or validates the
value" does not read its own continuation as a mitigation.

Closes #696
devops-thiago added a commit that referenced this pull request Aug 13, 2026
…efeaters

Rebased onto the #703 split shapes. DEFENSE_OBJECT_AFTER_VERB gains the
parameteriz stem the verb group already had and accepts clause-break
punctuation (semicolon, colon, dashes) as a separator, so "Nothing
escapes parameterization" and "Nothing escapes; the sanitizer runs on
render" read as the mitigations they assert instead of over-firing the
floor; the comma is deliberately excluded so comma-coordinated absence
verbs and appositive denials stay absence claims, and the denied
defense across a clause break is documented as accepted residual
under-fire. A new ABSENCE_MODAL_VERB token registers modal absence
claims ("Nothing can sanitize the value", one non-negator adverb
admitted), MITIGATION_DO_SUPPORTED admits one non-negator gap word so
"does always escape" defeats the floor while "does not escape" stays an
absence claim, and MITIGATION_ASSERTED_SUBJECT excludes coordinators
from its subject slot so "Nothing escapes, sanitizes, or validates the
value" does not read its own continuation as a mitigation.

Closes #696
@thrillhousebot

Copy link
Copy Markdown
Contributor

🤖 ThrillhouseBot PR Summary

What this PR does

Clears SonarCloud new-code findings via behavior-neutral refactors: three over-budget regexes are split into smaller patterns whose single-pattern find()/replaceAll semantics are re-implemented with explicit leftmost-match walks, private methods move into their only-caller nested classes with loggers pinned to the outer classes, and several small smell fixes land (assertEquals instead of assertTrue(a==b), the '/' BINARY_PACKAGE_SEPARATOR constant, the isKeepablePattern predicate, extracted mock variables).

Description vs. Implementation

No mismatch found between the PR description and the change.

Control-Flow Diagram

🔀 Show diagram
flowchart TD
    A["assertsMitigation(asserted)"] --> B{"hasUnnegatedAssertedMatch: leftmost across BE, GET, SUBJECT"}
    B -->|"no match"| C["fall back to MITIGATION_DO_SUPPORTED"]
    B -->|"match not preceded by nothing or nobody"| D["defeater fires: mitigation asserted"]
    B -->|"match preceded by nothing or nobody"| B
    E["claimsNothingNeutralizesIt(text)"] --> F["claimsAbsenceAsSubject: iterate verb tokens"]
    F --> G{"prefix is nothing or nobody plus up to 3 gap words, and no defense stem within 2 words after verb"}
    G -->|"yes"| H["absence claim fires"]
    G -->|"no"| F
    I["GitHubApiError.clean"] --> J["redactCredentials: leftmost match across prefix and value patterns"]
    J -->|"match"| K["mask match and resume from its end"] --> J
    J -->|"no match"| L["emit remaining text"]
Loading

Changes Overview

  • Files changed: 11
  • Lines added: +355
  • Lines removed: -179

Changed Files

File Change Summary
src/main/java/dev/thiagogonzaga/thrillhousebot/github/GitHubApiError.java Modified Splits CREDENTIAL_SHAPED into prefix/value patterns and re-implements replaceAll as a leftmost-match merge in redactCredentials.
src/main/java/dev/thiagogonzaga/thrillhousebot/github/RepoSettingsParser.java Modified Extracts the sanitize loop's keep/drop decisions into isKeepablePattern, preserving warn order and output.
src/main/java/dev/thiagogonzaga/thrillhousebot/review/FindingPipeline.java Modified Moves heuristicFailureModesFor into BatchPrompts and adds a Logger pinned to FindingPipeline to keep the WARN category unchanged.
src/main/java/dev/thiagogonzaga/thrillhousebot/review/HeuristicCodeDetector.java Modified Moves isTestPath into the FileScope record, its only caller, per java:S3398.
src/main/java/dev/thiagogonzaga/thrillhousebot/review/JacocoCoverageReport.java Modified Replaces the literal '/' with BINARY_PACKAGE_SEPARATOR to clear java:S1075, moving the rationale into javadoc.
src/main/java/dev/thiagogonzaga/thrillhousebot/review/ReviewDiffFormatter.java Modified Moves compileGlobMatchers into IgnoreGlobs with a Logger pinned to ReviewDiffFormatter, preserving the WARN category.
src/main/java/dev/thiagogonzaga/thrillhousebot/review/ai/FindingVerificationService.java Modified Splits MITIGATION_ASSERTED and MITIGATION_ABSENT_SUBJECT into three patterns each and re-implements their one-pass semantics via leftmost-match walks.
src/test/java/dev/thiagogonzaga/thrillhousebot/dashboard/AuthResourceTestFixtures.java Modified Extracts inline mock() calls inside thenReturn() into local variables per java:S9016.
src/test/java/dev/thiagogonzaga/thrillhousebot/github/GitHubApiErrorTest.java Modified Adds two tests pinning one-pass leftmost-match redaction of overlapping token/bearer credential shapes.
src/test/java/dev/thiagogonzaga/thrillhousebot/review/BlockingStrictnessTest.java Modified Replaces assertTrue(a == b) with assertEquals(expected, actual) per java:S5785.
src/test/java/dev/thiagogonzaga/thrillhousebot/review/ai/FindingVerificationServiceTest.java Modified Updates test comments to the renamed MITIGATION_ASSERTED_* patterns; no behavioral test changes.

Risk Assessment

Risk Count
🔴 Critical 0
🟠 High 0
🟡 Medium 1
🔵 Low 0

Key Findings

  • MEDIUM: claimsAbsenceAsSubject does O(n) substring+matcher work per verb token (O(k·n) worst case) (src/main/java/dev/thiagogonzaga/thrillhousebot/review/ai/FindingVerificationService.java:789)

⚠️ Required CI Checks Status

Some required checks are still pending or have failed:

Check Type Status Detail
frontend check-run ⏳ Pending -
format check-run ⏳ Pending -
test check-run ⏳ Pending -
trivy check-run ⏳ Pending -
dependency-review check-run ⏳ Pending -

Automated review by ThrillhouseBot. Reply with /review to re-run.

@thrillhousebot thrillhousebot Bot added java Pull requests that update java code tech-debt testing Test coverage and test quality labels Aug 13, 2026

@thrillhousebot thrillhousebot 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.

ThrillhouseBot found no issues in this PR, but some checks are still pending or failed:

  • Check trivy is pending
  • Check test is pending
  • Check format is pending
  • Check frontend is pending
  • Check dependency-review is pending

Additionally, No new issues in this revision, but 1 previous finding(s) remain unresolved — fix them, or reply on their review thread with why they are deferred. A finding listed only under "Things to double-check" has no thread: clear it by commenting @thrillhousebot resolved path/to/File.java:42 — <the finding's title> on this PR.

devops-thiago added a commit that referenced this pull request Aug 13, 2026
…efeaters

Rebased onto the #703 split shapes. DEFENSE_OBJECT_AFTER_VERB gains the
parameteriz stem the verb group already had and accepts clause-break
punctuation (semicolon, colon, dashes) as a separator, so "Nothing
escapes parameterization" and "Nothing escapes; the sanitizer runs on
render" read as the mitigations they assert instead of over-firing the
floor; the comma is deliberately excluded so comma-coordinated absence
verbs and appositive denials stay absence claims, and the denied
defense across a clause break is documented as accepted residual
under-fire. A new ABSENCE_MODAL_VERB token registers modal absence
claims ("Nothing can sanitize the value", one non-negator adverb
admitted), MITIGATION_DO_SUPPORTED admits one non-negator gap word so
"does always escape" defeats the floor while "does not escape" stays an
absence claim, and MITIGATION_ASSERTED_SUBJECT excludes coordinators
from its subject slot so "Nothing escapes, sanitizes, or validates the
value" does not read its own continuation as a mitigation.

Closes #696
@thrillhousebot

Copy link
Copy Markdown
Contributor

🤖 ThrillhouseBot — changes since the last review

  • New findings this round: 1
  • Previous findings resolved: 1
  • Previous findings still open: 0

devops-thiago added a commit that referenced this pull request Aug 13, 2026
…efeaters

Rebased onto the #703 split shapes. DEFENSE_OBJECT_AFTER_VERB gains the
parameteriz stem the verb group already had and accepts clause-break
punctuation (semicolon, colon, dashes) as a separator, so "Nothing
escapes parameterization" and "Nothing escapes; the sanitizer runs on
render" read as the mitigations they assert instead of over-firing the
floor; the comma is deliberately excluded so comma-coordinated absence
verbs and appositive denials stay absence claims, and the denied
defense across a clause break is documented as accepted residual
under-fire. A new ABSENCE_MODAL_VERB token registers modal absence
claims ("Nothing can sanitize the value", one non-negator adverb
admitted), MITIGATION_DO_SUPPORTED admits one non-negator gap word so
"does always escape" defeats the floor while "does not escape" stays an
absence claim, and MITIGATION_ASSERTED_SUBJECT excludes coordinators
from its subject slot so "Nothing escapes, sanitizes, or validates the
value" does not read its own continuation as a mitigation.

Closes #696
@thrillhousebot

Copy link
Copy Markdown
Contributor

🤖 ThrillhouseBot — changes since the last review

  • New findings this round: 1
  • Previous findings resolved: 1
  • Previous findings still open: 0

Comment thread src/main/java/dev/thiagogonzaga/thrillhousebot/github/GitHubApiError.java Outdated

@thrillhousebot thrillhousebot 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.

ThrillhouseBot found no issues in this PR, but some checks are still pending or failed:

  • Check format is pending
  • Check test is pending
  • Check frontend is pending
  • Check trivy is pending
  • Check dependency-review is pending

Additionally, No new issues in this revision, but 1 previous finding(s) remain unresolved — fix them, or reply on their review thread with why they are deferred. A finding listed only under "Things to double-check" has no thread: clear it by commenting @thrillhousebot resolved path/to/File.java:42 — <the finding's title> on this PR.

@sonarqubecloud

Copy link
Copy Markdown

@thrillhousebot

Copy link
Copy Markdown
Contributor

🤖 ThrillhouseBot — changes since the last review

  • New findings this round: 0
  • Previous findings resolved: 1
  • Previous findings still open: 0

@thrillhousebot thrillhousebot 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.

ThrillhouseBot found no issues in this PR, but some checks are still pending or failed:

  • Check test is pending

@devops-thiago
devops-thiago merged commit cbfb862 into main Aug 13, 2026
17 checks passed
@devops-thiago
devops-thiago deleted the refactor/sonar-new-code-smells branch August 13, 2026 21:17
devops-thiago added a commit that referenced this pull request Aug 13, 2026
…efeaters

Rebased onto the #703 split shapes. DEFENSE_OBJECT_AFTER_VERB gains the
parameteriz stem the verb group already had and accepts clause-break
punctuation (semicolon, colon, dashes) as a separator, so "Nothing
escapes parameterization" and "Nothing escapes; the sanitizer runs on
render" read as the mitigations they assert instead of over-firing the
floor; the comma is deliberately excluded so comma-coordinated absence
verbs and appositive denials stay absence claims, and the denied
defense across a clause break is documented as accepted residual
under-fire. A new ABSENCE_MODAL_VERB token registers modal absence
claims ("Nothing can sanitize the value", one non-negator adverb
admitted), MITIGATION_DO_SUPPORTED admits one non-negator gap word so
"does always escape" defeats the floor while "does not escape" stays an
absence claim, and MITIGATION_ASSERTED_SUBJECT excludes coordinators
from its subject slot so "Nothing escapes, sanitizes, or validates the
value" does not read its own continuation as a mitigation.

Closes #696
devops-thiago added a commit that referenced this pull request Aug 13, 2026
…efeaters

Rebased onto the #703 split shapes. DEFENSE_OBJECT_AFTER_VERB gains the
parameteriz stem the verb group already had and accepts clause-break
punctuation (semicolon, colon, dashes) as a separator, so "Nothing
escapes parameterization" and "Nothing escapes; the sanitizer runs on
render" read as the mitigations they assert instead of over-firing the
floor; the comma is deliberately excluded so comma-coordinated absence
verbs and appositive denials stay absence claims, and the denied
defense across a clause break is documented as accepted residual
under-fire. A new ABSENCE_MODAL_VERB token registers modal absence
claims ("Nothing can sanitize the value", one non-negator adverb
admitted), MITIGATION_DO_SUPPORTED admits one non-negator gap word so
"does always escape" defeats the floor while "does not escape" stays an
absence claim, and MITIGATION_ASSERTED_SUBJECT excludes coordinators
from its subject slot so "Nothing escapes, sanitizes, or validates the
value" does not read its own continuation as a mitigation.

Closes #696
devops-thiago added a commit that referenced this pull request Aug 14, 2026
…efeaters (#701)

## What type of PR is this?

- [x] 🐛 Bug fix

## Description

Closes the four residual gaps in the injection-sink floor's defeater
patterns in `FindingVerificationService` that survived the #676/#685
hardening:

1. **`parameteriz` added to `DEFENSE_OBJECT_AFTER_VERB`'s defense
stems** — "Nothing escapes parameterization before the query runs" is
the mitigation it asserts and no longer over-fires the floor.
2. **Modal absence claims register** — a new `ABSENCE_MODAL_VERB` token
reads "Nothing can sanitize the value" as the absence claim it is (one
non-negator adverb admitted, sharing the finite wording's subject
prefix), with the same defense-noun-object rejection so "nothing can
escape validation" stays a mitigation.
3. **`MITIGATION_DO_SUPPORTED` admits one non-negator gap word** — "the
framework does always escape the value" now defeats the floor, while
"does not escape" stays an absence claim via the negator lookahead.
4. **Punctuation separators, decided deliberately: widened for clause
breaks only** — `DEFENSE_OBJECT_AFTER_VERB`'s separator accepts
clause-break punctuation (`;` `:` and dashes), so "Nothing escapes; the
sanitizer runs on render" reads as mitigated. The comma and
sentence-ending punctuation are deliberately excluded: comma-coordinated
absence verbs ("Nothing escapes, sanitizes, or validates the value") and
appositive denials ("Nothing escapes, but the sanitizer is disabled")
stay absence claims, and a defense noun in the NEXT sentence cannot
defuse this sentence's claim — all tested. The denied defense across a
clause break is documented in the javadoc as accepted residual
under-fire. As part of the coordination case,
`MITIGATION_ASSERTED_SUBJECT` excludes coordinators from its subject
slot so "or validates" is not read as a subject-verb mitigation.

Over-fire was the dangerous direction; items 1, 3, 4 stop flooring
mitigated findings, and item 2's under-fire fix carries its own
over-fire guard.

## Related Issues

Closes #696

## How Has This Been Tested?

- [x] Unit tests

Eleven new tests in `FindingVerificationServiceTest` cover every
acceptance criterion plus the over-fire guards (modal defense-noun
object, negated do-support, next-sentence defense noun). Full `./mvnw
verify` clean locally.

## Checklist

- [x] My code follows the project's coding standards
- [x] I have performed a self-review of my own code
- [x] I have added tests that prove my fix is effective or that my
feature works
- [x] New and existing unit tests pass locally with my changes
- [x] I have updated the documentation accordingly
- [x] My changes generate no new warnings or errors

## Screenshots / Logs

N/A

## Additional Notes

Each pattern's javadoc is updated to stay accurate, and the CHANGELOG
gains an `[Unreleased]` Fixed entry. **Depends on #703**: this branch is
rebased onto `refactor/sonar-new-code-smells` and expresses the semantic
changes in that PR's split pattern shapes (which is also what keeps each
pattern under the S5843 complexity budget). Kept as draft until #703
merges; it will then be rebased onto main.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

java Pull requests that update java code tech-debt testing Test coverage and test quality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant