Open Bug 1897629 Opened 10 months ago Updated 5 months ago

"mach lint -l android-format" messes up ending whitespace when running on Windows

Categories

(Fenix :: Tooling, defect)

Firefox 128
x86_64
Windows 10
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:

  1. Do a fresh checkout of mozilla-central
  2. Make a trivial edit to a .java file, such as mobile/android/geckoview/src/main/java/org/mozilla/geckoview/GeckoSession.java
  3. Run ./mach lint -l android-format --fix
  • Note that hundreds of files now have edits, all of which are changes in ending whitespace
  1. 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)"
See Also: → 1894927

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)"

: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.

Flags: needinfo?(bugzeeeeee)

Moving this across to Fenix/Tooling as that seems like it might be the better spot for it.

Component: Lint and Formatting → Tooling
Flags: needinfo?(bugzeeeeee)
Product: Developer Infrastructure → Fenix

The severity field is not set for this bug.
:007, could you have a look please?

For more information, please visit BugBot documentation.

Flags: needinfo?(nbond)

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.

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!

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.)

Severity: -- → S3
Flags: needinfo?(nbond)
You need to log in before you can comment on or make changes to this bug.