java:S113 Rule Not Triggered on Merge Request but Fails on Master Branch

Environment

  • SonarQube Version: Developer Edition - Version 9.9.2 (build 77730)
  • Plugin Version: org.sonarqube: 4.3.1.3277

Issue

The java:S113 rule (requirement for an empty line at the end of a file) is not being triggered at the merge request level in my project. When I create a merge request that includes changes to a Java class without an empty line at the end, SonarQube shows a green status, indicating no issues. However, once the merge request is pushed to the master branch, SonarQube fails due to this rule.

Goal

I am trying to ensure that the java:S113 rule is consistently applied at both the merge request and master branch levels.

Attempts

  • I have confirmed that the rule java:S113 is active in my SonarQube quality profile.
  • Reviewed SonarQube logs for any errors or warnings related to this rule (no significant findings).
  • Checked the SonarQube configuration for any discrepancies between merge request and master branch settings.
  • Recreated the project in sonarqube
  • Introduced on purpose other issues on same file. These issues where caught as expected.

How is SonarQube deployed

  • Docker using Kubernetes

Warnings

  • Shallow clone detected during the analysis. Some files will miss SCM information. This will affect features like auto-assignment of issues. Please configure your build to disable shallow clone.
  • Missing blame information for 1 file. This may lead to some features not working correctly. Please check the analysis logs and refer to the documentation.
  • No devops platform configured. To report the Quality Gate status to a devops platform, please configure it in the project administration.

Hey there.

I would expect this rule would work on new files, but for existing files, only issues on changed lines of changed files will be raised, which means this issue won’t be raised until a full branch analysis.

There’s an item on our roadmap to solve cases like this: New Pull Request issues on unchanged code. I suggest voting for it!

Hello, thanks for replying, but the issue with the empty line appears on a new file of the branch. Forgot to mention it before.

Hey there.

It looks like I misunderstood how this rule reports issues – it reports file level issues, which are not raised on pull requests (new file or not).

As noted before: