From b654d986d7814b66808e40dfe8a4a891b7d6a7f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoph=20B=C3=BCscher?= Date: Fri, 21 Sep 2018 11:52:31 +0200 Subject: [PATCH] Add OneStatementPerLineCheck to Checkstyle rules (#33682) This change adds the OneStatementPerLineCheck to our checkstyle precommit checks. This rule restricts the number of statements per line to one. The resoning behind this is that it is very difficult to read multiple statements on one line. People seem to mostly use it in short lambdas and switch statements in our code base, but just going through the changes already uncovered some actual problems in randomization in test code, so I think its worth it. --- buildSrc/src/main/resources/checkstyle.xml | 2 + .../elasticsearch/painless/MethodWriter.java | 44 +++++++--- .../elasticsearch/painless/node/SSource.java | 35 +++++--- .../percolator/QueryAnalyzer.java | 80 ++++++++++--------- .../AnnotatedTextFieldMapper.java | 5 +- .../common/rounding/Rounding.java | 11 ++- .../index/mapper/DocumentParser.java | 3 +- .../search/aggregations/InternalOrder.java | 16 +++- .../search/query/QueryPhase.java | 5 +- .../common/settings/ScopedSettingsTests.java | 10 ++- .../concurrent/AsyncIOProcessorTests.java | 10 ++- .../shard/PrimaryReplicaSyncerTests.java | 16 +++- .../jvm/JvmGcMonitorServiceSettingsTests.java | 10 ++- .../aggregations/bucket/BooleanTermsIT.java | 3 +- .../highlight/HighlightBuilderTests.java | 6 +- .../core/ccr/ShardFollowNodeTaskStatus.java | 6 +- .../xpack/core/scheduler/Cron.java | 30 +++++-- .../ml/utils/ChainTaskExecutorTests.java | 52 +++++++++--- .../security/authc/TokenServiceTests.java | 6 +- 19 files changed, 247 insertions(+), 103 deletions(-) diff --git a/buildSrc/src/main/resources/checkstyle.xml b/buildSrc/src/main/resources/checkstyle.xml index 939d48e72ce..660c3661a46 100644 --- a/buildSrc/src/main/resources/checkstyle.xml +++ b/buildSrc/src/main/resources/checkstyle.xml @@ -35,6 +35,8 @@ + +