Coder Social home page Coder Social logo

coverage-parser's Introduction

coverage-parser

Circle CI Codacy Badge Codacy Badge Maven Central

Scala library for parsing coverage reports.

The parsers in this project receive as input two parameters, the project root folder, and the coverage report file. As a result of the parse operation, it will produce either a CoverageReport, a class that is compatible with the Codacy coverage format or a string describing the error parsing the coverage report file.

Supported formats

Check the formats we support on the documentation. You can use this parser with any of the listed coverage formats, independently of your language or coverage tool of choice.

If your coverage reports are in a different format you can use a format converter to generate a supported format.

Usage:

val reader: Either[String, CoverageReport] = CoverageParser.parse(rootProjectDir, coberturaFile)

What is Codacy?

Codacy is an Automated Code Review Tool that monitors your technical debt, helps you improve your code quality, teaches best practices to your developers, and helps you save time in Code Reviews.

Among Codacy’s features:

  • Identify new Static Analysis issues
  • Commit and Pull Request Analysis with GitHub, BitBucket/Stash, GitLab (and also direct git repositories)
  • Auto-comments on Commits and Pull Requests
  • Integrations with Slack, HipChat, Jira, YouTrack
  • Track issues in Code Style, Security, Error Proneness, Performance, Unused Code and other categories

Codacy also helps keep track of Code Coverage, Code Duplication, and Code Complexity.

Codacy supports PHP, Python, Ruby, Java, JavaScript, and Scala, among others.

Free for Open Source

Codacy is free for Open Source projects.

coverage-parser's People

Contributors

andreatp avatar bmbferreira avatar caxaria avatar cog avatar dreigada avatar ephemerist avatar franciscodua avatar gjsduarte avatar josemiguelmelo avatar ljmf00 avatar lolgab avatar machadoit avatar mrfyda avatar pcmanticore avatar pedrocodacy avatar pedrorijo91 avatar prcr avatar rtfpessoa avatar xplosunn avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

coverage-parser's Issues

Getting a divide by zero error parsing my jacoco file.

Any help much appreciated, better code coverage reporting equals a sweeter smelling garden

[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 01:34 min
[INFO] Finished at: 2019-02-15T21:17:24+00:00
[INFO] Final Memory: 89M/1143M
[INFO] ------------------------------------------------------------------------

[ERROR] Failed to execute goal com.gavinmogan:codacy-maven-plugin:1.0.3:coverage (post-test) on project backend: Execution post-test of goal com.gavinmogan:codacy-maven-plugin:1.0.3:coverage failed: / by zero -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal com.gavinmogan:codacy-maven-plugin:1.0.3:coverage (post-test) on project backend: Execution post-test of goal com.gavinmogan:codacy-maven-plugin:1.0.3:coverage failed: / by zero
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:212)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:863)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:199)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
Caused by: org.apache.maven.plugin.PluginExecutionException: Execution post-test of goal com.gavinmogan:codacy-maven-plugin:1.0.3:coverage failed: / by zero
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:145)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:207)
... 20 more
Caused by: java.lang.ArithmeticException: / by zero
at com.codacy.parsers.implementation.JacocoParser.com$codacy$parsers$implementation$JacocoParser$$lineCoverage(JacocoParser.scala:47)
at com.codacy.parsers.implementation.JacocoParser$$anonfun$5$$anonfun$apply$1.apply(JacocoParser.scala:32)
at com.codacy.parsers.implementation.JacocoParser$$anonfun$5$$anonfun$apply$1.apply(JacocoParser.scala:30)
at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:245)
at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:245)
at scala.collection.Iterator$class.foreach(Iterator.scala:750)
at scala.collection.AbstractIterator.foreach(Iterator.scala:1202)
at scala.collection.IterableLike$class.foreach(IterableLike.scala:72)
at scala.collection.AbstractIterable.foreach(Iterable.scala:54)
at scala.collection.TraversableLike$class.map(TraversableLike.scala:245)
at scala.collection.AbstractTraversable.map(Traversable.scala:104)
at com.codacy.parsers.implementation.JacocoParser$$anonfun$5.apply(JacocoParser.scala:29)
at com.codacy.parsers.implementation.JacocoParser$$anonfun$5.apply(JacocoParser.scala:27)
at scala.collection.TraversableLike$$anonfun$flatMap$1.apply(TraversableLike.scala:252)
at scala.collection.TraversableLike$$anonfun$flatMap$1.apply(TraversableLike.scala:252)
at scala.collection.Iterator$class.foreach(Iterator.scala:750)
at scala.collection.AbstractIterator.foreach(Iterator.scala:1202)
at scala.collection.IterableLike$class.foreach(IterableLike.scala:72)
at scala.collection.AbstractIterable.foreach(Iterable.scala:54)
at scala.collection.TraversableLike$class.flatMap(TraversableLike.scala:252)
at scala.collection.AbstractTraversable.flatMap(Traversable.scala:104)
at com.codacy.parsers.implementation.JacocoParser.generateReport(JacocoParser.scala:26)
at com.gavinmogan.CodacyCoverageReporterMojo.processReport(CodacyCoverageReporterMojo.java:196)
at com.gavinmogan.CodacyCoverageReporterMojo.execute(CodacyCoverageReporterMojo.java:121)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
... 21 more

Some snippets from the pom.xml I'm using


<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.3</version>

And using the supported codacy maven plugin

<plugin>
	<groupId>com.gavinmogan</groupId>
	<artifactId>codacy-maven-plugin</artifactId>
	<version>1.0.3</version>
	<configuration>
		<apiToken>${codacy.api.key}</apiToken>
		<projectToken>${codacy.project.key}</projectToken>
		<coverageReportFile>${project.build.directory}/site/jacoco/jacoco.xml</coverageReportFile>
		<!--<commit>${env.TRAVIS_COMMIT}</commit>-->
		<codacyApiBaseUrl>https://api.codacy.com</codacyApiBaseUrl>
		<failOnMissingReportFile>true</failOnMissingReportFile>
	</configuration>
	<executions>
		<execution>
			<id>post-test</id>
			<phase>post-integration-test</phase>
			<goals>
				<goal>coverage</goal>
			</goals>
		</execution>
	</executions>
</plugin>

See attached jacoco.xml file that causes the fail.

jacoco.txt

Division by Zero error parsing a jacoco report.

Maven 3
plugin 1.1.0

Operating System (Ubuntu 15.10 / MacOS 10.10 / Windows 10)

Windows 10
Use uname -a if on Linux.

JDK (Oracle 1.8.0_72, OpenJDK 1.8.x, Azul Zing)

1.8.0.161
Paste the output from java -version at the command line.

Library Dependencies

If this is an issue that involves integration with another system, include the exact version and OS of the other system, including any intermediate drivers or APIs i.e. if you connect to a PostgreSQL database, include both the version / OS of PostgreSQL and the JDBC driver version used to connect to the database.

Expected Behavior

Upload report
Please describe the expected behavior of the issue, starting from the first action.

1.Run coverage phase
2.
3.

Actual Behavior

Build Failure due to / by zero error

Please provide a description of what actually happens, working from the same starting point.

Be descriptive: "it doesn't work" does not describe what the behavior actually is -- instead, say "when sending the coverage with the command (...) it returns the output error (...)"

Reproducible Test Case

Please provide a some information on how to reproduce the bug. A PR with a failing test would be awesome, if possible.

StackTrace:
`[INFO] Parsing coverage data... \target\site\jacoco\jacoco.xml
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 15.979 s
[INFO] Finished at: 2019-02-08T13:01:28+10:00
[INFO] Final Memory: 14M/179M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal com.gavinmogan:codacy-maven-plugin:1.1.0:coverage (default-cli) on project Minigames: Execution default-cli of goal com.gavinmogan:codacy-maven-plugin:1.1.0:coverage failed: / by zero -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal com.gavinmogan:codacy-maven-plugin:1.1.0:coverage (default-cli) on project Minigames: Execution default-cli of goal com.gavinmogan:codacy-maven-plugin:1.1.0:coverage failed: / by zero
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:212)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:863)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:199)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
at org.codehaus.classworlds.Launcher.main(Launcher.java:47)
Caused by: org.apache.maven.plugin.PluginExecutionException: Execution default-cli of goal com.gavinmogan:codacy-maven-plugin:1.1.0:coverage failed: / by zero
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:145)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:207)
... 21 more
Caused by: java.lang.ArithmeticException: / by zero
at com.codacy.parsers.implementation.JacocoParser.com$codacy$parsers$implementation$JacocoParser$$lineCoverage(JacocoParser.scala:47)
at com.codacy.parsers.implementation.JacocoParser$$anonfun$5$$anonfun$apply$1.apply(JacocoParser.scala:32)
at com.codacy.parsers.implementation.JacocoParser$$anonfun$5$$anonfun$apply$1.apply(JacocoParser.scala:30)
at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:245)
at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:245)
at scala.collection.Iterator$class.foreach(Iterator.scala:750)
at scala.collection.AbstractIterator.foreach(Iterator.scala:1202)
at scala.collection.IterableLike$class.foreach(IterableLike.scala:72)
at scala.collection.AbstractIterable.foreach(Iterable.scala:54)
at scala.collection.TraversableLike$class.map(TraversableLike.scala:245)
at scala.collection.AbstractTraversable.map(Traversable.scala:104)
at com.codacy.parsers.implementation.JacocoParser$$anonfun$5.apply(JacocoParser.scala:29)
at com.codacy.parsers.implementation.JacocoParser$$anonfun$5.apply(JacocoParser.scala:27)
at scala.collection.TraversableLike$$anonfun$flatMap$1.apply(TraversableLike.scala:252)
at scala.collection.TraversableLike$$anonfun$flatMap$1.apply(TraversableLike.scala:252)
at scala.collection.Iterator$class.foreach(Iterator.scala:750)
at scala.collection.AbstractIterator.foreach(Iterator.scala:1202)
at scala.collection.IterableLike$class.foreach(IterableLike.scala:72)
at scala.collection.AbstractIterable.foreach(Iterable.scala:54)
at scala.collection.TraversableLike$class.flatMap(TraversableLike.scala:252)
at scala.collection.AbstractTraversable.flatMap(Traversable.scala:104)
at com.codacy.parsers.implementation.JacocoParser.generateReport(JacocoParser.scala:26)
at com.gavinmogan.CodacyCoverageReporterMojo.processReport(CodacyCoverageReporterMojo.java:221)
at com.gavinmogan.CodacyCoverageReporterMojo.execute(CodacyCoverageReporterMojo.java:136)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
... 22 more
[ERROR]
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginExecutionException

Process finished with exit code 1
`

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.