From 0d86af4b0fe9ccc4f0a5bb25669ec5906a2c5ed0 Mon Sep 17 00:00:00 2001 From: George Fraser Date: Sat, 5 Jan 2019 13:32:22 -0800 Subject: Don't warn unused lambda params --- src/test/java/org/javacs/WarningsTest.java | 8 +++++--- src/test/test-project/workspace/src/org/javacs/warn/Unused.java | 6 ++++++ 2 files changed, 11 insertions(+), 3 deletions(-) (limited to 'src/test') diff --git a/src/test/java/org/javacs/WarningsTest.java b/src/test/java/org/javacs/WarningsTest.java index f9e54d4..c82c80f 100644 --- a/src/test/java/org/javacs/WarningsTest.java +++ b/src/test/java/org/javacs/WarningsTest.java @@ -31,9 +31,11 @@ public class WarningsTest { @Test public void unusedLocal() { server.reportErrors(List.of(FindResource.uri("org/javacs/warn/Unused.java"))); - assertThat(errors, hasItem("unused(5)")); // int unusedLocal - assertThat(errors, hasItem("unused(8)")); // int unusedPrivate - assertThat(errors, not(hasItem("unused(4)"))); + assertThat(errors, hasItem("unused(7)")); // int unusedLocal + assertThat(errors, hasItem("unused(10)")); // int unusedPrivate + assertThat(errors, hasItem("unused(13)")); // int unusedLocalInLambda + assertThat(errors, not(hasItem("unused(6)"))); // test(int unusedParam) + assertThat(errors, not(hasItem("unused(12)"))); // unusedLambdaParam -> {}; } // TODO warn on type.equals(otherType) diff --git a/src/test/test-project/workspace/src/org/javacs/warn/Unused.java b/src/test/test-project/workspace/src/org/javacs/warn/Unused.java index 94e04b7..7852379 100644 --- a/src/test/test-project/workspace/src/org/javacs/warn/Unused.java +++ b/src/test/test-project/workspace/src/org/javacs/warn/Unused.java @@ -1,9 +1,15 @@ package org.javacs.warn; +import java.util.function.Consumer; + class Unused { void test(int unusedParam) { int unusedLocal = 1; } private int unusedPrivate; + + Consumer lambda = unusedLambdaParam -> { + int unusedLocalInLambda; + }; } \ No newline at end of file -- cgit v1.2.3