This gets worse if you have chained lamdas too, as each chaining requires another level of indentation
public static void fun() { String[] filterVals = { "1", "2" };
Arrays.asList("1","2","3") .stream() .filter(chain(x-> (y-> y.equals(x) ), filterVals)) .count(); } public static <T> Predicate<T> chain (Function<T,Predicate<T>> mapFn, T[]args) { return Arrays.asList(args) .stream() .map(x -> mapFn.apply(x)) .reduce(p -> false, Predicate::or); }
// ...
final class InputValidClassDefIndent66 extends java.awt.event.MouseAdapter implements java.awt.event.MouseListener {
// ...
private void myMethod() { //indent:4 exp:4
// ...
new JButton().addActionListener(new ActionListener() //line:129 indent:10 exp:8
{ //line:130 indent:8 exp:8
public void actionPerformed(ActionEvent e) { //line:131 indent:12 exp:12
//line:132
} //line:133
}); //line:134
// ...
}
// ...
}
It is actually a tricky case. Violations on lines 130 and 134 depend on the line 129 because they form an inner block. As line 129 isn't indented properly check says that you have to indent lines 130 and 134 relative to 129. So, it is not false positive. If you fix the original violation in line 129 violations on lines 130 and 134 will disappear.
1 private void myMethod() { //indent:4 exp:4
2
3 new JButton().addActionListener(new ActionListener() //indent:10 exp:8
4 { //indent:8 exp:8
5 public void actionPerformed(ActionEvent e) { //indent:12 exp:12
6
7 }
8 });
9
10 }
1 private void myMethod() { //indent:4 exp:4
2
3 new JButton().addActionListener(new ActionListener() //indent:10 exp:8
4 { //indent:9 exp:8
5 public void actionPerformed(ActionEvent e) { //indent:12 exp:12
6
7 }
8 }); //indent:9 exp:8
9
10 }
but how are you going to deal with such a case:
1 private void myMethod() { //indent:4 exp:4
2
3 new JButton().addActionListener(new ActionListener() //indent:10 exp:8
4 { //indent:9 exp:8
5 public void actionPerformed(ActionEvent e) { //indent:12 exp:12
6
7 }
8 }); //indent:9 exp:8
9
10 }
Here in lines 4 and 8 violations are expected as well as in line 3.
Logic looks clear , but at summer 2014 we introduced as option in IndentationCheck to allow non strict linewrapping so it mean that indentation on parent (but not the top parent!) can be 4,5,6,7,8.....any amount of spaces - it is completely up to the user.How that will work in your algorithm ?
Please provide links to Test inputs that you are going to use for issue 281.
Hi Alexey,
Please provide configuration as a comment on a input class that will help validate your expectations.
Thanks,
Roman Ivanov
--
You received this message because you are subscribed to the Google Groups "checkstyle-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to checkstyle-dev...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.