-
-
Notifications
You must be signed in to change notification settings - Fork 4k
Description
based on discussion at #4058 (PR #4173)
right curly of expression block is different from other blocks so rules or RightCurly Check does not work well as for example for alone results in weird code as } in expression is always followed by smth, same does not make sense .
Array Creation Expressions
Lambda expression
Class Instance Creation Expressions
on_same_line
ignoredAnnotations = Arrays.stream(new String[] {"Test", "Before", "After",
"BeforeClass", "AfterClass", }).collect(Collectors.toSet());
final Class<?>[] param = new Class<?>[] {String.class, String.class,
String.class, Attributes.class,};
someMethod(() -> {"Hello".equals("Hello world two!");});
new Object() { @Override protected void finalize() { "".toString(); } int b = 10; };
on_new_line
ignoredAnnotations = Arrays.stream(new String[] {"Test", "Before", "After",
"BeforeClass", "AfterClass",
}).collect(Collectors.toSet());
final Class<?>[] param = new Class<?>[] {String.class, String.class,
String.class, Attributes.class,
};
someMethod(() -> {"Hello".equals("Hello world two!");
});
new Object() { @Override protected void finalize() { "".toString(); } int b = 10;
};
on_new_line_or_singleline
ignoredAnnotations = Arrays.stream(new String[] {"Test", "Before",}).collect(Collectors.toSet());
ignoredAnnotations = Arrays.stream(new String[] {"Test", "Before", "After",
"BeforeClass", "AfterClass",
}).collect(Collectors.toSet());
final Class<?>[] param = new Class<?>[] {String.class, String.class,
String.class, Attributes.class,
};
final Class<?>[] param = new Class<?>[] {String.class, Attributes.class, };
someMethod(() -> {"Hello".equals("Hello world two!");});
someMethod(() -> {
"Hello".equals("Hello world two!");
});
new Object() { @Override protected void finalize() { "".toString(); } int b = 10; };
new Object() { @Override protected void finalize() { "".toString(); } int b = 10;
};
more examples of code from our repo - at this comment
For multi-dimensional arrays we validate only outer curly brace
int array[][] = { {1, 2}, {3,4} };
we will validate only "};".
case where we validate only outer "}":
java.util.Map<String, String> map2 = new LinkedHashMap<String, String>() {{
put("Hello", "World");
put("first", "second");
put("polygene", "lubricants");
put("alpha", "betical"); } // ATTENTION: here is "}", Check should not care
};
Looks like token set for Check should LAMBDA and NEW. We need to support anonymous inner classes as well, see #11575 for details.
On the moment of implementation, we need to recheck google style is case there become more details on how to format code of lambda. We need answer from google on this point, see google/styleguide#112 .