ec4j icon indicating copy to clipboard operation
ec4j copied to clipboard

.editorconfig with empty values

Open Vampire opened this issue 2 years ago • 3 comments

When you export a code style config from IntelliJ to an .editorconfig file, there are several keys without value. This makes the ktlint plugin 0.20.0-beta-4 not work anymore as it gets a parse exception from ec4j:

2023-12-01 16:51:13,882 [1216094]   INFO - STDOUT - Start ktlintFormat on file '....kt' triggered by 'KtlintPostFormatProcessor'
2023-12-01 16:51:13,888 [1216100] SEVERE - #c.i.c.a.AbstractLayoutCodeProcessor - Got unexpected exception during formatting file://....kt
java.util.concurrent.ExecutionException: org.ec4j.core.parser.ParseException: path:.../.editorconfig:93:26: Property 'ij_java_builder_methods' has no value

Vampire avatar Dec 02 '23 16:12 Vampire

Thanks for the report, @Vampire.

The editorconfig format specification is quite clear about the alowed structures in .editorconfig files:

Each line must be one of the following: ...

  • Key-Value Pair (or Pair): contains a key and a value, separated by an =.
    • Key: The part before the first = (trimmed of whitespace, but including any whitespace in the middle).
    • Value: The part after the first = (trimmed of whitespace, but including any whitespace in the middle). Any line that is not one of the above is invalid.

I'd interpret it in such a way that keys without values are illegal and it is the IJ export that should be fixed.

ppalaga avatar Jan 24 '24 10:01 ppalaga

I don't see how a value of "" (empty string) is not following that specification. "Fixing" the IJ export is not as simple as it might sound, because it is also the interpretation. A key with empty value is different from the key being absent.

Vampire avatar Jan 24 '24 12:01 Vampire

I have filed a specs clarification issue https://github.com/editorconfig/editorconfig/issues/496

ppalaga avatar Jan 24 '24 13:01 ppalaga

Soooo, the specification now is clarified by explicitly allowing empty values. Can we get a fix for this now? :-)

Vampire avatar Sep 28 '24 16:09 Vampire

I released 1.1.0

ppalaga avatar Sep 30 '24 18:09 ppalaga