Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
[java] ShortVariable should whitelist lambdas #720
Code Sample demonstrating the issue:
aListFullOfStrings.forEach(s -> s.replaceAll(" ", ""));
Possible fix (to be thoroughly tested):
[not(ancestor::ForInit)] **[not(ancestor::LambdaExpression)]** [not(../../VariableDeclarator and ../../../LocalVariableDeclaration and ../../../../ForStatement)] [not((ancestor::FormalParameter) and (ancestor::TryStatement))]
Any official work arounds here? I find that if I create a ruleset.xml file and add
That seems to work, but it also removes a check for shortVariableNames for some reason. i.e.
Doesn't get caught anymore. I've tried a variety of configurations to no avail.