on-precommit fails if source uses new instanceof pattern.
anoopvarma opened this issue · comments
What steps will reproduce the problem?
Steps to reproduce the behavior:
- Write a code using new instanceof pattern matching.
- Try to commit the code.
- The precommit hook will throw formatterexception.
What is the expected output?
It should get committed without any issue.
What happens instead?
precommit hook throws exception.
Environment:
- OS: Windows 11
- Git version: 2.40.1.windows.1
- git-code-format-maven-plugin version: 4.2
- Maven version: 3.9.1
I don’t know what you call « new instanceof pattern matching »
Hi,
For example,
See these two codes below.
1.
if (error instanceof FieldError) {
FieldError fieldError = (FieldError) error;
return "%s %s".formatted(fieldError.getField(),
fieldError.getDefaultMessage());
}
2.
if (error instanceof FieldError fieldError) {
return "%s %s".formatted(fieldError.getField(),
fieldError.getDefaultMessage());
}
From Java 16 onwards the 2nd syntax can be used in place of the 1st one.
But this causes error on pre-commit hook.
I hope this helps.
-
*Anoop Varma S*
…On Sat, May 6, 2023 at 12:35 AM Réda Housni Alaoui ***@***.***> wrote:
I don’t know what you call « new instanceof pattern matching »
—
Reply to this email directly, view it on GitHub
<#107 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AUZD6XD5XLF2BZEACKQBHJ3XEVFRNANCNFSM6AAAAAAXWT4NUI>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
--
--
CONFIDENTIALITY NOTICE: This e-mail and any attachments hereto are
intended only for use by the addressee(s) named herein and may contain
legally privileged and/or confidential information. If you are not the
intended recipient of this e-mail, you are hereby notified that any
dissemination, distribution or copying of this e-mail, and any attachments
thereto, is strictly prohibited. If you have received this e-mail in error,
please notify the sender by replying to this message and permanently delete
the original and any copy of this e-mail and any printout thereof.
pre-commits
uses the system's default JDK. Make sure JAVA_HOME
env variable is bound to a JDK 16+.
Thanks a lot.
*Anoop Varma S*
*Developer - Commerce*
Mindcurv TSPL
#6F, T-1, World Trade Center
Infopark CSEZ, P-1,
Kakkanad, Cochin - 682040
m: +91 77979 28298
<https://mindcurv.com/>
…On Tue, May 9, 2023 at 6:03 PM Réda Housni Alaoui ***@***.***> wrote:
pre-commits uses the system's default JDK. Make sure JAVA_HOME env
variable is bound to a JDK 16+.
—
Reply to this email directly, view it on GitHub
<#107 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AUZD6XFJRDQTTR3MTB74UITXFI2SNANCNFSM6AAAAAAXWT4NUI>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
--
--
CONFIDENTIALITY NOTICE: This e-mail and any attachments hereto are
intended only for use by the addressee(s) named herein and may contain
legally privileged and/or confidential information. If you are not the
intended recipient of this e-mail, you are hereby notified that any
dissemination, distribution or copying of this e-mail, and any attachments
thereto, is strictly prohibited. If you have received this e-mail in error,
please notify the sender by replying to this message and permanently delete
the original and any copy of this e-mail and any printout thereof.