Bitbucket pipelines started failing after todays updates in "Sonar way" quality profiles

Today all our Bitbucket pipelines started failing due to Sonar.
We run builds on some old branches and they started failing also.
We can see that global “Sonar way” quality profile rules were updated today, therefore we suspect this error is due to some updates made in Sonar today.

Caused by: org.sonar.java.AnalysisException: SonarQube is unable to analyze file : 'platform/backend-service/src/main/java/net/sympower/platform/backend/service/data/model/AnalogWireLevelType.java'
at org.sonar.java.ast.JavaAstScanner.simpleScan(JavaAstScanner.java:108)


Caused by: java.lang.ArrayIndexOutOfBoundsException: -1
at org.sonar.java.checks.RedundantTypeCastCheck.targetTypeFromMethodSymbol(RedundantTypeCastCheck.java:140)

Hi @Fred_Puistaja and welcome to the community !

We deployed an update to our Java analyzer today, and that included the following ticket: https://jira.sonarsource.com/browse/MMF-1651 where we dropped support for importing the jacoco.exec coverage reports.

The following reason is given:

We know that the .exec file is not an exchange format. This is an internal format used by JaCoCo developers. It is not at all recommended to use it for integration purpose.
Because of that, we want to get rid of the support of the .exec file format and rely only on the XML one.

This feature has been deprecated for quite some time, and warnings should have been reported in the SonarCloud UI.

Switching to the Jacoco XML format should fix your issues.

Mickaël

We are not using Jacoco.

Hi @Fred_Puistaja,

Would it be possible to share the code in service/src/main/java/net/sympower/platform/backend/service/data/model/AnalogWireLevelType.java so that we can reproduce this error? You can share it through a private message if it contains sensitive information.

Thanks,
Tom

1 Like
package net.sympower.platform.backend.service.data.model;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;

@AllArgsConstructor
public enum AnalogWireLevelType {

  LEVEL_TYPE_VOLTS((byte) 1),
  LEVEL_TYPE_MILLI_AMPERES((byte) 2);

  @Getter private byte value;

  public static AnalogWireLevelType getLevel(Byte value) {
    return Arrays.stream(values())
      .filter(levelType -> ((Byte) levelType.value).equals(value))
      .findFirst()
      .orElseThrow(() -> new IllegalArgumentException("Unknown type: " + value));
  }
}
2 Likes

Thanks, I was able to reproduce the error. I will follow-up once we found the cause.

2 Likes

Hi, we have a similar failure since today.
The file with the problem also uses

  1. lombok @AllArgsConstructor
  2. is enum
  3. has byte field initialized in enum values constructors.
1 Like

Workaround found: removing @AllArgsConstructor (replacing it by an explicit private constructor) solves the issue

3 Likes

Hello @lrozenblyum & @Fred_Puistaja,

We are working currently working on a fix and will deploy the changes as soon as possible.

2 Likes

Hey @Fred_Puistaja & @lrozenblyum,

Thanks a lot for your pretty accurate feedback, and thanks @TomVanBraband for the follow up. Fix is on it’s way in our SonarJava master. This is due to a case we missed during our migration to our new frontend. I created the following ticket to describe the issue: SONARJAVA-3269

We are going to release a bugfix version of SonarJava (6.0.1) between today and Monday to fix the issue. The bugfix version will be deployed on SonarCloud just after the release.

Cheers,
Michael

1 Like

SonarJava 6.0.1 hasn’t been released yet?

Hi @Fred_Puistaja,

SonarJava 6.0.1 is not available yet on SonarCloud, but it will be soon.
I will update you in this thread when it is available.

@Fred_Puistaja @lrozenblyum

SonarJava 6.0.1 is now available on SonarCloud!

1 Like

Thanks @TomVanBraband! I confirm the fix works for us.

2 Likes