Skip to content

Commit 9458684

Browse files
committed
#13 is fixed, cleaning directories before writing
1 parent 21e7ac1 commit 9458684

File tree

4 files changed

+24
-9
lines changed

4 files changed

+24
-9
lines changed

.scalafmt.conf

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ version = "3.5.2"
22
runner.dialect = scala3
33
trailingCommas = multiple
44
rewrite.scala3.convertToNewSyntax = yes
5-
rewrite.scala3.insertEndMarkerMinLines = 4
5+
# FIXME: this line causes EO.scala to fail
6+
# rewrite.scala3.insertEndMarkerMinLines = 4
67
rewrite.scala3.removeOptionalBraces = oldSyntaxToo
78
project.git = true
89

src/main/scala/org/polystat/EO.scala

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,10 @@ object EO:
4444
cfg.output.dirs.traverse_(out =>
4545
val outPath =
4646
out / "sarif" / codePath.replaceExt(".sarif.json")
47-
48-
IO.println(s"Writing results to $outPath") *>
49-
writeOutputTo(outPath)(sarifJson)
47+
for
48+
_ <- IO.println(s"Writing results to $outPath")
49+
_ <- writeOutputTo(outPath)(sarifJson)
50+
yield ()
5051
)
5152
}
5253
yield ()
@@ -68,6 +69,16 @@ object EO:
6869
}
6970
}
7071

71-
analyzeToDirs *> analyzeAggregate
72+
for
73+
_ <- cfg.output.dirs.traverse_ { outDir =>
74+
for
75+
_ <- IO.println(s"Cleaning $outDir before writing...")
76+
_ <- outDir.clean
77+
yield ()
78+
}
79+
_ <- analyzeToDirs
80+
_ <- analyzeAggregate
81+
yield ()
82+
end for
7283
end analyze
7384
end EO

src/main/scala/org/polystat/InputUtils.scala

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,12 @@ object InputUtils:
2020
._1 + newExt
2121
)
2222

23+
def clean: IO[Path] =
24+
for
25+
_ <- Files[IO].deleteRecursively(path)
26+
_ <- Files[IO].createDirectory(path)
27+
yield path
28+
2329
def toInput: IO[Input] =
2430
Files[IO]
2531
.isDirectory(path)

src/main/scala/org/polystat/Main.scala

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,7 @@ object Main extends IOApp:
7272
filteredAnalyzers = filterAnalyzers(inex),
7373
tempDir = tmp match
7474
case Some(path) =>
75-
(IO.println(s"Cleaning ${path.absolute}...") *>
76-
Files[IO].deleteRecursively(path) *>
77-
Files[IO].createDirectory(path))
78-
.as(path)
75+
IO.println(s"Cleaning ${path.absolute}...") *> path.clean
7976
case None => Files[IO].createTempDirectory
8077
,
8178
output = out,

0 commit comments

Comments
 (0)