Sunday, 15 August 2010

java 8 - Sonar : lambda - Remove useless curly braces around statement -



java 8 - Sonar : lambda - Remove useless curly braces around statement -

these code examples:

import java.util.observer; public class main { public static void main(string[] args) { observer observer = (o, arg) -> { if (arg != null) { system.out.println(arg); } }; } } import java.util.observer; public class main { public static void main(string[] args) { observer observer = (o, arg) -> { seek { string test = (string) arg; ... } grab (classcastexception e) { } }; } }

are noncompliant sonarqube rule:

lamdbas containing 1 statement should not nest statement in block : remove useless curly braces around statement

how can prepare ?

the classification of these curly braces “useless” wrong.

you can omit curly braces around single expression statement, is, example, method invocation, new expression, or x++, x+=y, etc.

or can transform sole … -> { homecoming x; } statement look … -> x.

but can’t omit curly braces around every single statement.

you can’t prepare that. thing can file bug report.

by way, then, removing them not readability improvement. depends…

lambda java-8 sonarqube

No comments:

Post a Comment