|
| 1 | +//// SNIPPET:LINT |
| 2 | +// === Autoformatting |
| 3 | +// |
| 4 | +// To autoformat your Java code with |
| 5 | +// https://github.com/palantir/palantir-java-format[Palantir Java Format], you |
| 6 | +// can run `./mill mill.javalib.palantirformat/` as shown below: |
| 7 | + |
| 8 | +/** Usage |
| 9 | + |
| 10 | +> cat src/foo/Foo.java |
| 11 | +package foo; |
| 12 | +public class Foo { |
| 13 | +public static void main(String[] args) { |
| 14 | +System.out.println("Hello World"); |
| 15 | +new java.util.HashSet<Short>().remove(1); |
| 16 | +} |
| 17 | +} |
| 18 | + |
| 19 | +> ./mill mill.javalib.palantirformat/ |
| 20 | +formatting 1 java sources ... |
| 21 | + |
| 22 | +> cat src/foo/Foo.java |
| 23 | +package foo; |
| 24 | +public class Foo { |
| 25 | + public static void main(String[] args) { |
| 26 | + System.out.println("Hello World"); |
| 27 | + new java.util.HashSet<Short>().remove(1); |
| 28 | + } |
| 29 | +} |
| 30 | + |
| 31 | +*/ |
| 32 | + |
| 33 | +// See xref:javalib/linting.adoc#_autoformatting_with_palantir_java_format[Autoformatting with Palantir Java Format] for more information. |
| 34 | +// Apart from Palantir Format, Mill also comes with |
| 35 | +// xref:javalib/linting.adoc#_auto_formatting_with_spotless[mill.javalib.spotless.SpotlessModule] |
| 36 | +// that can also be used |
| 37 | + |
| 38 | +// === Autofixing |
| 39 | + |
| 40 | +// To lint your code with https://errorprone.info/index[ErrorProne], you can |
| 41 | +// make yor module extend `mill.javalib.errorprone.ErrorProneModule`, which will |
| 42 | +// run errorprone lint checks every time you `compile` that module. |
| 43 | + |
| 44 | +/** See Also: build.mill.yaml */ |
| 45 | +/** Usage |
| 46 | + |
| 47 | +> ./mill compile |
| 48 | +.../src/foo/Foo.java:6:42: [CollectionIncompatibleType]... |
| 49 | +...Argument '1' should not be passed to this method... |
| 50 | +...its type int is not compatible with its collection's type argument Short |
| 51 | +[warn] (see https://errorprone.info/bugpattern/CollectionIncompatibleType) |
| 52 | +[warn] new java.util.HashSet<Short>().remove(1) |
| 53 | +[warn] ^ |
| 54 | + |
| 55 | +*/ |
| 56 | + |
| 57 | +// See xref:javalib/linting.adoc#_linting_with_errorprone[Linting with ErrorProne] for more |
| 58 | +// details on how ErrorProne can be configured. Apart from ErrorProne, Mill also comes with |
| 59 | +// xref:javalib/linting.adoc#_linting_with_checkstyle[mill.contrib.checkstyle.CheckstyleModule] and |
| 60 | +// xref:javalib/linting.adoc#_static_analysis_with_pmd[mill.javalib.pmd.PmdModule] |
0 commit comments