From 9cc8068881186f0a7a3ff9a8beb23d87e6da7692 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Fournier?= Date: Wed, 23 May 2018 19:38:06 +0200 Subject: [PATCH] Whitelist lambda parameters --- .../main/resources/category/java/codestyle.xml | 2 ++ .../java/rule/codestyle/xml/ShortVariable.xml | 15 +++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/pmd-java/src/main/resources/category/java/codestyle.xml b/pmd-java/src/main/resources/category/java/codestyle.xml index 8f1600ced7..531dd376a0 100644 --- a/pmd-java/src/main/resources/category/java/codestyle.xml +++ b/pmd-java/src/main/resources/category/java/codestyle.xml @@ -1436,6 +1436,8 @@ Fields, local variables, or parameter names that are very short are not helpful [not(../../..[self::ForStatement])] (: Catch statement parameter :) [not(../..[self::CatchStatement])] + (: Lambda expression parameter :) + [not(parent::LambdaExpression or ../../..[self::LambdaExpression])] ]]> diff --git a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/codestyle/xml/ShortVariable.xml b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/codestyle/xml/ShortVariable.xml index 5ebb0b2944..36f80055c6 100644 --- a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/codestyle/xml/ShortVariable.xml +++ b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/codestyle/xml/ShortVariable.xml @@ -130,6 +130,21 @@ public class ShortVariable { String thisIsOk = ""; String foo = ""; // that's ok, too, now } +} + ]]> + + + + #720 Whitelist lambda parameters + 1 + 0 + foo(); + String foo = (a, b) -> foo(); + String bar = (String a, Boolean b) -> foo(); + } } ]]>