How to refactor what is reported by S6517?

About the S6517 rule. I have a problem with spring repository intreface and this rule. check out the example:

interface MyRepositoryInterface : JpaRepository<MyEntityBean, UUID>, 
  JpaSpecificationExecutor<MyEntityBean> {
     fun findSomethind(uuid: UUID, personUuid: UUID): Optional<MyEntityBean>

The only solution I find is to remove the interface by abstract class. Is there another solution?

1 Like

I think S6517 has false positive detection for JPA or Spring JPA.
Because JpaRepository or CrudRepository has multiple functions.
So the interface that implmented them cannot convert to SAM.

If I change to functional interface, Kotlin compiler say compile error.

Fun interfaces must have exactly one abstract method

This rule released by SonarKotlin 2.14 with SONARKT-290

Yes, is a false positive but the sonarcloud pipelines file marks it as smell code

Hello Andres,

Thanks for reporting this issue. Indeed, this is a false positive, I’ve opened a ticket for it.

You can mark the finding as false positive in the SonarCloud UI and it should not affect your quality gate. If the rule is too noisy you can disable it as a temporary workaround, until we ship a fix.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.