codacy / codacy-coverage-reporter

Multi-language coverage reporter for Codacy
https://www.codacy.com
Other
131 stars 94 forks source link

[TS-549] Exception in thread "main" java.lang.NumberFormatException: For input string: "18446744073709551615" #472

Closed jasonm23 closed 8 months ago

jasonm23 commented 10 months ago

Expected Behavior

Parsing of coverage.lcov report.

bash <(curl -Ls https://coverage.codacy.com/get.sh) \
report \
--coverage-reports coverage.lcov \
--language swift \
--project-token $CODACY_PROJECT_TOKEN

RipGrep shows the number which breaks the reporter.

rg "18446744073709551615" coverage.lcov
2954:DA:36,18446744073709551615
2955:DA:37,18446744073709551615
2978:DA:66,18446744073709551615
2979:DA:67,18446744073709551615

Actual Behavior

Error stacktrace:

java.lang.NumberFormatException

Exception in thread "main" java.lang.NumberFormatException: For input string: "18446744073709551615"
        at java.base@11.0.17/java.lang.Long.parseLong(Long.java:692)
        at java.base@11.0.17/java.lang.Long.parseLong(Long.java:817)
        at scala.collection.immutable.StringLike.toLong(StringLike.scala:309)
        at scala.collection.immutable.StringLike.toLong$(StringLike.scala:309)
        at scala.collection.immutable.StringOps.toLong(StringOps.scala:33)
        at com.codacy.parsers.util.MathUtils$ParseIntOps$.toIntOrMaxValue$extension(MathUtils.scala:12)
        at com.codacy.parsers.implementation.LCOVParser$.$anonfun$parseLines$5(LCOVParser.scala:45)
        at com.codacy.parsers.implementation.LCOVParser$.$anonfun$parseLines$5$adapted(LCOVParser.scala:45)
        at scala.collection.TraversableLike.$anonfun$map$1(TraversableLike.scala:273)
        at scala.collection.IndexedSeqOptimized.foreach(IndexedSeqOptimized.scala:36)
        at scala.collection.IndexedSeqOptimized.foreach$(IndexedSeqOptimized.scala:33)
        at scala.collection.mutable.ArrayOps$ofRef.foreach(ArrayOps.scala:198)
        at scala.collection.TraversableLike.map(TraversableLike.scala:273)
        at scala.collection.TraversableLike.map$(TraversableLike.scala:266)
        at scala.collection.mutable.ArrayOps$ofRef.map(ArrayOps.scala:198)
        at com.codacy.parsers.implementation.LCOVParser$.$anonfun$parseLines$2(LCOVParser.scala:45)
        at scala.util.Either.flatMap(Either.scala:341)
        at com.codacy.parsers.implementation.LCOVParser$.$anonfun$parseLines$1(LCOVParser.scala:37)
        at scala.collection.TraversableOnce$folder$1$.apply(TraversableOnce.scala:187)
        at scala.collection.TraversableOnce$folder$1$.apply(TraversableOnce.scala:185)
        at scala.collection.Iterator.foreach(Iterator.scala:943)
        at scala.collection.Iterator.foreach$(Iterator.scala:943)
        at scala.collection.AbstractIterator.foreach(Iterator.scala:1431)
        at scala.collection.TraversableOnce.foldLeft(TraversableOnce.scala:189)
        at scala.collection.TraversableOnce.foldLeft$(TraversableOnce.scala:184)
        at scala.collection.AbstractIterator.foldLeft(Iterator.scala:1431)
        at com.codacy.parsers.implementation.LCOVParser$.parseLines(LCOVParser.scala:36)
        at com.codacy.parsers.implementation.LCOVParser$.$anonfun$parse$3(LCOVParser.scala:30)
        at scala.util.Either.flatMap(Either.scala:341)
        at com.codacy.parsers.implementation.LCOVParser$.parse(LCOVParser.scala:30)
        at com.codacy.parsers.CoverageParser$ParsedCoverage$1$.unapply(CoverageParser.scala:53)
        at com.codacy.parsers.CoverageParser$$anonfun$parse$4.applyOrElse(CoverageParser.scala:62)
        at com.codacy.parsers.CoverageParser$$anonfun$parse$4.applyOrElse(CoverageParser.scala:61)
        at scala.collection.TraversableOnce.collectFirst(TraversableOnce.scala:172)
        at scala.collection.TraversableOnce.collectFirst$(TraversableOnce.scala:159)
        at scala.collection.SeqLike$$anon$2.collectFirst(SeqLike.scala:682)
        at com.codacy.parsers.CoverageParser$.parse(CoverageParser.scala:61)
        at com.codacy.rules.ReportRules.$anonfun$sendFilesReportForCommit$2(ReportRules.scala:40)
        at scala.util.Either.flatMap(Either.scala:341)
        at com.codacy.rules.ReportRules.$anonfun$sendFilesReportForCommit$1(ReportRules.scala:39)
        at scala.collection.immutable.List.map(List.scala:286)
        at com.codacy.rules.ReportRules.sendFilesReportForCommit(ReportRules.scala:36)
        at com.codacy.rules.ReportRules.$anonfun$codacyCoverage$2(ReportRules.scala:76)
        at scala.util.Either.flatMap(Either.scala:341)
        at com.codacy.rules.ReportRules.$anonfun$codacyCoverage$1(ReportRules.scala:68)
        at com.codacy.rules.ReportRules.$anonfun$withCommitUUID$4(ReportRules.scala:365)
        at scala.util.Either.flatMap(Either.scala:341)
        at com.codacy.rules.ReportRules.withCommitUUID(ReportRules.scala:365)
        at com.codacy.rules.ReportRules.codacyCoverage(ReportRules.scala:63)
        at com.codacy.rules.ReportRules.codacyCoverage(ReportRules.scala:59)
        at com.codacy.CodacyCoverageReporter$.$anonfun$sendReport$1(CodacyCoverageReporter.scala:43)
        at scala.util.Either.flatMap(Either.scala:341)
        at com.codacy.CodacyCoverageReporter$.sendReport(CodacyCoverageReporter.scala:34)
        at com.codacy.CodacyCoverageReporter$.run(CodacyCoverageReporter.scala:19)
        at com.codacy.configuration.parser.ConfigurationParsingApp.run(ConfigurationParser.scala:15)
        at com.codacy.configuration.parser.ConfigurationParsingApp.run(ConfigurationParser.scala:13)
        at caseapp.CommandAppWithPreCommand.$anonfun$main$1(CommandAppWithPreCommand.scala:97)
        at caseapp.CommandAppWithPreCommand.$anonfun$main$1$adapted(CommandAppWithPreCommand.scala:82)
        at scala.Option.foreach(Option.scala:407)
        at caseapp.CommandAppWithPreCommand.main(CommandAppWithPreCommand.scala:82)
        at com.codacy.CodacyCoverageReporter.main(CodacyCoverageReporter.scala)

Reproducible Test Case

I assume parsing a report containing an Int value larger n will throw the error.

github-actions[bot] commented 10 months ago

Internal ticket created : TS-549

jasonm23 commented 10 months ago

Seems to be an issue in

MathUtils.ParseIntOps.toIntOrMaxValue

Use of toLong will only handle 64bit (max ≤19 digits), time for BigInteger?

jasonm23 commented 10 months ago

473 should fix this.

jasonm23 commented 10 months ago

Currently working around this by replacing > 2,147,483,647 with 2,147,483,647 in coverage.lcov

stefanvacareanu7 commented 9 months ago

Hi Jason,

Thanks for reaching our community!

While the fix you proposed is good for the tool itself, we are passing that information to other internal components and it requires other changes as well.

I am passing the internal ticket to the corresponding team. Keep in mind that this is a low priority for now.

Best, Stefan

jasonm23 commented 9 months ago

we are passing that information to other internal components and it requires other changes as well.

Such as?

You have components that want an int overflow?

Facepalm moment

lolgab commented 8 months ago

@jasonm23 Clearly there was some misunderstanding of the problem on our side. I answered in your PR thread. I used your PR as the starting point to fix the problem and to fix a bug that comes out when you handle such big numbers (you can't sum as easily as before, since you have overflows). I also added a test case. I will merge #479 (which contains your commit as well) when the CI is green.

jasonm23 commented 8 months ago

Great to hear. Looking forward to the fix shipping