Formatting escape hatch (#81806)

Thanks to https://bugs.eclipse.org/bugs/show_bug.cgi?id=574437,
we've run into a situation where Spotless is incorrectly formatting
a particular piece of syntax (due the underlying Eclipse bug). We
were able to turn off formatting of this syntax using `// @formatter:off`
and `// @formatter:on`, but there was a further problem. We configure
IntelliJ to use the Eclipse formatter plugin, but this doesn't
respect the `@formatter` tags since these are set at the Spotless
level, not the Eclipse formatter level. Note that these tags aren't
set in the Eclipse formatter config, because there we use `// tag::`
and `// end::` in order to avoid reformatting docs snippets, which
have a much narrower line width.

What a mess.

So, to get around all this, drop the `@formatter` tags and tweak
our custom `SnippetLengthCheck` Checkstyle rule so that
`// tag:noformat` regions are not subject to the narrower line length
check, but are still exempt from formatting.
This commit is contained in:
Rory Hunter 2021-12-16 16:18:34 +00:00 committed by Rory Hunter
parent d5222bd6e2
commit 358cd80d34
11 changed files with 25 additions and 29 deletions

View file

@ -154,7 +154,7 @@ public class Vertex implements ToXContentFragment {
this.weight = weight;
}
// @formatter:off
// tag::noformat
/**
* If the {@link GraphExploreRequest#useSignificance(boolean)} is true (the default)
* this statistic is available.
@ -163,12 +163,12 @@ public class Vertex implements ToXContentFragment {
* href="https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-significantterms-aggregation.html"
* >the significant_terms aggregation</a>)
*/
// @formatter:on
// end::noformat
public long getBg() {
return bg;
}
// @formatter:off
// tag::noformat
/**
* If the {@link GraphExploreRequest#useSignificance(boolean)} is true (the default)
* this statistic is available.
@ -178,7 +178,7 @@ public class Vertex implements ToXContentFragment {
* href="https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-significantterms-aggregation.html"
* >the significant_terms aggregation</a>)
*/
// @formatter:on
// end::noformat
public long getFg() {
return fg;
}