Skip to content

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

Draft
romainbrenguier wants to merge 1 commit into
romain/ap-1498from
romain/ap-1498-ruling-diff-test
Draft

romainbrenguier wants to merge 1 commit into
romain/ap-1498from
romain/ap-1498-ruling-diff-test

Conversation

@romainbrenguier

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.

@gitar-bot

gitar-bot Bot commented Nov 20, 2026 •

Copy link
Copy Markdown
CI failed: Two test failures are attributed to this PR, which suppresses System.out/System.err findings: JavaRulingTest shows ruling differences and the Plugin QA test no longer finds java:S106. The ruling update job failed separately on a checkout SHA mismatch that the analyzer did not link to the PR, and the diff-generation job's log shows no failing step.

Overview

Two test failures are attributed to this PR, which suppresses System.out/System.err findings: JavaRulingTest shows ruling differences and the Plugin QA test no longer finds java:S106. The ruling update job failed separately on a checkout SHA mismatch that the analyzer did not link to the PR, and the diff-generation job's log shows no failing step.

Failures

JavaRulingTest fails with issue differences in five ruling projects

  • Type: test
  • Affected jobs: 136416060974
  • Related to change: yes
  • Confidence: high
  • Root cause: JavaRulingTest fails in spring_mall (1 issue difference), jboss_ejb3_tutorial (302), guava (3), eclipse_jetty_incremental (30), and apache_commons_beanutils (2). The supplied diff changes SystemOutOrErrUsageCheck to report only when isIoPrintFunction is true and removes the corresponding System.out/System.err expectations from the sample, changing the rule’s findings against existing ruling baselines. This directly explains the ruling differences; the token-refresh warning in the log is non-fatal.
  • Suggested fix: If suppressing these findings is intentional, update the affected ruling baselines to match the new analysis results. Otherwise, retain the previous rule behavior so the current baselines continue to pass.

Plugin QA SonarLintIntegrationTest.simpleJava no longer finds java:S106

  • Type: test
  • Affected jobs: 136416060922
  • Related to change: yes
  • Confidence: high
  • Root cause: At SonarLintIntegrationTest.simpleJava:81, the actual issues include java:S1220 and java:S1481, but not the expected java:S106. The PR explicitly disables System output findings: it changes SystemOutOrErrUsageCheck and removes the corresponding noncompliant expectations from its sample. This explains why the integration test's S106 expectation is no longer met.
  • Suggested fix: Align the integration test with the intended behavior: if disabling System output findings is deliberate, update SonarLintIntegrationTest.simpleJava to stop expecting java:S106; if the check should still report S106 in that scenario, preserve the rule behavior and scope the suppression to the ruling-diff test instead.

Ruling update job fails on PR head SHA checkout mismatch

  • Type: configuration
  • Affected jobs: 136424717004, 136426166628
  • Related to change: no
  • Confidence: high
  • Root cause: The commit-ruling-update action rejected the checkout: it expected PR head SHA 156ca76a27fec88fd04ea29d111fb69f9c20e2ab, but the checked-out revision differed. The earlier ruling QA failure triggered the update attempt, but does not explain this checkout guard failure. The PR changes modify SystemOutOrErrUsageCheck and its tests; no supplied change evidence connects them to the workflow checkout configuration.
  • Suggested fix: Configure the workflow checkout to use github.event.pull_request.head.sha (the PR head), rather than the PR merge commit, before running the ruling update action.

Summary

  • Change-related failures: 2
  • Infrastructure/flaky failures: 0
  • Recommended action: If suppressing these findings is intentional, update the affected ruling baselines to match the new analysis results. Otherwise, retain the previous rule behavior so the current baselines continue to pass.
Code Review ⚠️ Changes requested 🟡 Medium risk 0 closed / 1 findings

Disabling S106 findings for System.out and System.err removes detection of these usages, potentially allowing them to pass analysis unnoticed.

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 2/2 met Knowledge 🔎 3 Repos 5 inspected · PRs 3 inspected

Functional validation No results

Rules 2 passed 2 not applicable

✅ Internal artifact registries
✅ 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

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.");
}
}

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.");
  }
}
  • Apply fix

Check the box to apply the fix or reply for a change | Was this helpful? React with 👍 / 👎

@sonarqube-next

Copy link
Copy Markdown
Contributor

@datadog-sonarsource

datadog-sonarsource Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

Pipelines

⚠️ Warnings

Your PR has warnings. Please review the issues below.

🚦 4 Pipeline jobs failed

Build | Plugin QA (LATEST_RELEASE, false) — 🔧 Needs a code fix, caused by this PR

View more details · View in GitHub Actions

Build | Ruling QA (warp-custom-windows-2022-l, without-sonarqube-project, LATEST_RELEASE) — 🔧 Needs a code fix, caused by this PR

View more details · View in GitHub Actions

Build | Ruling QA (warp-custom-ubuntu-24-04, without-sonarqube-project, LATEST_RELEASE)

View more details · View in GitHub Actions

View all 4 failed jobs.

Useful? React with 👍 / 👎

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 156ca76 | Docs | View more details | Give us feedback!

This branch has not been deployed

No deployments
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