Skip to content

.editorconfig #14740

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

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open

.editorconfig #14740

wants to merge 7 commits into from

Conversation

dsmiley
Copy link
Contributor

@dsmiley dsmiley commented May 31, 2025

Complementary to Spotless/tidy

Description

A while back, I imported a "Google Java Style" into my IntelliJ from some internet source and have been using it in my IDE. I exported that to editorconfig format. Then I made some tweaks:

  • added root = true
  • removed entire file format sections that our repo doesn't even have. IntelliJ was able to point this out easily.
  • *.properties: kept blank lines
  • *.gradle: added as a groovy source file pattern
  • tab_width removed as generally redundant
  • insert_final_newline = true because spotless.gradle configures this.

QA: I told IntelliJ to reformat and optimize imports across all of lucene-core. I saw no changes to java sources, which was correct except for a generated source file.

Complementary to Spotless/tidy
Copy link

This PR does not have an entry in lucene/CHANGES.txt. Consider adding one. If the PR doesn't need a changelog entry, then add the skip-changelog-check label to it and you will stop receiving this reminder on future updates to the PR.

@vigyasharma
Copy link
Contributor

Nice, this would help avoid a bunch of "tidy" commits in my git history!

I tried pulling the .editorconfig locally and reformatted a couple of existing files via Cmd + Alt + L on IntelliJ. It did make a bunch of changes, mostly on docStrings. Attaching the git diff here, in case this is reconcilable with some simple editorconfig commands. – (diff_with_editorconfig_on_main.txt)

An alternate would be to change reformatting scope to only uncommitted changes. This can be done via a setting in Intellij but might be easy to miss?

Copy link
Contributor

@dweiss dweiss left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm fine with adding these hints, although I don't use this convention myself so Robert's comments should probably be reviewed and applied first - especially if adding this file may result in corruping certain file types (Makefile).

@vigyasharma
Copy link
Contributor

I'm fine with adding these hints, although I don't use this convention myself

Oh wait, I thought these changes were coming from the editorconfig in this PR. But looks like it's adding some stuff from my local IDE setup, duh! Surprising because I don't use this convention either!

Robert's comments should probably be reviewed and applied first - especially if adding this file may result in corruping certain file types (Makefile).

100% agree. We also don't need to add any extra hints, as long as we have parity with the tidy bot, and reformatting with this config doesn't change existing committed code.

Copy link

github-actions bot commented Jun 2, 2025

This PR does not have an entry in lucene/CHANGES.txt. Consider adding one. If the PR doesn't need a changelog entry, then add the skip-changelog-check label to it and you will stop receiving this reminder on future updates to the PR.

@dsmiley
Copy link
Contributor Author

dsmiley commented Jun 2, 2025

I simplified the glob patterns.

I realized my QA was quite flawed because I had the "Google Java Format" IntelliJ plugin installed, which overrides the style settings. I disabled it and spent hours wrestling with IntelliJ's settings to try to get it to match as close as possible. Alas... there remains irreconcilable differences, especially in line wrapping of Javadoc but also in line wrapping of long assignments. This is the best I could do. I updated the Groovy settings to match because of it's syntactical closeness to Java.

A reminder: these settings are applied to certain lines of code or files when the user takes certain actions. Yes it can be done automatically on commit but that's opt-in and I'm not sure I'd condone that in a project that uses a non-IDE solution as we do.

@dsmiley dsmiley added the skip-changelog-check Apply to PRs that don't need a changelog entry to stop the automated changelog check. label Jun 3, 2025
@stefanvodita stefanvodita added the skip-changelog Apply to PRs that don't need a changelog entry, stopping the automated changelog check. label Jun 3, 2025
@dsmiley
Copy link
Contributor Author

dsmiley commented Jun 12, 2025

Are there any concerns with merging this in its current state? It's trimmed down from the original.

@dweiss
Copy link
Contributor

dweiss commented Jun 12, 2025

Most of those settings apply to intellij, right? They are not some "standard" .editorconfig things. I'm fine with adding this - if something clashes with other settings, we can always tweak this file's configuration (for example, gradle and groovy files are auto-formatted on #14764).

@dsmiley
Copy link
Contributor Author

dsmiley commented Jun 12, 2025

Yes; most lines are IntelliJ specific. Thanks for pointing to your recent build work... I'll want to adjust this this configuration to align with the Groovy style from there.

@dsmiley
Copy link
Contributor Author

dsmiley commented Jun 16, 2025

I plan to merge this tonight (~10pm EST) if I don't hear advise to the contrary.

@rmuir
Copy link
Member

rmuir commented Jun 16, 2025

please remove the python completely as we already have a python autoformatter and verifier (like spotless, except not slow as hell). We don't need conflicting editor configuration around it.

@dsmiley
Copy link
Contributor Author

dsmiley commented Jun 16, 2025

please remove the python completely as we already have a python autoformatter and verifier

I think you're missing a point of the value of this. It's complementary with Spotless (or similar). It helps us write code formatted according to the project's standards during the writing/editing process, especially when utilizing IDE features that manipulate code (e.g. refactorings, perhaps code suggestion completions too). Consequently, forgetting to run tidy/Spotless can be less of an annoyance... pushing more formatting earlier.

@dweiss
Copy link
Contributor

dweiss commented Jun 17, 2025

Just FYI - I noticed we already have an editorconfig file in scripts -
https://github.com/apache/lucene/blob/main/dev-tools/scripts/.editorconfig

is this complementary? Could it be moved to the top level as part of this patch?

@dsmiley
Copy link
Contributor Author

dsmiley commented Jun 17, 2025

OMG that's ironic! @rmuir, you added it (in March), and it only configures Python :-) LOL

Okay... well I think that file should be removed and it's python section integrated into the top-level file coming with this PR. As to the very specifics of what it configures, I don't care (whatever you guys say) as Python isn't my thing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
skip-changelog Apply to PRs that don't need a changelog entry, stopping the automated changelog check. skip-changelog-check Apply to PRs that don't need a changelog entry to stop the automated changelog check.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants