Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,5 @@ class ArtifactoryHttpApi(
}

private def base64(s: String) =
new String(Base64.getEncoder.encode(s.getBytes))
String(Base64.getEncoder.encode(s.getBytes))
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ trait ArtifactoryPublishModule extends PublishModule {
connectTimeout: Int = 5000
): Command[Unit] = Task.Command {
val (artifacts, artifactInfo) = publishArtifacts().withConcretePath
new ArtifactoryPublisher(
ArtifactoryPublisher(
artifactoryUri,
artifactorySnapshotUri,
checkArtifactoryCreds(credentials)(),
Expand Down Expand Up @@ -64,7 +64,7 @@ object ArtifactoryPublishModule extends ExternalModule {
val artifacts = Task.sequence(publishArtifacts.value)().map {
case data @ PublishModule.PublishData(_, _) => data.withConcretePath
}
new ArtifactoryPublisher(
ArtifactoryPublisher(
artifactoryUri,
artifactorySnapshotUri,
checkArtifactoryCreds(credentials)(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class ArtifactoryPublisher(

private def prepareCreds(credentials: String, repoUri: String): String = {
if (credentials.isEmpty) {
val hostname = new URI(repoUri).getHost
val hostname = URI(repoUri).getHost
val coursierCreds = CoursierConfig.default().credentials.map(_.get).flatten
coursierCreds.find(cred =>
cred.host == hostname && cred.usernameOpt.isDefined && cred.passwordOpt.isDefined
Expand Down Expand Up @@ -63,7 +63,7 @@ class ArtifactoryPublisher(
payloads: Map[os.SubPath, Array[Byte]],
artifacts: Seq[Artifact]
): Unit = {
val api = new ArtifactoryHttpApi(
val api = ArtifactoryHttpApi(
credentials = prepareCreds(credentials, repoUri),
readTimeout = readTimeout,
connectTimeout = connectTimeout
Expand All @@ -87,7 +87,7 @@ class ArtifactoryPublisher(
val errors = publishResults.filterNot(_.is2xx).map { response =>
s"Code: ${response.statusCode}, message: ${response.text()}"
}
throw new RuntimeException(
throw RuntimeException(
s"Failed to publish ${artifacts.map(_.id).mkString(", ")} to Artifactory. Errors: \n${errors.mkString("\n")}"
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class CodeartifactPublisher(
connectTimeout: Int,
log: Logger
) {
private val api = new CodeartifactHttpApi(
private val api = CodeartifactHttpApi(
credentials,
readTimeout = readTimeout,
connectTimeout = connectTimeout
Expand Down Expand Up @@ -112,7 +112,7 @@ class CodeartifactPublisher(
val errors = publishResults.filterNot(_.is2xx).map { response =>
s"Code: ${response.statusCode}, message: ${response.text()}"
}
throw new RuntimeException(
throw RuntimeException(
s"Failed to publish ${artifacts.map(_.id).mkString(", ")} to AWS Codeartifact. Errors: \n${errors
.mkString("\n")}"
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class CodeartifactHttpApi(
uri,
readTimeout = uploadTimeout,
headers = Seq("Content-Type" -> "application/octet-stream"),
auth = new requests.RequestAuth.Basic("aws", credentials),
auth = requests.RequestAuth.Basic("aws", credentials),
data = data
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ trait CodeartifactPublishModule extends PublishModule {

val (artifacts, artifactInfo) = publishArtifacts().withConcretePath

new CodeartifactPublisher(
CodeartifactPublisher(
codeartifactUri,
codeartifactSnapshotUri,
credentials,
Expand All @@ -47,7 +47,7 @@ object CodeartifactPublishModule extends ExternalModule {
) =
Task.Command {
val artifacts = Task.sequence(publishArtifacts.value)().map(_.withConcretePath)
new CodeartifactPublisher(
CodeartifactPublisher(
codeartifactUri,
codeartifactSnapshotUri,
credentials,
Expand Down
2 changes: 1 addition & 1 deletion contrib/flyway/src/mill/contrib/flyway/ConsoleLog.scala
Original file line number Diff line number Diff line change
Expand Up @@ -56,5 +56,5 @@ class ConsoleLog(val level: ConsoleLog.Level.Level) extends Log {
* Log Creator for the Command-Line console.
*/
class ConsoleLogCreator(val level: ConsoleLog.Level.Level) extends LogCreator {
override def createLogger(clazz: Class[?]): Log = new ConsoleLog(level)
override def createLogger(clazz: Class[?]): Log = ConsoleLog(level)
}
2 changes: 1 addition & 1 deletion contrib/flyway/src/mill/contrib/flyway/FlywayModule.scala
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ trait FlywayModule extends JavaModule {
strToOptPair(flyway.USER, flywayUser()) ++
strToOptPair(flyway.PASSWORD, flywayPassword())

LogFactory.setLogCreator(new ConsoleLogCreator(Level.INFO))
LogFactory.setLogCreator(ConsoleLogCreator(Level.INFO))

Flyway
.configure(jdbcClassloader)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ trait GitlabPublishModule extends PublishModule { outer =>
if (skipPublish) {
Task.log.info(s"SkipPublish = true, skipping publishing of $artifactInfo")
} else {
val uploader = new GitlabUploader(gitlabHeaders()(), readTimeout, connectTimeout)
new GitlabPublisher(
val uploader = GitlabUploader(gitlabHeaders()(), readTimeout, connectTimeout)
GitlabPublisher(
uploader.upload,
gitlabRepo,
Task.log
Expand All @@ -66,9 +66,9 @@ object GitlabPublishModule extends ExternalModule {
val artifacts = Task.sequence(publishArtifacts.value)().map {
case data @ PublishModule.PublishData(_, _) => data.withConcretePath
}
val uploader = new GitlabUploader(auth, readTimeout, connectTimeout)
val uploader = GitlabUploader(auth, readTimeout, connectTimeout)

new GitlabPublisher(
GitlabPublisher(
uploader.upload,
repo,
Task.log
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class GitlabPublisher(
s"Code: ${response.statusCode}, message: ${response.text()}"
}
// Or just log? Fail later?
throw new RuntimeException(
throw RuntimeException(
s"Failed to publish $artifact to Gitlab. Errors: \n${errors.mkString("\n")}"
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,14 +127,14 @@ object GitlabTokenTests extends TestSuite {
object uploader extends ((String, Array[Byte]) => requests.Response) {
def apply(url: String, data: Array[Byte]): requests.Response = {
urls.append(url)
requests.Response(url, 200, "Success", new geny.Bytes("".getBytes()), Map.empty, None)
requests.Response(url, 200, "Success", geny.Bytes("".getBytes()), Map.empty, None)
}

val urls: ListBuffer[String] = ListBuffer[String]()
}

val repo = ProjectRepository("https://gitlab.local", 10)
val publisher = new GitlabPublisher(uploader, repo, DummyLogger)
val publisher = GitlabPublisher(uploader, repo, DummyLogger)

val fakeFile = os.pwd / "dummy.data"
os.write(fakeFile, Array[Byte]())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import mill.api.{Discover, ExternalModule}

trait RouteCompilerWorkerModule extends Module {
def routeCompilerWorker: Worker[RouteCompilerWorker] = Task.Worker {
new RouteCompilerWorker()
RouteCompilerWorker()
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class HomeControllerSpec extends PlaySpec with GuiceOneAppPerTest with Injecting
"HomeController GET" should {

"render the index page from a new instance of controller" in {
val controller = new HomeController(stubControllerComponents())
val controller = HomeController(stubControllerComponents())
val home = controller.index().apply(FakeRequest(GET, "/"))

status(home) mustBe OK
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class HomeControllerSpec extends PlaySpec with GuiceOneAppPerTest with Injecting
"HomeController GET" should {

"render the index page from a new instance of controller" in {
val controller = new HomeController(stubControllerComponents())
val controller = HomeController(stubControllerComponents())
val home = controller.index().apply(FakeRequest(GET, "/"))

status(home) mustBe OK
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class HomeControllerSpec extends PlaySpec with GuiceOneAppPerTest with Injecting
"HomeController GET" should {

"render the index page from a new instance of controller" in {
val controller = new HomeController(stubControllerComponents())
val controller = HomeController(stubControllerComponents())
val home = controller.index().apply(FakeRequest(GET, "/"))

status(home) mustBe OK
Expand Down
2 changes: 1 addition & 1 deletion contrib/sbom/src/mill/contrib/sbom/CycloneDX.scala
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ object CycloneDX {
val md = MessageDigest.getInstance("SHA-256")
val fileContent = os.read.bytes(f)
val digest = md.digest(fileContent)
String.format("%0" + (digest.length << 1) + "x", new BigInteger(1, digest))
String.format("%0" + (digest.length << 1) + "x", BigInteger(1, digest))
}

case class SbomHeader(serialNumber: UUID, timestamp: Instant)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ trait ScalaPBModule extends ScalaModule {
val cp = scalaPBProtoClasspath()
val dest = Task.dest
cp.iterator.foreach { ref =>
Using(new ZipInputStream(ref.path.getInputStream)) { zip =>
Using(ZipInputStream(ref.path.getInputStream)) { zip =>
while ({
Option(zip.getNextEntry) match {
case None => false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ trait ScalaPBWorkerApi {
}

object ScalaPBWorkerApi extends ExternalModule {
def scalaPBWorker: Task.Worker[ScalaPBWorker] = Task.Worker { new ScalaPBWorker() }
def scalaPBWorker: Task.Worker[ScalaPBWorker] = Task.Worker { ScalaPBWorker() }
lazy val millDiscover = Discover[this.type]
}
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,6 @@ object ScoverageReportWorker extends ExternalModule {
}

def scoverageReportWorker: Task.Worker[ScoverageReportWorker] =
Task.Worker { new ScoverageReportWorker() }
Task.Worker { ScoverageReportWorker() }
lazy val millDiscover = Discover[this.type]
}
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ class ScoverageReportWorkerImpl extends ScoverageReportWorkerApi2 {

if (errors.nonEmpty) {
// Throw exception with all error messages
throw new RuntimeException(
throw RuntimeException(
s"Coverage minimums violated:\n${errors.mkString("\n")}"
)
} else {
Expand Down Expand Up @@ -126,13 +126,13 @@ class ScoverageReportWorkerImpl extends ScoverageReportWorkerApi2 {
ScoverageReportWorkerApi2.makeAllDirs(folder)
reportType match {
case ReportType.Html =>
new ScoverageHtmlWriter(sourceFolders, folder.toFile, None)
ScoverageHtmlWriter(sourceFolders, folder.toFile, None)
.write(coverage)
case ReportType.Xml =>
new ScoverageXmlWriter(sourceFolders, folder.toFile, false, None)
ScoverageXmlWriter(sourceFolders, folder.toFile, false, None)
.write(coverage)
case ReportType.XmlCobertura =>
new CoberturaXmlWriter(sourceFolders, folder.toFile, None)
CoberturaXmlWriter(sourceFolders, folder.toFile, None)
.write(coverage)
case ReportType.Console =>
ctx.log.info(s"Statement coverage.: ${coverage.statementCoverageFormatted}%")
Expand Down
8 changes: 4 additions & 4 deletions contrib/twirllib/src/mill/twirllib/TwirlWorker.scala
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ object TwirlWorker {
// * the java api uses java collections, manipulating which using reflection is much simpler
//
// NOTE: When creating the cl classloader with passing the current classloader as the parent:
// val cl = new URLClassLoader(twirlClasspath.map(_.toIO.toURI.toURL).toArray, getClass.getClassLoader)
// val cl = URLClassLoader(twirlClasspath.map(_.toIO.toURI.toURL).toArray, getClass.getClassLoader)
// it is possible to cast the default to a Seq[String], construct our own Seq[String], and pass it to the method invoke -
// classes will be compatible (the tests passed).
// But when run in an actual mill project with this module enabled, there were exceptions like this:
Expand Down Expand Up @@ -63,7 +63,7 @@ object TwirlWorker {
codec: Codec,
inclusiveDot: Boolean
): Unit = {
// val twirlImports = new HashSet()
// val twirlImports = HashSet()
// imports.foreach(twirlImports.add)
val twirlImports = hashSetClass.getConstructor().newInstance().asInstanceOf[Object]
val hashSetAddMethod = twirlImports.getClass.getMethod("add", classOf[Object])
Expand All @@ -73,7 +73,7 @@ object TwirlWorker {
val twirlCodec =
codecApplyMethod.invoke(null, charsetForNameMethod.invoke(null, codec.charSet.name()))

// val twirlConstructorAnnotations = new ArrayList()
// val twirlConstructorAnnotations = ArrayList()
// constructorAnnotations.foreach(twirlConstructorAnnotations.add)
val twirlConstructorAnnotations =
arrayListClass.getConstructor().newInstance().asInstanceOf[Object]
Expand Down Expand Up @@ -169,7 +169,7 @@ object TwirlWorker {

private def twirlExtensionClass(name: String, formats: Map[String, String]) =
formats.collectFirst { case (ext, klass) if name.endsWith(ext) => klass }.getOrElse {
throw new IllegalStateException(
throw IllegalStateException(
s"Unknown twirl extension for file: $name. Known extensions: ${formats.keys.mkString(", ")}"
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ sealed trait Version {
case Bump.minor => (major, minor + 1, 0)
case Bump.patch => (major, minor, patch + 1)
case _ =>
throw new RuntimeException(s"Valid arguments for bump are: ${Bump.values.mkString(", ")}")
throw RuntimeException(s"Valid arguments for bump are: ${Bump.values.mkString(", ")}")
}

this match {
Expand Down
12 changes: 6 additions & 6 deletions core/api/daemon/src/mill/api/daemon/ExecResult.scala
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ object ExecResult {
try Success(t)
catch {
case e: Throwable =>
Exception(e, new OuterStack(new java.lang.Exception().getStackTrace.toIndexedSeq))
Exception(e, OuterStack(java.lang.Exception().getStackTrace.toIndexedSeq))
}
}

Expand Down Expand Up @@ -68,7 +68,7 @@ object ExecResult {

override def asFailing: Option[ExecResult.Failing[T]] = Some(this)
def throwException: Nothing = this match {
case f: ExecResult.Failure[?] => throw new Result.Exception(f.msg)
case f: ExecResult.Failure[?] => throw Result.Exception(f.msg)
case f: ExecResult.Exception => throw f.throwable
}
}
Expand Down Expand Up @@ -106,7 +106,7 @@ object ExecResult {
val formatted =
// for some reason .map without the explicit ArrayOps conversion doesn't work,
// and results in `ExecResult[String]` instead of `Array[String]`
new scala.collection.ArrayOps(elements).map(" " + _)
scala.collection.ArrayOps(elements).map(" " + _)
Seq(ex.toString) ++ formatted

}
Expand All @@ -129,14 +129,14 @@ object ExecResult {
try Result.Success(t)
catch {
case e: InvocationTargetException =>
Result.Failure(makeResultException(e.getCause, new java.lang.Exception()).left.get)
Result.Failure(makeResultException(e.getCause, java.lang.Exception()).left.get)
case e: java.lang.Exception =>
Result.Failure(makeResultException(e, new java.lang.Exception()).left.get)
Result.Failure(makeResultException(e, java.lang.Exception()).left.get)
}
}

def makeResultException(e: Throwable, base: java.lang.Exception): Left[String, Nothing] = {
val outerStack = new ExecResult.OuterStack(base.getStackTrace)
val outerStack = ExecResult.OuterStack(base.getStackTrace)
Left(ExecResult.Exception(e, outerStack).toString)
}
}
8 changes: 4 additions & 4 deletions core/api/daemon/src/mill/api/daemon/Logger.scala
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,10 @@ object Logger {
object DummyLogger extends Logger {
def colored = false

val streams = new SystemStreams(
new PrintStream(_ => ()),
new PrintStream(_ => ()),
new ByteArrayInputStream(Array())
val streams = SystemStreams(
PrintStream(_ => ()),
PrintStream(_ => ()),
ByteArrayInputStream(Array())
)

def info(s: String) = ()
Expand Down
4 changes: 2 additions & 2 deletions core/api/daemon/src/mill/api/daemon/MillURLClassLoader.scala
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ object MillURLClassLoader {

private[mill] def addOpenClassloader(label: String) =
openClassloaders.synchronized {
// println(s"addOpenClassLoader ${classPath.hashCode}\n " + new Exception().getStackTrace.mkString("\n "))
// println(s"addOpenClassLoader ${classPath.hashCode}\n " + Exception().getStackTrace.mkString("\n "))

openClassloaders.updateWith(label) {
case None => Some(1)
Expand All @@ -81,7 +81,7 @@ object MillURLClassLoader {

private[mill] def removeOpenClassloader(label: String) =
openClassloaders.synchronized {
// println(s"removeOpenClassLoader ${classPath.hashCode}\n " + new Exception().getStackTrace.mkString("\n "))
// println(s"removeOpenClassLoader ${classPath.hashCode}\n " + Exception().getStackTrace.mkString("\n "))
openClassloaders.updateWith(label) {
case Some(1) => None
case Some(n) => Some(n - 1)
Expand Down
6 changes: 3 additions & 3 deletions core/api/daemon/src/mill/api/daemon/Segments.scala
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ final case class Segments private (value: Seq[Segment]) {
def last: Segment.Label = value.last match {
case l: Segment.Label => l
case _ =>
throw new IllegalArgumentException("Segments must end with a Label, but found a Cross.")
throw IllegalArgumentException("Segments must end with a Label, but found a Cross.")
}

def parts: List[String] = value.flatMap(_.pathSegments).toList
Expand Down Expand Up @@ -58,7 +58,7 @@ final case class Segments private (value: Seq[Segment]) {

object Segments {
implicit def ordering: Ordering[Segments] = Ordering.by(_.value)
def apply(): Segments = new Segments(Vector())
def apply(items: Seq[Segment]): Segments = new Segments(items.toVector)
def apply(): Segments = Segments(Vector())
def apply(items: Seq[Segment]): Segments = Segments(items.toVector)
def labels(values: String*): Segments = Segments(values.map(Segment.Label(_)).toVector)
}
Loading
Loading