"mach lint -l android-format" messes up ending whitespace when running on Windows
Categories
(Fenix :: Tooling, defect)
Tracking
(Not tracked)
People
(Reporter: gstoll, Unassigned)
References
Details
On Windows, running ./mach lint -l android-format
on Android code seems to mess up whitespace at the end of lines.
Steps to Reproduce:
- Do a fresh checkout of mozilla-central
- Make a trivial edit to a .java file, such as
mobile/android/geckoview/src/main/java/org/mozilla/geckoview/GeckoSession.java
- Run
./mach lint -l android-format --fix
- Note that hundreds of files now have edits, all of which are changes in ending whitespace
- Run a try build with the
source-test-mozlint-file-whitespace file-whitespace
task
- It will fail with many lines like "[task 2024-05-19T02:08:43.761Z] TEST-UNEXPECTED-ERROR | /builds/worker/checkouts/gecko/mobile/android/annotations/src/main/java/org/mozilla/gecko/annotationProcessors/AnnotationInfo.java:0 | Windows line return (file-whitespace)"
Reporter | ||
Comment 1•10 months ago
|
||
The source-test-mozlint-android-lints
task also fails with many lines like "[task 2024-05-19T02:20:48.309Z] TEST-UNEXPECTED-ERROR | /builds/worker/checkouts/gecko/mobile/android/annotations/src/main/java/org/mozilla/gecko/annotationProcessors/AnnotationInfo.java:0 | Formatting error, please run ./mach lint -l android-format --fix (spotless-java)"
Comment 2•10 months ago
|
||
:owlish (please redirect if you're the wrong person to ask): I'm wondering if these bugs should be here, or if they'd be better off in one of the android or geckoview components? It'd be nice to make sure that these get looked at by the correct teams.
We might want to extend this definition if they should be somewhere else.
Comment 3•8 months ago
|
||
Moving this across to Fenix/Tooling as that seems like it might be the better spot for it.
Comment 4•7 months ago
|
||
The severity field is not set for this bug.
:007, could you have a look please?
For more information, please visit BugBot documentation.
This could be related to differences in how line endings and whitespace are handled between Windows and other operating systems.
Try configuring git to automatically convert line endings on checkout by running and let me know if that resolves the issue:
git config --global core.autocrlf true
If that doesn't work, I wonder if running this in a UNIX environment like WSL might make more sense.
Reporter | ||
Comment 6•7 months ago
|
||
I confirmed that core.autocrlf
is set and that doesn't resolve the issue. (I still see a bunch of changes and the file-whitespace
build fails)
I think it would be kind of a shame to require WSL for Windows developers working on Android, but I realize that developing for Android on Windows seems to be fairly rare. Since I'm not actively working on Android anymore, I'll leave it up to y'all whether to leave this bug open or close it. Thanks!
Comment 7•7 months ago
|
||
android-format uses Google Java Format, but it doesn't have an option to set line ending to LF at force. ktlint (for Kotlin) has a option for it (If needed, I will add this option to linter.)
Updated•5 months ago
|
Description
•