-
Notifications
You must be signed in to change notification settings - Fork 55
palantir-java-format IntelliJ plugin ignores @Formatter:off/on #653
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
Comments
Any plan on fixing this? |
One of the guiding principles of this project was to minimize configurability in order to avoid endless discussions/arguments between developers about 'which formatting looks better'. I would be concerned that building support for special So consequently I'd actually vote to not implement support for these (unless there's a super compelling use-case I'm not aware of). I think this is consistent with the google-java-format approach (diffplug/spotless#275), gofmt. rustfmt does actually support these kinds of comments though ( Are there snippets or examples where you feel it's essential to use the |
I need this as well. I am having code like this
The palantir plugin will currently put this all in single lines so this is not readable anymore. |
@querdenker2k I appreciate the snippet of code you've pasted is arguably better than the p-j-f formatted version: new ResponseVerifier.ProductionRecordBuilder()
.verifyArtifact("MyArtefact")
.verifyDataFields()
.verifyDataField("DataField1")
.mustExist()
.back()
.verifyDataField("DataField2")
.mustNotExist()
.back() but I'm afraid I don't find this example compelling enough to open the door to We found somewhat similar cases internally, which led to us calling out the 'downside' of strongly opinionated formatters on the README:
In this case, I'd suggest maybe the new ResponseVerifier.ProductionRecordBuilder()
.verifyArtifact("MyArtefact")
.verifyDataFields()
.verifyDataField("DataField1", field -> {
field.mustExist();
})
.verifyDataField("DataField2", field -> {
field.mustNotExist();
}) |
One of the arguments to support |
I think if a team is aware enough to be using a tool such as PJF, then when they see a code block that has formatting disabled via |
The bigger concern is that this plugin breaks from IntelliJ default behavior, without any option to restore it or even a hint that it does so. The implication is that it modifies how IntelliJ does its formatting, when in fact it seems to replace the formatting function in its entirety. |
FWIW, diffplug/spotless#275 was also referenced along with the Google Java Formatter earlier as partial justification for not supporting this, but Spotless actually added the ability to disable formatting regardless of the fact GJF doesn't support it. |
IMHO it makes no sense not to support the // @Formatter:off feature through at least a config setting on the plugin :
Let me illustrate with this "anonimized" real-life example. I included 2 variations for the description args, one with multi-line Strings and one with "classic" String addition, which both have their issues in this forced formatting.
I see the following problems with it :
I could format this in a much more readable way, aligning the annotations, properties etc in such a way that any scanning operation (i.e. quickly visually determining what the properties are, what the annotations are for a given property, ...) are facilitated and become trivial. With the plugin as-is, pretty much whatever I do will be destroyed though. One would think that the end goal of any formatting is to get readable maintainable code. To add insult to injury, one of the promises of records and annotations is to create more declarative, very easy-to-read code. |
I have to agree with @philip-rx , the auto formatting does not go well with At least for "normal" classes, one can extract the longer description strings easily. But with records, you would need to extract them into a different file to be accessible... so not that elegant of a solution. |
What happened?
The IntelliJ plugin ignores formatter guards (e.g. @Formatter:off/on) even though IntelliJ itself is setup to respect it.
What did you want to happen?
Do not overwrite the formatter guard settings (or at least provide a settings option to respect those).
The text was updated successfully, but these errors were encountered: