@@ -9,9 +9,11 @@ import org.polystat.odin.analysis.EOOdinAnalyzer
99import org .polystat .odin .parser .EoParser .sourceCodeEoParser
1010import org .polystat .sarif .AggregatedSarifOutput
1111import org .polystat .sarif .SarifOutput
12+ import fs2 .io .file .Path
1213
1314import PolystatConfig .*
1415import InputUtils .*
16+ import org .polystat .odin .analysis .EOOdinAnalyzer .OdinAnalysisResult
1517
1618object EO :
1719
@@ -27,60 +29,60 @@ object EO:
2729 val inputFiles = readCodeFromInput(" .eo" , cfg.input)
2830 val analyzed = inputFiles
2931 .evalMap { case (codePath, code) =>
30- for analyzed <- runAnalyzers(cfg.filteredAnalyzers)(code)
32+ for
33+ _ <- IO .println(s " Analyzing $codePath... " )
34+ analyzed <- runAnalyzers(cfg.filteredAnalyzers)(code)
3135 yield (codePath, analyzed)
3236 }
3337 .compile
3438 .toVector
35- .map(_.toMap)
36- val analyzeToDirs = inputFiles
37- .evalMap { case (codePath, code ) =>
39+
40+ def writeToDirs ( analyzed : Vector [( Path , List [ OdinAnalysisResult ])]) =
41+ analyzed.traverse_ { case (codePath, results ) =>
3842 for
39- _ <- IO .println(s " Analyzing $codePath... " )
40- analyzed <- runAnalyzers(cfg.filteredAnalyzers)(code)
4143 _ <- if cfg.output.console then IO .println(analyzed) else IO .unit
4244 _ <- cfg.fmts.traverse_ { case OutputFormat .Sarif =>
4345 val sarifJson = SarifOutput (
4446 codePath,
45- analyzed ,
47+ results ,
4648 ).json.toString
4749 cfg.output.dirs.traverse_(out =>
4850 val outPath =
4951 out / " sarif" / codePath.replaceExt(" .sarif.json" )
5052 for
51- _ <- IO .println(s " Writing results to $outPath" )
53+ _ <- IO .println(s " Writing results to $outPath... " )
5254 _ <- writeOutputTo(outPath)(sarifJson)
5355 yield ()
5456 )
5557 }
5658 yield ()
5759 }
58- .compile
59- .drain
60- val analyzeAggregate = cfg.output.files.traverse_ { outputPath =>
61- cfg.fmts.traverse_ { case OutputFormat .Sarif =>
62- for
63- _ <- IO .println(s " Writing aggregated output to $outputPath... " )
64- analyzed <- analyzed
65- sariOutput = AggregatedSarifOutput
66- .fromAnalyzed(analyzed)
67- .asJson
68- .deepDropNullValues
69- .toString
70- _ <- writeOutputTo(outputPath)(sariOutput )
71- yield ()
60+
61+ def writeAggregate ( analyzed : Vector [( Path , List [ OdinAnalysisResult ])]) =
62+ cfg.output.files.traverse_ { outputPath =>
63+ cfg.fmts.traverse_ { case OutputFormat .Sarif =>
64+ for
65+ _ <- IO .println(s " Writing aggregated output to $outputPath... " )
66+ sariOutput = AggregatedSarifOutput
67+ .fromAnalyzed(analyzed)
68+ .asJson
69+ .deepDropNullValues
70+ .toString
71+ _ <- writeOutputTo(outputPath)(sariOutput)
72+ yield ( )
73+ }
7274 }
73- }
7475
7576 for
77+ analyzed <- analyzed
7678 _ <- cfg.output.dirs.traverse_ { outDir =>
7779 for
7880 _ <- IO .println(s " Cleaning $outDir before writing... " )
7981 _ <- outDir.clean
8082 yield ()
8183 }
82- _ <- analyzeToDirs
83- _ <- analyzeAggregate
84+ _ <- writeToDirs(analyzed)
85+ _ <- writeAggregate(analyzed)
8486 yield ()
8587 end for
8688 end analyze
0 commit comments