-
Notifications
You must be signed in to change notification settings - Fork 48
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
spotless-maven-palantirJavaFormat : last character not a \n
-> check fails
#975
Comments
+1 For reference the google style plugin (google and aosp versions) do add the new line when formatting a file. |
I'm wondering where it is to be fixed: in the |
In order to debug the problem, I opened this project in Intellij 2024.1 with Java "openjdk@21" and "openjdk@17" installed on my MacBook. while the project does not build with openjdk@21 on the command line
it does build with however inside Intellij, it does not build with openjdk@21 nor with "openjdk@17" because:
Moreover , it seems that the file based tests already test for an additional "newline" at the end of a source file. : Therefore i don't understand why the Intellij-palantir-java-plugin does not add this obviousely required "newline" at the end of each source file ? |
what about just change @Override
public void run() {
if (formatterService.isEmpty()) {
request.onError(
Notifications.GENERIC_ERROR_NOTIFICATION_GROUP,
"Failed to format file because formatterService is not configured");
return;
}
try {
String formattedText = applyReplacements(
request.getDocumentText(),
formatterService.get().getFormatReplacements(request.getDocumentText(), toRanges(request)));
// request.onTextReady(formattedText);
request.onTextReady(formattedText.trim() + "\n");
} catch (FormatterException e) {
request.onError(
Notifications.PARSING_ERROR_TITLE,
Notifications.parsingErrorMessage(
request.getContext().getContainingFile().getName()));
}
} this seems to do the trick |
Problem: using palantirJavaFormat with spotless maven : last character not a
\n
-> check failswhen creating a new java class using Intellij with palantir-java-format for formating all java files
AND using spotless with palantirJavaFormat
AND
the last line in a java file is not an empty line but just
}
with no\n
appendedTHEN
the spotless:check fails
what i would expect instead
I would expect that the check should pass no matter of the
\n
as the last character in java files, just as the palantir-java-plugin for intellij does not care.EDIT: and/or I expect that the Intellij palantir-java-plugin adds a
\n
to the end of each java file all by itself.Details:
copy-paste your full Spotless configuration block(s), and a link to a public git repo that reproduces the problem if possible
copy-paste the full content of any console errors emitted by
mvn -e spotless:check
java file:
The text was updated successfully, but these errors were encountered: