Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove this unused method parameter in Sonar

Tags:

java

sonarqube

I got some trouble with a sonar issue:

Remove this unused method parameter "messageId".

well my method looks like:

private static Optional<Status> getStatus(Member member, String messageId) {
    return Optional.ofNullable(member)
            .map(Member::getTraffic)
            .map(Traffic::getSymlinks)
            .map(messages -> messages
                    .stream()
                    .filter(message -> message.getMessageId().equals(messageId))
                    .findFirst()).flatMap(message -> message.map(Message::getStatus));
}

the messageId is used inside the equals of the filter. It is no field. It is the method parameter.

Is that a sonar bug or have I overlooked something? We are using Sonar 5.6

like image 485
s_bei Avatar asked Feb 28 '18 08:02

s_bei


1 Answers

Yeah, looks like a Bug . Seems this got recently addressed in SonarJava 5.0 (compatible with SonarQube 6.7+) which got released last December

https://jira.sonarsource.com/browse/SONARJAVA-2115

like image 106
CGS Avatar answered Nov 03 '22 22:11

CGS