FP on squid:S1481 when using nested Streams

Unused variable warning when using variable within nested streams.

Sonar Version:

  • SonarLint IntelliJ, Java 8

Minimum code example:

public void example() {
        final MutableInt count = new MutableInt(1);
        Stream.empty().forEach(item -> {
                .forEach(batch -> {
                    log.debug("Processing batch: {}", count.getAndIncrement());


This is a tricky one as it is a subtle variation (on another rule) of this one : https://jira.sonarsource.com/browse/SONARJAVA-2084

There is not a lot to be done on your side besides mark the issue as false positive.

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