-
-
Notifications
You must be signed in to change notification settings - Fork 390
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow external modules to have a
defaultCommandName
, simplify autof…
…ormatting and publishing docs (#3545) * Broke out `Linting_Scala_Projects` as a new top-level page in the docs, to match `Linting_Java_Projects`. Currently pretty spartan with just Scalafmt and links to Scoverage and Scalafix, but we can flesh it out over time * Updated the parser so you can now run `./mill mill.scalalib.ScalafmtModule/` and it runs `/reformatAll` by default, and set a default `__.sources` so you don't need to pass it in if you're happy with the default
- Loading branch information
Showing
19 changed files
with
166 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
= Linting Scala Projects | ||
|
||
++++ | ||
<script> | ||
gtag('config', 'AW-16649289906'); | ||
</script> | ||
++++ | ||
|
||
This page will discuss common topics around maintaining the code quality of Scala | ||
codebases using the Mill build tool | ||
|
||
== Autoformatting and Enforcement | ||
|
||
include::example/scalalib/linting/1-scalafmt.adoc[] | ||
|
||
== Scoverage Code Coverage | ||
|
||
Mill supports Scala code coverage analysis via the Scoverage contrib plugin. See the | ||
contrib plugin documentation for more details: | ||
|
||
* xref:contrib/scoverage.adoc[] | ||
|
||
== Scalafix Autofixes | ||
|
||
Scalafix is a tool that analyzes your Scala source code, performing intelligent analyses and | ||
code quality checks, and is often able to automatically fix the issues that it discovers. | ||
It can also perform automated refactoring. | ||
|
||
Mill supports Scalafix through the Mill-Scalafix third party module. See the module documentation | ||
for more details: | ||
|
||
* https://github.com/joan38/mill-scalafix |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Newer versions won't work with Java 8! | ||
version = "3.7.15" | ||
runner.dialect = scala213 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package build | ||
import mill._, scalalib._ | ||
|
||
object `package` extends RootModule with ScalaModule { | ||
def scalaVersion = "2.13.11" | ||
} | ||
|
||
/** See Also .scalafmt.conf */ | ||
|
||
// Mill supports code formatting via https://scalameta.org/scalafmt/[scalafmt] out of the box. | ||
// You can reformat your project's code globally with `mill mill.scalalib.scalafmt.ScalafmtModule/` command, | ||
// specific modules via `mill mill.scalalib.scalafmt.ScalafmtModule/ '{foo,bar}.sources` | ||
// or only check the code's format with `+mill mill.scalalib.scalafmt.ScalafmtModule/checkFormatAll`. | ||
// By default, ScalaFmt checks for a `.scalafmt.conf` file at the root of repository. | ||
|
||
/** Usage | ||
|
||
> cat src/Foo.scala # initial poorly formatted source code | ||
package foo | ||
object Foo{ | ||
def main(args: | ||
Array[String | ||
] | ||
):Unit= | ||
{println("hello world") | ||
} | ||
} | ||
|
||
|
||
> mill mill.scalalib.scalafmt.ScalafmtModule/checkFormatAll | ||
error: ...Found 1 misformatted files | ||
|
||
> mill mill.scalalib.scalafmt.ScalafmtModule/ | ||
|
||
> cat src/Foo.scala | ||
package foo | ||
object Foo { | ||
def main(args: Array[String]): Unit = { println("hello world") } | ||
} | ||
|
||
> mill mill.scalalib.scalafmt.ScalafmtModule/checkFormatAll | ||
Everything is formatted already | ||
|
||
*/ | ||
|
||
// You can modify `.scalafmt.conf` to adjust the formatting as desired: | ||
|
||
/** Usage | ||
> echo "maxColumn: 50" >> .scalafmt.conf | ||
|
||
> mill mill.scalalib.scalafmt.ScalafmtModule/ | ||
|
||
> cat src/Foo.scala | ||
package foo | ||
object Foo { | ||
def main(args: Array[String]): Unit = { | ||
println("hello world") | ||
} | ||
} | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package foo | ||
object Foo{ | ||
def main(args: | ||
Array[String | ||
] | ||
):Unit= | ||
{println("hello world") | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.