@@ -5,6 +5,7 @@ import fansi.Color.{Blue, Green, Red}
5
5
import java .io .File
6
6
import java .security .SecureRandom
7
7
8
+ import scala .annotation .tailrec
8
9
import scala .io .StdIn .readLine
9
10
import scala .util .Random
10
11
import scala .util .matching .Regex
@@ -28,8 +29,8 @@ case class Options(
28
29
29
30
enum Commands :
30
31
def context : Context
31
- def name = toString.takeWhile(_ != '(' )
32
- def log = this match {
32
+ def name : String = toString.takeWhile(_ != '(' )
33
+ def log : Any = this match {
33
34
case _ : Clear => " "
34
35
case Check (patterns, regex, _) =>
35
36
val kind = if regex then " regexes" else " patterns"
@@ -51,13 +52,13 @@ enum Commands:
51
52
case Clear (context : Context )
52
53
53
54
case class Context (file : os.RelPath , line : Int ):
54
- def proceed (linesToSkip : Int = 1 ) = copy(line = line + linesToSkip)
55
- override def toString = s " $file: $line"
55
+ def proceed (linesToSkip : Int = 1 ): Context = copy(line = line + linesToSkip)
56
+ override def toString = s " $file: $line"
56
57
57
58
case class FailedCheck (line : Int , file : os.RelPath , txt : String )
58
59
extends RuntimeException (s " [ $file: $line] $txt" )
59
60
60
- def check (cond : Boolean , msg : => String )(using c : Context ) =
61
+ def check (cond : Boolean , msg : => String )(using c : Context ): Unit =
61
62
if ! cond then throw FailedCheck (c.line, c.file, msg)
62
63
63
64
@ annotation.tailrec
@@ -197,10 +198,10 @@ def checkFile(file: os.Path, options: Options): Unit =
197
198
var lastOutput : String = null
198
199
val allSources = Set .newBuilder[os.Path ]
199
200
200
- def runCommand (cmd : Commands , log : String => Unit ) =
201
+ def runCommand (cmd : Commands , log : String => Unit ): Unit =
201
202
given Context = cmd.context
202
203
203
- def writeFile (file : os.Path , code : Seq [String ], c : Context ) =
204
+ def writeFile (file : os.Path , code : Seq [String ], c : Context ): Unit =
204
205
val (prefixLines, codeLines) =
205
206
code match
206
207
case shbang :: tail if shbang.startsWith(" #!" ) =>
@@ -254,7 +255,7 @@ def checkFile(file: os.Path, options: Options): Unit =
254
255
else
255
256
check(exitCode == 0 , s " Compilation failed. " )
256
257
257
- case Commands .Check (patterns, regex, line ) =>
258
+ case Commands .Check (patterns, regex, _ ) =>
258
259
check(lastOutput != null , " No output stored from previous commands" )
259
260
val lines = lastOutput.linesIterator.toList
260
261
@@ -282,7 +283,7 @@ def checkFile(file: os.Path, options: Options): Unit =
282
283
commands.foreach { cmd =>
283
284
val logs = List .newBuilder[String ]
284
285
285
- def printResult (success : Boolean , startTime : Long ) =
286
+ def printResult (success : Boolean , startTime : Long ): Unit =
286
287
val duration = System .currentTimeMillis - startTime
287
288
val commandName = s " [ ${cmd.name} in $duration ms] "
288
289
val cmdLog =
@@ -341,8 +342,8 @@ def checkFile(file: os.Path, options: Options): Unit =
341
342
342
343
os.list(out).filter(_.last.endsWith(" .scala" )).foreach(p => os.copy.into(p, exampleDir))
343
344
344
- @ main def check (args : String * ) =
345
- def processFiles (options : Options ) =
345
+ @ main def check (args : String * ): Unit =
346
+ def processFiles (options : Options ): Unit =
346
347
val paths = options.files.map { str =>
347
348
val path = os.Path (str, os.pwd)
348
349
assert(os.exists(path), s " Provided path $str does not exists in ${os.pwd}" )
@@ -382,6 +383,7 @@ def checkFile(file: os.Path, options: Options): Unit =
382
383
val Dest = PathParameter (" --dest" )
383
384
val StatusFile = PathParameter (" --status-file" )
384
385
386
+ @ tailrec
385
387
def parseArgs (args : Seq [String ], options : Options ): Options = args match
386
388
case Nil => options
387
389
case " --step" :: rest =>
0 commit comments