dnanexus / wdlTools

WDL tools for parsing, type-checking, and more
Apache License 2.0
25 stars 7 forks source link

format subcommand throws error when file ends in a comment #214

Open wholtz opened 2 years ago

wholtz commented 2 years ago
$ wdltools --version
wdlTools 0.17.8
$ cat test.wdl
version 1.0
workflow my_workflow {
  input { String message }
    call display { input: message=message }
}

task display {
  input { String message }
  command { printf '~{message}' }
}
# comment
$ wdltools check test.wdl
$ wdltools format test.wdl
[error] Command scallop failed
java.lang.IllegalArgumentException: requirement failed
    at scala.Predef$.require(Predef.scala:324)
    at wdlTools.generators.code.WdlFormatter$LineFormatter.endLine(WdlFormatter.scala:205)
    at wdlTools.generators.code.WdlFormatter$LineFormatter.maybeAppendFullLineComments(WdlFormatter.scala:311)
    at wdlTools.generators.code.WdlFormatter$LineFormatter.endSection(WdlFormatter.scala:173)
    at wdlTools.generators.code.WdlFormatter$DocumentSections.format(WdlFormatter.scala:1885)
    at wdlTools.generators.code.WdlFormatter.formatElement(WdlFormatter.scala:1898)
    at wdlTools.generators.code.WdlFormatter.formatDocument(WdlFormatter.scala:1907)
    at wdlTools.generators.code.WdlFormatter.$anonfun$formatDocuments$1(WdlFormatter.scala:1914)
    at wdlTools.syntax.WdlParser$Walker.addDocument$1(WdlParser.scala:66)
    at wdlTools.syntax.WdlParser$Walker.walk(WdlParser.scala:80)
    at wdlTools.generators.code.WdlFormatter.formatDocuments(WdlFormatter.scala:1913)
    at wdlTools.cli.Format.apply(Format.scala:15)
    at wdlTools.cli.Main$.runCommand(Main.scala:36)
    at wdlTools.cli.Main$.delayedEndpoint$wdlTools$cli$Main$1(Main.scala:48)
    at wdlTools.cli.Main$delayedInit$body.apply(Main.scala:12)
    at scala.Function0.apply$mcV$sp(Function0.scala:39)
    at scala.Function0.apply$mcV$sp$(Function0.scala:39)
    at scala.runtime.AbstractFunction0.apply$mcV$sp(AbstractFunction0.scala:17)
    at scala.App.$anonfun$main$1(App.scala:76)
    at scala.App.$anonfun$main$1$adapted(App.scala:76)
    at scala.collection.IterableOnceOps.foreach(IterableOnce.scala:563)
    at scala.collection.IterableOnceOps.foreach$(IterableOnce.scala:561)
    at scala.collection.AbstractIterable.foreach(Iterable.scala:926)
    at scala.App.main(App.scala:76)
    at scala.App.main$(App.scala:74)
    at wdlTools.cli.Main$.main(Main.scala:12)
    at wdlTools.cli.Main.main(Main.scala)

$ 

If the comment line is removed, then the format command does not throw an exception and shows the reformated file as expected.