Whitelist lambda parameters

This commit is contained in:
Clément Fournier
2018-05-23 19:38:06 +02:00
parent 5ecf60b73c
commit 9cc8068881
2 changed files with 17 additions and 0 deletions

View File

@ -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])]
]]>
</value>
</property>

View File

@ -130,6 +130,21 @@ public class ShortVariable {
String thisIsOk = "";
String foo = ""; // that's ok, too, now
}
}
]]></code>
</test-code>
<test-code>
<description>#720 Whitelist lambda parameters</description>
<rule-property name="minimum">1</rule-property>
<expected-problems>0</expected-problems>
<code><![CDATA[
public class ShortVariable {
public void bar() {
String thisIsOk = a -> foo();
String foo = (a, b) -> foo();
String bar = (String a, Boolean b) -> foo();
}
}
]]></code>
</test-code>