Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enforce ScalaFix unused imports and other things during PR validation #2918

Merged
merged 8 commits into from
Dec 12, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ jobs:
uses: ./.github/workflows/run-mill-action.yml
with:
java-version: '8'
millargs: mill.scalalib.scalafmt.ScalafmtModule/checkFormatAll __.sources
lefou marked this conversation as resolved.
Show resolved Hide resolved
millargs: -i __.fix && git diff --exit-code
lefou marked this conversation as resolved.
Show resolved Hide resolved

bincompat-check:
uses: ./.github/workflows/run-mill-action.yml
Expand Down
3 changes: 3 additions & 0 deletions .scalafix.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
rules = [
RemoveUnused
]
12 changes: 10 additions & 2 deletions build.sc
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@ import $ivy.`de.tototec::de.tobiasroeser.mill.vcs.version::0.4.0`
import $ivy.`com.github.lolgab::mill-mima::0.1.0`
import $ivy.`net.sourceforge.htmlcleaner:htmlcleaner:2.29`
import $ivy.`com.lihaoyi::mill-contrib-buildinfo:`
import $ivy.`com.goyeau::mill-scalafix::0.3.1`

// imports
import com.github.lolgab.mill.mima.{CheckDirection, ProblemFilter, Mima}
import coursier.maven.MavenRepository
import de.tobiasroeser.mill.vcs.version.VcsVersion
import com.goyeau.mill.scalafix.ScalafixModule
import mill._
import mill.api.JarManifest
import mill.define.NamedTask
Expand Down Expand Up @@ -317,10 +319,10 @@ trait MillPublishJavaModule extends MillJavaModule with PublishModule {
/**
* Some custom scala settings and test convenience
*/
trait MillScalaModule extends ScalaModule with MillJavaModule { outer =>
trait MillScalaModule extends ScalaModule with MillJavaModule with ScalafixModule{ outer =>
def scalaVersion = Deps.scalaVersion
def scalacOptions =
super.scalacOptions() ++ Seq("-deprecation", "-P:acyclic:force", "-feature", "-Xlint:unused")
super.scalacOptions() ++ Seq("-deprecation", "-P:acyclic:force", "-feature", "-Ywarn-unused:imports")
lefou marked this conversation as resolved.
Show resolved Hide resolved

def testIvyDeps: T[Agg[Dep]] = Agg(Deps.utest)
def testModuleDeps: Seq[JavaModule] =
Expand Down Expand Up @@ -820,6 +822,8 @@ object contrib extends Module {

// Worker for Scoverage 1.x
object worker extends MillPublishScalaModule {
// scoverage is on an old Scala version which doesnt support scalafix
def fix(args: String*): Command[Unit] = T.command{}
def compileModuleDeps = Seq(main.api)
def moduleDeps = Seq(scoverage.api)
def testDepPaths = T { Seq(compile().classes) }
Expand Down Expand Up @@ -1044,6 +1048,8 @@ object example extends MillScalaModule {
object web extends Cross[ExampleCrossModule](listIn(millSourcePath / "web"))

trait ExampleCrossModule extends IntegrationTestCrossModule {
// disable scalafix because these example modules don't have sources causing it to misbehave
def fix(args: String*): Command[Unit] = T.command{}
def testRepoRoot: T[PathRef] = T.source(millSourcePath)
def compile = example.compile()
def forkEnv = super.forkEnv() ++ Map("MILL_EXAMPLE_PARSED" -> upickle.default.write(parsed()))
Expand Down Expand Up @@ -1301,6 +1307,8 @@ object dist extends MillPublishJavaModule {
}

object dev extends MillPublishScalaModule {
// disable scalafix here because it crashes when a module has no sources
def fix(args: String*): Command[Unit] = T.command{}
def moduleDeps = Seq(runner, idea)

def testTransitiveDeps = super.testTransitiveDeps() ++ Seq(
Expand Down
Loading