Unexplainable warnings about encoding

  • ALM used: GitHub

  • CI system used: Jenkins

  • Scanner command used when applicable (private details masked)

    mvn -Duser.home=masked org.sonarsource.scanner.maven:sonar-maven-plugin:5.6.0.6792:sonar --batch-mode -pl masked --also-make --no-snapshot-updates -Psonar -Dsonar -Dsonar.projectName=masked -Dsonar.projectKey=masked -Dsonar.organization=masked -Dsonar.host.url=https://sonarcloud.io -Dsonar.token=masked -Dsonar.branch.name=masked -Dmaven.repo.local=masked/.m2/repository -f masked/Parent/pom.xml

  • Languages of the repository: Java,JS,TS

SonarQube Cloud UI shows such a warning for every branch/PR analyzed recently

There are problems with file encoding in the source code. Please check the scanner logs for more details.

We had a single warn that could be possibly related to this issue

[WARNING] Invalid character encountered in file …

we fixed it and after running the branch analyzing on the branch with the fix the warning is still shown.

Any clues what are other possible reasons of this warning?

I may provide redacted debug logs of the analyzing…

Hello @lrozenblyum, no need to provide logs, I’ve actually been able to reproduce it myself. I’m going to flag this for the devs to look at, right now I’m not sure if this is intended or not, or if perhaps there’s room for improving the clarity of the warning. Thanks for sharing this!

Hello,

I can confirm this is not the intended behavior, and we’ve created a ticket to tackle it.
Analysis warnings should be branch aware.

Hello @Stan does your comment imply that we should promote the fix for the warning `[WARNING] Invalid character encountered in file …

to our main branch and then the UI warning about encoding will disappear or they’re unrelated?

I can confirm @Stan that after we promoted the fix for the warning [WARNING] Invalid character encountered in file … to the main branch and it has been analyzed, in other branches is also disappears after they’re reanalyzed.

Hey @lrozenblyum, indeed what you just described is part of the unintended behavior that we are fixing: the warnings from the main branch are shown on other branches/PRs too. The moment you got rid of the warning on the main branch, it also doesn’t pop up on other branches.

Hey @lrozenblyum, I just checked and the fix is already live, so I suspect that what you saw (fixing the warning in main > warning also disappeared on other branches) might have been caused by other branches rebasing/merging main and being analyzed again. Could you please double-check if it really is unintended that the warning no longer shows up on the other branches? Could you try, for example, reverting your fix for the warning in a branch and seeing if the warning pops up in that branch correctly?

I’ve created a branch from the main branch where I reverted the fix, and analyzed it.
SonarQube Cloud shows proper warning for this branch with the issue. Main branch is shown without warnings.

So I guess it’s fine @andres