fune/docs/code-quality/lint/linters/android-format.rst
Agi Sferro 2bd64785fc Bug 1571899 - Use google-java-format via spotless to enforce Java formatting. r=ahal,owlish
This change adds a new lint `android-format` which enforces formatting of Java
code using google-java-format.

To run the lint simply run:

./mach lint -l android-format

This command also support automatically fixing all errors running by adding
--fix:

./mach lint -l android-format --fix

This change also removes all the formatting-related checkstyle checks which are
now implicitly enforced by the formatter.

Differential Revision: https://phabricator.services.mozilla.com/D127734
2021-10-11 18:11:55 +00:00

28 lines
658 B
ReStructuredText

Spotless
========
`Spotless <https://github.com/diffplug/spotless>`__ is a pluggable formatter
for Gradle and Android.
In our current configuration, Spotless includes the
`Google Java Format plug-in https://github.com/google/google-java-format`__
which formats all our Java code using the Google Java coding style guidelines.
Run Locally
-----------
The mozlint integration of spotless can be run using mach:
.. parsed-literal::
$ mach lint --linter android-format
Alternatively, omit the ``--linter android-format`` and run all configured linters, which will include
spotless.
Autofix
-------
The spotless linter provides a ``--fix`` option.