首页 > 解决方案 > 检查样式报告奇怪的缩进问题

问题描述

Checkstyle 仅针对以下代码抱怨不正确的缩进。我尝试通过 intellij 或手动格式化代码,但它们都不起作用。当我通过错误消息修复问题时,缩进级别仍然不正确,但数字发生了变化。

        Map<MessageStatusAndErrorCode, Integer> result = MESSAGES_POLLER_EXECUTOR_SERVICE.invokeAll(callables).stream()
                .map(stringFuture -> {
                    try {
                        return stringFuture.get();
                    } catch (InterruptedException | ExecutionException ex) {
                        throw new IllegalStateException(ex);
                    } 
                })
                .collect(Collectors.groupingBy(Function.identity(), reducing(0, e -> 1, Integer::sum)));
        messagesStatusCountMap.putAll(result);

来自 checkstyle 的错误消息:

'try' have incorrect indentation level 20, expected level should be 24.
Line 132'try' child have incorrect indentation level 24, expected level should be 28.
Line 133'try rcurly' have incorrect indentation level 20, expected level should be 24.
Line 134'catch' child have incorrect indentation level 24, expected level should be 28.
Line 135'block rcurly' have incorrect indentation level 22, expected level should be 20.
Line 135'catch rcurly' have incorrect indentation level 20, expected level should be 24.

标签: javaindentationcheckstyle

解决方案


推荐阅读