Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Formatting escape hatch #81806

Merged
merged 4 commits into from
Dec 16, 2021
Merged

Conversation

pugnascotia
Copy link
Contributor

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.

@elasticmachine elasticmachine added the Team:Delivery Meta label for Delivery team label Dec 16, 2021
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-delivery (Team:Delivery)

@Luegg
Copy link
Contributor

Luegg commented Dec 16, 2021

Works on my machine 👍 Lgtm.

Only question I have is wether .editorconfig might also need to be updated?

ij_formatter_off_tag = @formatter:off
ij_formatter_on_tag = @formatter:on
ij_formatter_tags_enabled = false

I guess currently the settings have no effect because the tags are disabled but it might cause some confusion.

@pugnascotia
Copy link
Contributor Author

Good point, I've taken that config out.

@pugnascotia pugnascotia merged commit 5b49982 into elastic:master Dec 16, 2021
@pugnascotia pugnascotia deleted the formatting-escape-hatch branch December 16, 2021 16:18
pugnascotia added a commit that referenced this pull request Dec 16, 2021
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.
pugnascotia added a commit that referenced this pull request Dec 16, 2021
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>bug :Delivery/Tooling Developer tooliing and automation Team:Delivery Meta label for Delivery team v7.17.0 v8.0.0-rc1 v8.1.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants