S1168 FP Best practice Spring Batch raise a Return an empty collection instead of null

java
(Philippart S) #1

versions used : SonarQube : 5.6.1, Java Language

The above code raise a Return an empty collection instead of null. but it’s a best practice from Spring team : https://docs.spring.io/spring-batch/4.0.x/api/org/springframework/batch/item/ItemProcessor.html

@Override
    public List<EnrichedDSNLine> process(List<DSNLine> dsnLines) {
        if (dsnLines.isEmpty()) {
            log.warn("process launched but no input lines...'");
            return null;
      }
   }
(Philippart S) #2

Hi,

Anybody have an idea ?

Thanks,

Stef

(G Ann Campbell) #3

Hi Stef,

The current version of SonarQube is 7.7, and the current LTS is 6.7.6. You’re going to have a hard time finding support for versions older than those. You should upgrade at your earliest convenience.

 
Ann

(Philippart S) #5

Thanks for your answer, I try to update to the last LTS version but the RPM repo doesn’t have the 6.76.
I use this repo : http://downloads.sourceforge.net/project/sonar-pkg/rpm.

Did you know if the RPM repo change ?

(G Ann Campbell) #6

Hi,

IIRC, the RPM repo was somebody’s side project. Official download is here: https://www.sonarqube.org/downloads/

 
Ann

(Philippart S) #7

Hello,
I finally upgrage my sonarqube version : 6.7.7 LTS and I have always the false positive.
Is there a way that the issue will not appear in SpringBatch context ?

Regards.

Stephane

(Tibor Blenessy) #9

hello @philippart-s,

you are right that there should be an exception for the implementations of this interface, I created the ticket to improve the rule https://jira.sonarsource.com/browse/SONARJAVA-3101