Skip to content

Spotless removes space before instanceof in pattern match #82794

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

Closed
DaveCTurner opened this issue Jan 19, 2022 · 5 comments · Fixed by #94994
Closed

Spotless removes space before instanceof in pattern match #82794

DaveCTurner opened this issue Jan 19, 2022 · 5 comments · Fixed by #94994
Labels
>bug :Delivery/Tooling Developer tooliing and automation Team:Delivery Meta label for Delivery team

Comments

@DaveCTurner
Copy link
Contributor

Spotless does this:

diff --git a/server/src/main/java/org/elasticsearch/cluster/coordination/Publication.java b/server/src/main/java/org/elasticsearch/cluster/coordination/Publication.java
index 3a48bb3f05d..506c0efe8ac 100644
--- a/server/src/main/java/org/elasticsearch/cluster/coordination/Publication.java
+++ b/server/src/main/java/org/elasticsearch/cluster/coordination/Publication.java
@@ -378,7 +378,7 @@ public abstract class Publication {

         private Exception getRootCause(Exception e) {
             if (e instanceof final TransportException transportException) {
-                if (transportException.getRootCause() instanceof final Exception rootCause) {
+                if (transportException.getRootCause()instanceof final Exception rootCause) {
                     return rootCause;
                 } else {
                     assert false : e;

An aesthetic thing for sure but I think it's better with the space than without.

@DaveCTurner DaveCTurner added >bug :Delivery/Tooling Developer tooliing and automation labels Jan 19, 2022
@elasticmachine elasticmachine added the Team:Delivery Meta label for Delivery team label Jan 19, 2022
@elasticmachine
Copy link
Collaborator

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

@mark-vieira
Copy link
Contributor

This looks to be a bug in eclipse-jdt. There's no explicit formatter setting for instanceof pattern matching, it's just the formatter not understanding this syntax. Eclipse version 2021.12, using eclipse-jdt 4.22 works as intended. We unfortunately have to wait for a) the IntelliJ plugin to update the bundled Eclipse libraries and b) Spotless to update eclipse-jdt to 4.22.

I was able to get the IDE to work as intended by configuring the IntelliJ Eclipse Formatter plugin to point to an Eclipse 2021.12 installation, so that at least confirms that version of eclipse-jdt works as intended. That said, we need both IDE and CLI to match otherwise folks will reformat in IntelliJ and spotless with complain or vice versa.

We can open a PR for spotless for this but the IntelliJ plugin doesn't seem to use any kind of dependency management. I suspect the author has to download the updated libraries locally and rebuild.

@mark-vieira
Copy link
Contributor

We aren't the only ones asking for this: diffplug/spotless#1059

@mark-vieira
Copy link
Contributor

An aesthetic thing for sure but I think it's better with the space than without.

This definitely triggers me as well.

@pugnascotia
Copy link
Contributor

Spotless has finally updated, so we should now be able to address this issue.

pugnascotia added a commit that referenced this issue Apr 4, 2023
Fixes #82794. Upgrade the spotless plugin, which addresses the issue
around formatting `instanceof` expressions. Formatting of statements
including lambdas seems to have improved too.
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
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants