Skip to content

Commit c43fb0b

Browse files
committed
Changed Iterable to List
1 parent 8c1a262 commit c43fb0b

File tree

8 files changed

+27
-26
lines changed

8 files changed

+27
-26
lines changed

src/main/scala/codacy/dockerApi/DockerEngine.scala

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,21 @@ abstract class DockerEngine(Tool: Tool) {
1414

1515
def initTimeout(duration: FiniteDuration) = {
1616
implicit val ct: ExecutionContext = sys.dispatcher
17-
sys.scheduler.scheduleOnce(duration){
18-
Runtime.getRuntime().halt(2)
17+
sys.scheduler.scheduleOnce(duration) {
18+
Runtime.getRuntime.halt(2)
1919
}
2020
}
2121

22-
lazy val timeout = Option(System.getProperty("timeout")).flatMap{ case rawDuration =>
23-
Try(Duration(rawDuration)).toOption.collect{ case d:FiniteDuration => d }
22+
lazy val timeout = Option(System.getProperty("timeout")).flatMap { case rawDuration =>
23+
Try(Duration(rawDuration)).toOption.collect { case d: FiniteDuration => d }
2424
}.getOrElse(30.minutes)
2525

26-
lazy val isDebug = Option(System.getProperty("debug")).flatMap{ case rawDebug =>
26+
lazy val isDebug = Option(System.getProperty("debug")).flatMap { case rawDebug =>
2727
Try(rawDebug.toBoolean).toOption
2828
}.getOrElse(false)
2929

30-
def log(message:String):Unit = if(isDebug){
31-
Console.err.print(s"[DockerEngine] $message")
30+
def log(message: String): Unit = if (isDebug) {
31+
Console.err.println(s"[DockerEngine] $message")
3232
}
3333

3434
def main(args: Array[String]): Unit = {
@@ -64,6 +64,7 @@ abstract class DockerEngine(Tool: Tool) {
6464
logResult(relativeIssue)
6565
}
6666
log("tool finished")
67+
System.exit(0)
6768
case Failure(error) =>
6869
error.printStackTrace(Console.err)
6970
System.exit(1)

src/main/scala/codacy/dockerApi/DockerEnvironment.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ object DockerEnvironment {
3030
}
3131

3232
private[this] def asFailure(error: Seq[(JsPath, Seq[ValidationError])]) =
33-
Failure(new Throwable(Json.stringify(JsError.toFlatJson(error))))
33+
Failure(new Throwable(Json.stringify(JsError.toFlatJson(error.toList))))
3434

3535
private[this] lazy val configFilePath = sourcePath.resolve(".codacy.json")
3636

src/main/scala/codacy/dockerApi/package.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ abstract class Formats[W <: AnyVal {val value : B}, B](apply_ : (B => W)) extend
2222
}
2323

2424
trait Tool {
25-
def apply(path: Path, conf: Option[Seq[PatternDef]], files: Option[Set[Path]])(implicit spec: Spec): Try[Iterable[Result]]
25+
def apply(path: Path, conf: Option[List[PatternDef]], files: Option[Set[Path]])(implicit spec: Spec): Try[List[Result]]
2626
}
2727

2828
final class PatternId(val value: String) extends AnyVal {
@@ -71,7 +71,7 @@ case class ParameterDef(name: ParameterName, value: JsValue)
7171

7272
case class PatternDef(patternId: PatternId, parameters: Option[Set[ParameterDef]])
7373

74-
case class ToolConfig(name: ToolName, patterns: Seq[PatternDef])
74+
case class ToolConfig(name: ToolName, patterns: List[PatternDef])
7575

7676
case class FullConfig(tools: Set[ToolConfig], files: Option[Set[SourcePath]])
7777

src/main/scala/codacy/dockerApi/utils/CommandRunner.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@ import scala.language.postfixOps
99
import scala.sys.process._
1010
import scala.util.{Failure, Success, Try}
1111

12-
case class CommandResult(exitCode: Int, stdout: Seq[String], stderr: Seq[String])
12+
case class CommandResult(exitCode: Int, stdout: List[String], stderr: List[String])
1313

1414
object CommandRunner {
1515

16-
def exec(cmd: Seq[String], dir: Option[File] = None): Either[Throwable, CommandResult] = {
16+
def exec(cmd: List[String], dir: Option[File] = None): Either[Throwable, CommandResult] = {
1717
val stdout = mutable.Buffer[String]()
1818
val stderr = mutable.Buffer[String]()
1919

@@ -23,7 +23,7 @@ object CommandRunner {
2323
case Success(process) =>
2424
Try(process.exitValue()) match {
2525
case Success(exitValue) =>
26-
Right(CommandResult(exitValue, stdout, stderr))
26+
Right(CommandResult(exitValue, stdout.toList, stderr.toList))
2727

2828
case Failure(e) =>
2929
process.destroy()

src/main/scala/codacy/dockerApi/utils/FileHelper.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,17 @@ object FileHelper {
2323
.stripPrefix("/")
2424
}
2525

26-
def listAllFiles(path: String): Seq[File] = {
26+
def listAllFiles(path: String): List[File] = {
2727
listAllFiles(Paths.get(path))
2828
}
2929

30-
def listAllFiles(path: Path): Seq[File] = {
30+
def listAllFiles(path: Path): List[File] = {
3131
recursiveListFiles(path.toFile)
3232
}
3333

34-
private def recursiveListFiles(file: File): Seq[File] = {
34+
private def recursiveListFiles(file: File): List[File] = {
3535
val these = file.listFiles
36-
these ++ these.filter(_.isDirectory).flatMap(recursiveListFiles)
36+
(these ++ these.filter(_.isDirectory).flatMap(recursiveListFiles)).toList
3737
}
3838

3939
}

src/main/scala/codacy/dockerApi/utils/ToolHelper.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import codacy.dockerApi._
44

55
object ToolHelper {
66

7-
def getPatternsToLint(conf: Option[Seq[PatternDef]])(implicit spec: Spec): Option[Seq[PatternDef]] = {
7+
def getPatternsToLint(conf: Option[List[PatternDef]])(implicit spec: Spec): Option[List[PatternDef]] = {
88
conf.map {
99
configuration =>
1010
configuration.map(pattern => getMissingParametersFromSpec(pattern))

src/test/scala/codacy/dockerApi/utils/CommandRunnerTest.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ import scala.collection.mutable.ArrayBuffer
77

88
class CommandRunnerTest extends FlatSpec with Matchers {
99

10-
val genericCMD = Seq("echo", "foo")
11-
val invalidCMD = Seq("rm", "nofile.ext")
12-
val errorCMD = Seq("rmzzz", "nofile.ext")
10+
val genericCMD = List("echo", "foo")
11+
val invalidCMD = List("rm", "nofile.ext")
12+
val errorCMD = List("rmzzz", "nofile.ext")
1313

1414
"CommandRunner" should "simpleEchoExec" in {
1515
val result: Either[Throwable, CommandResult] = CommandRunner.exec(genericCMD)

src/test/scala/codacy/dockerApi/utils/ToolHelperTest.scala

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ class ToolHelperTest extends FlatSpec with Matchers {
2121
val patternDef2NoParam = PatternDef(PatternId("id2"), None)
2222

2323
val genericSpec = codacy.dockerApi.Spec(ToolName("tool1"), patternsSpec)
24-
val genericConf: Option[Seq[PatternDef]] = Some(Seq(patternDef1, patternDef2))
25-
val genericConfNoParam: Option[Seq[PatternDef]] = Some(Seq(patternDef1NoParam, patternDef2NoParam))
24+
val genericConf: Option[List[PatternDef]] = Some(List(patternDef1, patternDef2))
25+
val genericConfNoParam: Option[List[PatternDef]] = Some(List(patternDef1NoParam, patternDef2NoParam))
2626

2727
"ToolHelper" should "getPatternsFromConf" in {
2828
val spec = genericSpec
@@ -44,11 +44,11 @@ class ToolHelperTest extends FlatSpec with Matchers {
4444

4545
"ToolHelper" should "getPatternsEmptyIfEmptyConf" in {
4646
val spec = genericSpec
47-
val conf: Option[Seq[PatternDef]] = Some(Seq())
47+
val conf: Option[List[PatternDef]] = Some(List())
4848

4949
val result = ToolHelper.getPatternsToLint(conf)(spec)
5050

51-
result should equal(Some(Seq()))
51+
result should equal(Some(List()))
5252
}
5353

5454
"ToolHelper" should "getParametersFromSpec" in {
@@ -59,7 +59,7 @@ class ToolHelperTest extends FlatSpec with Matchers {
5959
val expectedParamDef2 = ParameterDef(ParameterName("param2"), JsString("value2"))
6060
val expectedPatternDef1 = PatternDef(PatternId("id1"), Some(Set(expectedParamDef1, expectedParamDef2)))
6161
val expectedPatternDef2 = PatternDef(PatternId("id2"), None)
62-
val expectedResult = Some(Seq(expectedPatternDef1, expectedPatternDef2))
62+
val expectedResult = Some(List(expectedPatternDef1, expectedPatternDef2))
6363

6464
val result = ToolHelper.getPatternsToLint(conf)(spec)
6565

0 commit comments

Comments
 (0)