Add .editorconfig with basic configuration for better integration with editors and IDEs

Vladimir Sitnikov sitnikov.vladimir at gmail.com
Tue Jun 20 13:17:33 UTC 2023


Hi,

I would like to suggest a follow-up to 8298047: Remove all
non-significant trailing whitespace from properties.
Magnus suggested asking the question on the mailing list:
https://github.com/openjdk/jdk/pull/11491#issuecomment-1385333560

Currently, jcheck provides whitespace checks, however, those checks
are not understood by the editors,
so contributors have to configure their editors and IDEs manually.

What I suggest is
1) Add one or more .editorconfg files so it would be easier for contributors to
pass the CI, and they would spend less time configuring IDEs.
See https://editorconfig.org/ which is a de-facto standard for sharing
editor configurations.
It does not solve the problem of verifying or autoformatting, however,
it solves the use-case
for configuring different editors and IDEs in a common format.

2) Consider using .editorconfig for managing some of jcheck settings.
For instance, it would be great if jcheck could infer
trim_trailing_whitespace based on .editorconfig.

Would you please clarify if such a change might we considered for
OpenJDK, and what would be the process to make it happen?

---

There are several checks that are often configured:
"trim trailing whitespace"
"add newline at the end of the file"
"tab vs space for indentation"

Even though, they are "trivial", they are a constant waste of CI
resources and contributor's time.
Here's the way the settings can be set in .editorconfig, so editors
would trim whitespace, add a newline, and so on:

[*.java]
indent_style = space
indent_size = 4
trim_trailing_whitespace = true
insert_final_newline = true

That would make it easier for the contributors to pass CI on the first try.

I do not suggest adding, configuring, and enforcing every possible
editorconfig setting,
however, there are quite some settings that might help users.

For instance, max_line_length, end_of_line (lf, crlf).

There are a bunch of extension properties.
For instance, IntelliJ IDEA recognizes many ij_... settings that can
configure some of the code formatting rules,
and which might even specify the desired import order.

I do not want to raise discussions on the code style, and my key
intention here is to suggest committing some .editorconfig files
that would configure contributor's editors in such a way that the
default style would more-or-less match the existing style of the
project.

Vladimir


More information about the ide-support-dev mailing list