# False negative java:S3626: a redundant return inside a lambda body is not reported

**URL:** <https://community.sonarsource.com/t/false-negative-java-a-redundant-return-inside-a-lambda-body-is-not-reported/190777>\
**Category:** Report False-positive / False-negative...\
**Tags:** java\
**Created:** [November 1, 2026, 3:34pm UTC](https://community.sonarsource.com/t/false-negative-java-a-redundant-return-inside-a-lambda-body-is-not-reported/190777 "2026-11-01T15:34:58Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![MarkLee131](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/marklee131/32/77010_2.png) [@MarkLee131](https://community.sonarsource.com/u/MarkLee131)\
**Post date:** [November 1, 2026, 3:34pm UTC](https://community.sonarsource.com/t/false-negative-java-a-redundant-return-inside-a-lambda-body-is-not-reported/190777/1 "2026-11-01T15:34:58Z")

</div>

**Product/version:** SonarQube Community Build 26.9.0.129388 (sonar-java 8.41.0.47177), sonar-scanner 8.1.0.6389

**Language:** Java

**Rule:** java:S3626

**Issue:**

S3626 reports the `return;` at the end of `run(int x) { System.out.println(x); return; }`. The same two statements in a lambda that’s run right away aren’t reported, but in an anonymous `Runnable` they are (`control/WSAnonRedundantReturn.java`).

`RedundantJumpCheck` registers for `Tree.Kind.METHOD` and `CONSTRUCTOR` and walks `methodTree.cfg()`, which doesn’t include lambda bodies (a lambda has its own `cfg()`).

**Reproducer:**

`seed/WSRedundantReturn.java`:

```java
public class WSRedundantReturn {
    public void run(int x) {
        System.out.println(x);
        return;
    }
}

```

`variant/WSRedundantReturn.java`:

```java
public class WSRedundantReturn {
    public void run(int x) {
        Runnable r = () -> {
            System.out.println(x);
            return;
        };
        r.run();
    }
}

```

`control/WSAnonRedundantReturn.java`:

```java
public class WSAnonRedundantReturn {
    public void run(int x) {
        Runnable r = new Runnable() {
            public void run() {
                System.out.println(x);
                return;
            }
        };
        r.run();
    }
}

```

**Expected behavior:**

S3626 (“Remove this redundant jump.”) on the `return;` inside the lambda in `variant/WSRedundantReturn.java`, as in `seed/`.

**How to reproduce:**

```auto
# one project per file
sonar-scanner -Dsonar.projectKey=<key> -Dsonar.sources=. \
    -Dsonar.java.binaries=. -Dsonar.scm.disabled=true

```

**Output** of the commands above:

```plaintext
### SonarQube Community Build 26.9.0.129388 (sonar-java 8.41.0.47177), server reports 26.9.0.129388, default Sonar way profile rule: S3626

--- SEED -- expected: reported (seed/)
    java:S1220 line - Move this file to a named package.
    java:S106 line 3 Replace this use of System.out by a logger.
    java:S3626 line 4 Remove this redundant jump. <== S3626
    [S3626: 1]

--- VARIANT -- expected: reported; actual: not reported (variant/)
    java:S1220 line - Move this file to a named package.
    java:S106 line 4 Replace this use of System.out by a logger.
    [S3626: 0]

--- CONTROL -- the same rule on the control file, expected: reported (control/)
    java:S1220 line - Move this file to a named package.
    java:S1604 line 3 Make this anonymous inner class a lambda (sonar.java.source
    java:S9357 line 3 Make this anonymous inner class a lambda (sonar.java.source
    java:S106 line 5 Replace this use of System.out by a logger.
    java:S3626 line 6 Remove this redundant jump. <== S3626
    [S3626: 1]

```

---

<div class="post-metadata">

**Author:** ![romain.birling](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/romain.birling/32/76362_2.png) [@romain.birling](https://community.sonarsource.com/u/romain.birling)\
**Post date:** [November 2, 2026, 10:58am UTC](https://community.sonarsource.com/t/false-negative-java-a-redundant-return-inside-a-lambda-body-is-not-reported/190777/3 "2026-11-02T10:58:58Z")

</div>

Hi @MarkLee131!

Thank you for reporting this issue and providing a clear reproducer.

I have created a ticket to track it here: **[SONARJAVA-7280](https://sonarsource.atlassian.net/browse/SONARJAVA-7280)**

Thanks again for your contribution!

Romain
