You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@lucene.apache.org by "rmuir (via GitHub)" <gi...@apache.org> on 2025/06/20 02:17:07 UTC
[I] fix sources to conform to .editorconfig [lucene]
rmuir opened a new issue, #14819:
URL: https://github.com/apache/lucene/issues/14819
### Description
editorconfig with aggressive settings was applied to all files, but without fixing any existing problems or preventing new ones.
It causes the issue that when editing any impacted file, random unrelated formatting changes will appear. For example trailing whitespace is disabled, so if you edit any files that have it, your editor will correct that, leading to unrelated changes.
validation/autofix is tough: especially since indentation and line-length settings are applied to ALL files: these need ast-awareness to validating and fix correctly (e.g. spotless, prettier, etc). On the other hand, editors tend to not aggressively autofix these for the same reason.
We can start by fixing the most basic problems: e.g. trailing whitespace, missing newlines, etc in one fell swoop with low-tech tools, and add the commit to `.git-blame-ignore-revs`. These are the corrections that editors tend to do automatically across the entire individual file when saving it.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org
Re: [I] fix sources to conform to .editorconfig [lucene]
Posted by "dweiss (via GitHub)" <gi...@apache.org>.
dweiss commented on issue #14819:
URL: https://github.com/apache/lucene/issues/14819#issuecomment-3003720172
> For `java`, I don't believe `max_line_length` should be set. Current line length seems to be `Infinity`: there are enormous values present even exceeding thousands of characters long lines. I think spotless allows this in comments and string constants and such:
We don't do what they call "long string reflowing". I agree that it shouldn't be the editorconfig's responsibility here - apply tidy and it should do the job of restoring whatever state is "canonical" for the source.
I may play around with google-java-format - there's more things we have in the backlog (for example markdown)... I may just fork it since there doesn't seem to be much going on in google's repo.
>
> ```
> lucene/analysis/kuromoji/src/test/org/apache/lucene/analysis/ja/TestJapaneseAnalyzer.java:
> 215:8001: line is too long (44326 > 8000)
> "\u10b47\u10b58\u0020\u0078\u0077\u0020\u0020
> ...
> ```
>
> For `python`, the same situation applies. `ruff` formatter is used similar to Spotless, but it also allows code comments, string constants, etc to be longer than the current `200` line length:
>
> ```
> dev-tools/scripts/reproduceJenkinsFailures.py:
> 34:201: line is too long (217 > 200)
> # Policeman Jenkins example: [Lucene-Solr-7.x-Linux] $ /var/lib/jenkins/tools/hudson.tasks.Ant_AntInstallation/ANT_1.8.2/bin/ant "-Dargs=-XX:-UseCompressedOops -XX:+UseConcMarkSweepGC" jenkins-hourly
> ```
>
> For least friction with java and gradle, I recommend to run `./gradlew tidy` CLI workflow and put `lucene.spotlessGradleScripts=true` into your `~/.gradle/gradle.properties`: I don't have a better way.
>
> For python code, I'd recommend to use ruff language server and just configure to format and organize imports automatically on save (and/or upon request). You'll never think about formatting again. It will pick up our configuration from `pyproject.toml`. Really wish the java tools worked like this, it is the workflow I use for all other languages too :) https://docs.astral.sh/ruff/editors/setup/
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org
Re: [I] fix sources to conform to .editorconfig [lucene]
Posted by "dweiss (via GitHub)" <gi...@apache.org>.
dweiss commented on issue #14819:
URL: https://github.com/apache/lucene/issues/14819#issuecomment-2990073330
> It causes the issue that when editing any impacted file, random unrelated formatting changes will appear.
This is what I was worried about.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org
Re: [I] fix sources to conform to .editorconfig [lucene]
Posted by "rmuir (via GitHub)" <gi...@apache.org>.
rmuir commented on issue #14819:
URL: https://github.com/apache/lucene/issues/14819#issuecomment-2989770075
I'm having decent luck with the fast https://gitlab.com/greut/eclint, which allows disabling some of the problems in the .editorconfig with `eclint_` prefix. There are many categories of problems, e.g. invalid encoding: as we now say all non-binary files are UTF-8. I'm iterating with it, I've had to regenerate that huge DFA several times.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org
Re: [I] fix sources to conform to .editorconfig [lucene]
Posted by "rmuir (via GitHub)" <gi...@apache.org>.
rmuir commented on issue #14819:
URL: https://github.com/apache/lucene/issues/14819#issuecomment-2991947545
next step up, is the CI linter task. From the gradle side I will look to do it consistent with the ast-grep.
because elements in .editorconfig, configure the editor, I think its ok to just invoke it in CI (or if the user opts-in via a property). Newly introduced problems going forwards should be rare.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org
Re: [I] fix sources to conform to .editorconfig [lucene]
Posted by "rmuir (via GitHub)" <gi...@apache.org>.
rmuir commented on issue #14819:
URL: https://github.com/apache/lucene/issues/14819#issuecomment-3002202141
closing this out: we're now linting in CI, space and indentation is fixed.
One thing that happened was disabling the `max_line_length`. Personally I'm ok with that, but if you don't like it, feel free to make a PR as long as sources are fixed to match :)
I understand the motivation here, to reduce friction with the autoformatting, which is good thing to want to do, but I really feel, we should not set such config for any files unless we really adhere to it. Otherwise it causes problems such as unrelated changes in PRs due to editors.
For `java`, I don't believe `max_line_length` should be set. Current line length seems to be `Infinity`: there are enormous values present even exceeding thousands of characters long lines. I think spotless allows this in comments and string constants and such:
```
lucene/analysis/kuromoji/src/test/org/apache/lucene/analysis/ja/TestJapaneseAnalyzer.java:
215:8001: line is too long (44326 > 8000)
"\u10b47\u10b58\u0020\u0078\u0077\u0020\u0020
...
```
For `python`, the same situation applies. `ruff` formatter is used similar to Spotless, but it also allows code comments, string constants, etc to be longer than the current `200` line length:
```
dev-tools/scripts/reproduceJenkinsFailures.py:
34:201: line is too long (217 > 200)
# Policeman Jenkins example: [Lucene-Solr-7.x-Linux] $ /var/lib/jenkins/tools/hudson.tasks.Ant_AntInstallation/ANT_1.8.2/bin/ant "-Dargs=-XX:-UseCompressedOops -XX:+UseConcMarkSweepGC" jenkins-hourly
```
For least friction with java and gradle, I recommend to run `./gradlew tidy` CLI workflow and put `lucene.spotlessGradleScripts=true` into your `~/.gradle/gradle.properties`: I don't have a better way.
For python code, I'd recommend to use ruff language server and just configure to format and organize imports automatically on save (and/or upon request). You'll never think about formatting again. It will pick up our configuration from `pyproject.toml`. Really wish the java tools worked like this, it is the workflow I use for all other languages too :) https://docs.astral.sh/ruff/editors/setup/
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org
Re: [I] fix sources to conform to .editorconfig [lucene]
Posted by "rmuir (via GitHub)" <gi...@apache.org>.
rmuir closed issue #14819: fix sources to conform to .editorconfig
URL: https://github.com/apache/lucene/issues/14819
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org
Re: [I] fix sources to conform to .editorconfig [lucene]
Posted by "rmuir (via GitHub)" <gi...@apache.org>.
rmuir commented on issue #14819:
URL: https://github.com/apache/lucene/issues/14819#issuecomment-2989648867
It looks to me like https://github.com/ec4j/editorconfig-gradle-plugin might be exactly what is wanted here for the build to keep this tidy.
its TextLinter will address the common ones that cause this kind of noise in PRs:
end_of_line, trim_trailing_whitespace, insert_final_newline. We can disable its XMLLinter which will do indentation as well for .xml and .xsl files, or just keep it, doesn't matter to me. I'm mostly concerned about the issues detected/fixed by TextLinter because editors will automatically introduce this noise into files otherwise.
cc: @dweiss
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org