From 014e1b1090eb43faf47a246be7e1df32b0903493 Mon Sep 17 00:00:00 2001 From: Rory Hunter Date: Mon, 11 Nov 2019 14:33:04 +0000 Subject: [PATCH] Improve resiliency to auto-formatting in server (#48940) Backport of #48450. Make a number of changes so that code in the `server` directory is more resilient to automatic formatting. This covers: * Reformatting multiline JSON to embed whitespace in the strings * Move some comments around to they aren't auto-formatted to a strange place. This also required moving some `&&` and `||` operators from the end-of-line to start-of-line`. * Add helper method `reformatJson()`, to strip whitespace from a JSON document using XContent methods. This is sometimes necessary where a test is comparing some machine-generated JSON with an expected value. Also, `HyperLogLogPlusPlus.java` is now excluded from formatting because it contains large data tables that don't reformat well with the current settings, and changing the settings would be worse for the rest of the codebase. --- build.gradle | 1 - .../resources/checkstyle_suppressions.xml | 2 +- server/build.gradle | 16 ++++++ .../queries/BinaryDocValuesRangeQuery.java | 24 +++++---- .../action/search/FetchSearchPhase.java | 6 ++- .../cluster/routing/RoutingNodes.java | 7 +-- .../elasticsearch/common/lucene/Lucene.java | 3 +- .../index/query/MoreLikeThisQueryBuilder.java | 52 +++++++++---------- .../cluster/IndicesClusterStateService.java | 4 +- .../metrics/HyperLogLogPlusPlus.java | 40 +++++++++----- .../search/suggest/phrase/WordScorer.java | 4 +- .../elasticsearch/transport/TcpTransport.java | 16 +++--- .../time/format/StrictISODateTimeFormat.java | 31 +++++++---- .../TransportMasterNodeActionTests.java | 7 ++- .../coordination/LeaderCheckerTests.java | 3 +- .../index/store/CorruptedFileIT.java | 3 +- .../plugins/PluginsServiceTests.java | 3 +- .../elasticsearch/recovery/RelocationIT.java | 3 +- .../aggregations/bucket/DateRangeIT.java | 3 +- .../search/preference/SearchPreferenceIT.java | 4 +- .../suggest/CompletionSuggestSearchIT.java | 2 +- .../threadpool/ThreadPoolTests.java | 4 +- 22 files changed, 148 insertions(+), 90 deletions(-) diff --git a/build.gradle b/build.gradle index f148cd145ea..95701023acb 100644 --- a/build.gradle +++ b/build.gradle @@ -114,7 +114,6 @@ subprojects { spotless { java { - removeUnusedImports() eclipse().configFile rootProject.file('.eclipseformat.xml') trimTrailingWhitespace() diff --git a/buildSrc/src/main/resources/checkstyle_suppressions.xml b/buildSrc/src/main/resources/checkstyle_suppressions.xml index 775c89c257a..4de487382a2 100644 --- a/buildSrc/src/main/resources/checkstyle_suppressions.xml +++ b/buildSrc/src/main/resources/checkstyle_suppressions.xml @@ -21,7 +21,7 @@ configuration of classes that aren't in packages. --> - +