polystat / polystat-cli

MIT License
5 stars 3 forks source link

CLI fails when file from `--to file` is missing #24

Open mximp opened 2 years ago

mximp commented 2 years ago

Running polystat-cli with the following command:

sudo java -jar polystat.jar eo --in temp/sources/eo --to file=results/polystat-eo-out.txt --sarif

Got exception:

java.lang.Exception: results/polystat-eo-out.txt is either not a regular file or does not exist!
    at org.polystat.cli.util.FileTypes$File$.fromPathFailFast$$anonfun$2(FileTypes.scala:63)
    at delay @ fs2.io.file.FilesCompanionPlatform$AsyncFiles.isRegularFile(FilesPlatform.scala:273)
    at ifM @ org.polystat.cli.util.FileTypes$Directory$.fromPath(FileTypes.scala:23)
    at flatMap @ org.polystat.cli.util.FileTypes$File$.fromPathFailFast(FileTypes.scala:66)
    at map @ org.polystat.cli.PolystatOpts$.files$$anonfun$1$$anonfun$1$$anonfun$1(PolystatOpts.scala:209)
    at map @ org.polystat.cli.PolystatOpts$.files$$anonfun$1$$anonfun$1$$anonfun$1(PolystatOpts.scala:216)
    at flatMap @ org.polystat.cli.PolystatOpts$.files$$anonfun$1$$anonfun$1(PolystatOpts.scala:216)
    at map @ org.polystat.cli.PolystatOpts$.analyzerConfig$$anonfun$1$$anonfun$1$$anonfun$2(PolystatOpts.scala:227)
    at flatMap @ org.polystat.cli.PolystatOpts$.analyzerConfig$$anonfun$1$$anonfun$1(PolystatOpts.scala:227)
    at delay @ fs2.io.file.FilesCompanionPlatform$AsyncFiles.isDirectory(FilesPlatform.scala:256)
    at ifM @ org.polystat.cli.util.FileTypes$Directory$.fromPath(FileTypes.scala:23)
    at flatMap @ org.polystat.cli.util.InputUtils$.toInput(InputUtils.scala:51)
    at flatMap @ org.polystat.cli.PolystatOpts$.analyzerConfig$$anonfun$1(PolystatOpts.scala:227)
    at map @ org.polystat.cli.PolystatOpts$.analyzeEO$$anonfun$1(PolystatOpts.scala:41)
    at flatMap @ org.polystat.cli.Main$.run$$anonfun$1(Main.scala:31)
    at as @ org.polystat.cli.Main$.run$$anonfun$1(Main.scala:31)
    at map @ com.monovore.decline.effect.CommandIOApp$.run$$anonfun$4(CommandIOApp.scala:40)

If empty file results/polystat-eo-out.txt is created beforehand, the run succeed.

I would assume the out file should be automatically created in this case.

Test environment:

nikololiahim commented 2 years ago

@mximp Thank you for reporting! According to release logs, this issue should be fixed in versions >= 0.1.12.