Skip to content

[TEST ONLY][DO NOT MERGE] AP-1498 Exercise ruling diff action - #6551

Closed
romainbrenguier wants to merge 2 commits into
romain/ap-1498from
romain/ap-1498-ruling-diff-test
Closed

romainbrenguier wants to merge 2 commits into
romain/ap-1498from
romain/ap-1498-ruling-diff-test

Conversation

@romainbrenguier

@romainbrenguier romainbrenguier commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

TEST ONLY — DO NOT MERGE

This draft PR is stacked on #6550 solely to exercise the ruling diff action. The commit intentionally stops rule S106 from reporting System.out and System.err usages, causing a large ruling diff. This behavior is a deliberate test regression and must not be shipped.

The IO.print and IO.println behavior remains active. Unit test expectations were updated so the ruling workflow can run against the intentional S106 change.

Verification: targeted SystemOutOrErrUsageCheckTest passed; deep Vortex analysis found no issues in the three changed files.

Agent workflow

Tool link: https://github.com/SonarSource/languages-experimental-tooling/tree/romain/my-tickets/personal/romain-brenguier
Addressed review comments in pr_report_6551.md using uv run address_reviews.py pr_report_6551.md

Comment on lines 52 to 56
private void visitMemberSelectExpression(MemberSelectExpressionTree mset) {
String name = mset.identifier().name();
if ("out".equals(name) && isSystem(mset.expression())) {
reportIssue(mset, "Replace this use of System.out by a logger.");
} else if ("err".equals(name) && isSystem(mset.expression())) {
reportIssue(mset, "Replace this use of System.err by a logger.");
} else if (isIoPrintFunction(mset)) {
if (isIoPrintFunction(mset)) {
reportIssue(mset, "Replace this use of IO." + mset.identifier().name() + " by a logger.");
}
}

@gitar-bot gitar-bot Bot Nov 20, 2026 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Bug: S106 no longer reports System.out/err, breaking downstream SonarLint ITs

visitMemberSelectExpression now reports only when isIoPrintFunction(mset) is true, so every System.out/System.err usage, which is the core of rule S106, goes silent. The sample file and verifyNoIssues() tests were changed to match. The PR says this is a deliberate, do-not-merge regression. Even so, it should not land on romain/ap-1498 or anything downstream. Several SonarLint consumers depend on S106 firing on plain System.out: sonarlint-eclipse connected-mode ITs such as OpenInIdeTest that call getFirstIssue(S106) on SysOut.java; the sonarlint-vscode java diagnostics IT, which expects 'Replace this use of System.out by a logger.'; and sonarlint-intellij StandaloneModeMediumTests.should_analyze_java_file, which expects java:S106 on src/Main.java. All of these would fail once they bump to a sonar-java release that contains this commit. Close this PR, or revert commit 156ca76, once the ruling diff action has been exercised, and keep it out of the #6550 stack before that merges.

Restore the original System.out/System.err reporting branch alongside the IO.print branch:

private void visitMemberSelectExpression(MemberSelectExpressionTree mset) {
  if (isIoPrintFunction(mset)) {
    reportIssue(mset, "Replace this use of IO." + mset.identifier().name() + " by a logger.");
    return;
  }
  String name = mset.identifier().name();
  if (("out".equals(name) || "err".equals(name)) && isSystem(mset.expression())) {
    reportIssue(mset, "Replace this use of System." + name + " by a logger.");
  }
}

Was this helpful? React with 👍 / 👎

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Agreed that this behavior must not ship. PR #6551 is a draft test branch created solely to produce an S106 ruling diff; the production branch (#6550) retains normal System.out/System.err reporting. I fixed the separate PR-head checkout failure and will close this test PR after the ruling diff action runs.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Understood. The finding holds on this branch (SystemOutOrErrUsageCheck only reports when isIoPrintFunction(mset) is true), and you've confirmed it's intentional for this throwaway ruling-diff PR. I've recorded it as won't fix and made no code changes. Just make sure #6551 is closed rather than merged, so it doesn't reach #6550 or any SonarLint consumers.

@datadog-sonarsource

This comment has been minimized.

@gitar-bot

gitar-bot Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
CI failed: Ruling-diff tests fail in five projects and the Plugin QA simpleJava test no longer sees java:S106, both attributed to the PR's SystemOutOrErrUsageCheck change which now suppresses System output findings without updated baselines or expectations. The truncated log for template_0000000000000001 shows no explicit error, so its failure cause remains unidentified and it is not attributed to the change.

Overview

Ruling-diff tests fail in five projects and the Plugin QA simpleJava test no longer sees java:S106, both attributed to the PR's SystemOutOrErrUsageCheck change which now suppresses System output findings without updated baselines or expectations. The truncated log for template_0000000000000001 shows no explicit error, so its failure cause remains unidentified and it is not attributed to the change.

Failures

JavaRulingTest ruling diffs in five projects (spring_mall, jboss_ejb3_tutorial, guava, eclipse_jetty_incremental, apache_commons_beanutils)

  • Type: test
  • Affected jobs: 138453096428
  • Related to change: yes
  • Confidence: high
  • Root cause: Each failure is an assertion that the ruling diff is empty (JavaRulingTest.assertNoDifferences, line 569). The PR changes SystemOutOrErrUsageCheck and its fixture/tests to stop reporting the System output findings; the ruling baselines were not updated, so changed analysis results produce diffs. The log does not show individual issue details, so it cannot establish that every difference is exclusively from this check.
  • Suggested fix: If removing these findings is intended, update the affected ruling expectations and verify the generated diffs. If the PR is only meant to exercise the ruling-diff action, retain the intentional failing comparisons for that exercise or configure the test accordingly; otherwise preserve the check's prior behavior.

Plugin QA SonarLintIntegrationTest.simpleJava missing expected java:S106 issue

  • Type: test
  • Affected jobs: 138453096318
  • Related to change: yes
  • Confidence: high
  • Root cause: At its/plugin/tests, SonarLintIntegrationTest.simpleJava (line 81) expected java:S106, java:S1220, and java:S1481, but the analysis returned only java:S1220 and java:S1481. This is explained by the PR change: SystemOutOrErrUsageCheck was altered to disable the System output finding, and its sample and unit tests were updated to expect no issues. The integration test still expects java:S106, so its expectation is stale relative to the changed rule behavior.
  • Suggested fix: If disabling java:S106 is intended, update SonarLintIntegrationTest.simpleJava to stop expecting that issue. If the integration test should continue to report java:S106, restore the rule behavior that emits it.

Summary

  • Change-related failures: 2
  • Infrastructure/flaky failures: 0
  • Recommended action: If removing these findings is intended, update the affected ruling expectations and verify the generated diffs. If the PR is only meant to exercise the ruling-diff action, retain the intentional failing comparisons for that exercise or configure the test accordingly; otherwise preserve the check's prior behavior.
Code Review ⚠️ Changes requested 🟡 Medium risk 0 closed / 1 findings

Removing S106 reports for System.out/System.err changes analyzer behavior; projects may miss console-output findings that previously prompted logger use.

Disables S106 reporting for System.out and System.err by restricting SystemOutOrErrUsageCheck to IO.print/IO.println, with updated unit test expectations; this is an intentional test regression for the ruling diff action. One open important finding: this silences S106 on core usages, which would break downstream SonarLint integration tests once they consume this commit, so the PR should be closed or commit 156ca76 reverted before anything is merged.

⚠️ Bug: S106 no longer reports System.out/err, breaking downstream SonarLint ITs

📄 java-checks/src/main/java/org/sonar/java/checks/SystemOutOrErrUsageCheck.java:52-56 📄 java-checks/src/test/java/org/sonar/java/checks/SystemOutOrErrUsageCheckTest.java:31 📄 java-checks/src/test/java/org/sonar/java/checks/SystemOutOrErrUsageCheckTest.java:72 📄 java-checks-test-sources/default/src/main/java/checks/SystemOutOrErrUsageCheckSample.java:8-18

visitMemberSelectExpression now reports only when isIoPrintFunction(mset) is true, so every System.out/System.err usage, which is the core of rule S106, goes silent. The sample file and verifyNoIssues() tests were changed to match. The PR says this is a deliberate, do-not-merge regression. Even so, it should not land on romain/ap-1498 or anything downstream. Several SonarLint consumers depend on S106 firing on plain System.out: sonarlint-eclipse connected-mode ITs such as OpenInIdeTest that call getFirstIssue(S106) on SysOut.java; the sonarlint-vscode java diagnostics IT, which expects 'Replace this use of System.out by a logger.'; and sonarlint-intellij StandaloneModeMediumTests.should_analyze_java_file, which expects java:S106 on src/Main.java. All of these would fail once they bump to a sonar-java release that contains this commit. Close this PR, or revert commit 156ca76, once the ruling diff action has been exercised, and keep it out of the #6550 stack before that merges.

Restore the original System.out/System.err reporting branch alongside the IO.print branch
private void visitMemberSelectExpression(MemberSelectExpressionTree mset) {
  if (isIoPrintFunction(mset)) {
    reportIssue(mset, "Replace this use of IO." + mset.identifier().name() + " by a logger.");
    return;
  }
  String name = mset.identifier().name();
  if (("out".equals(name) || "err".equals(name)) && isSystem(mset.expression())) {
    reportIssue(mset, "Replace this use of System." + name + " by a logger.");
  }
}
🤖 Prompt for agents
Code Review: Disables S106 reporting for `System.out` and `System.err` by restricting `SystemOutOrErrUsageCheck` to `IO.print`/`IO.println`, with updated unit test expectations; this is an intentional test regression for the ruling diff action. One open important finding: this silences S106 on core usages, which would break downstream SonarLint integration tests once they consume this commit, so the PR should be closed or commit 156ca76 reverted before anything is merged.

1. ⚠️ Bug: S106 no longer reports System.out/err, breaking downstream SonarLint ITs
   Files: java-checks/src/main/java/org/sonar/java/checks/SystemOutOrErrUsageCheck.java:52-56, java-checks/src/test/java/org/sonar/java/checks/SystemOutOrErrUsageCheckTest.java:31, java-checks/src/test/java/org/sonar/java/checks/SystemOutOrErrUsageCheckTest.java:72, java-checks-test-sources/default/src/main/java/checks/SystemOutOrErrUsageCheckSample.java:8-18

   `visitMemberSelectExpression` now reports only when `isIoPrintFunction(mset)` is true, so every `System.out`/`System.err` usage, which is the core of rule S106, goes silent. The sample file and `verifyNoIssues()` tests were changed to match. The PR says this is a deliberate, do-not-merge regression. Even so, it should not land on `romain/ap-1498` or anything downstream. Several SonarLint consumers depend on S106 firing on plain `System.out`: sonarlint-eclipse [connected-mode ITs](https://github.com/SonarSource/sonar-java/pull/6550) such as `OpenInIdeTest` that call `getFirstIssue(S106)` on `SysOut.java`; the sonarlint-vscode [java diagnostics IT](https://github.com/SonarSource/sonar-java/pull/6550), which expects 'Replace this use of System.out by a logger.'; and sonarlint-intellij [StandaloneModeMediumTests.should_analyze_java_file](https://github.com/SonarSource/sonar-java/pull/6550), which expects `java:S106` on `src/Main.java`. All of these would fail once they bump to a sonar-java release that contains this commit. Close this PR, or revert commit 156ca76, once the ruling diff action has been exercised, and keep it out of the #6550 stack before that merges.

   Fix (Restore the original System.out/System.err reporting branch alongside the IO.print branch):
   private void visitMemberSelectExpression(MemberSelectExpressionTree mset) {
     if (isIoPrintFunction(mset)) {
       reportIssue(mset, "Replace this use of IO." + mset.identifier().name() + " by a logger.");
       return;
     }
     String name = mset.identifier().name();
     if (("out".equals(name) || "err".equals(name)) && isSystem(mset.expression())) {
       reportIssue(mset, "Replace this use of System." + name + " by a logger.");
     }
   }

Verification Rules 3/3 met Knowledge 🔎 3 Repos 5 inspected · PRs 3 inspected

Functional validation No results

Rules 3 passed 2 not applicable

✅ Internal artifact registries
✅ Release secrets usage
✅ Repository license compliance

Knowledge 🔎 3 informed a finding

🔎 java:S106 'Replace this use of System.out by a logger.': dependency with SonarSource/sonarlint-vscode informed a finding, open -> S106 no longer reports System.out/err, breaking downstream SonarLint ITs
🔎 java:S106 (SystemOutOrErrUsageCheck) reporting 'Replace this use of System.out by a logger.': dependency with SonarSource/sonarlint-intellij informed a finding, open -> S106 no longer reports System.out/err, breaking downstream SonarLint ITs
🔎 java:S106 raised on System.out usage (SysOut.java): dependency with SonarSource/sonarlint-eclipse informed a finding, open -> S106 no longer reports System.out/err, breaking downstream SonarLint ITs

Broader impact Repos 5 inspected PRs 3 inspected
Cross-repo 5 repositories inspected 0 open impacts

SonarSource/sonar-lits Inspected
SonarSource/core-languages-tooling-public Inspected
SonarSource/sonarlint-vscode Inspected
SonarSource/sonarlint-intellij Inspected
SonarSource/sonar-iac Inspected

Cross-PR 3 PRs inspected 0 open impacts

PR 6550: AP-1498: Activate AI-enhanced ruling diff reviews Inspected
PR 115: AP-1497: Add review-time survey to ruling diff comments Inspected
PR 6457: RC-354 Pin core-languages-tooling-public actions to the current master commit Inspected

Auto-approval Not enabled

Set up

For more verification details, comment gitar display:verbose.

Tip

Comment Gitar fix CI or enable auto-apply: gitar auto-apply:on

Options

Auto-apply is off → Gitar will not commit updates to this branch.
Display: compact → Showing compact verification results.
Unblock → Override a blocking verdict and allow merging.

Comment with these commands to change the behavior for this request:

Auto-apply Compact Unblock
gitar auto-apply:on         
gitar display:verbose         
gitar unblock         

Was this helpful? React with 👍 / 👎 | Gitar

@sonarqube-next

Copy link
Copy Markdown
Contributor

@romainbrenguier

Copy link
Copy Markdown
Contributor Author

The test-only S106 regression has served its purpose and must not merge. The PR-head checkout fix is on #6550 and the ruling update job now succeeds. The diff comment remained skipped because this removal-only ruling change produces no actual S106 SARIF files, while the shared artifact sync only copies files that exist; that follow-up belongs in the shared action.

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.

1 participant