shanbin / scoverage-plugin

Jenkins scoverage plugin for Scala code coverage
https://wiki.jenkins-ci.org/display/JENKINS/Scoverage+Plugin
MIT License
6 stars 19 forks source link

ScoveragePublisher.java gives java.util.regex.PatternSyntaxException: Illegal/unsupported escape sequence near #8

Closed peterlai-roboops closed 8 years ago

peterlai-roboops commented 8 years ago

When ScoveragePublisher.java scans a scoverage results file i side a folder that starts with M (e.g. scoverage-report\com\nephila\attribution\common**mail\test.xml)

It gives this error,

Publishing Scoverage XML and HTML report ... ERROR: Build step failed with exception java.util.regex.PatternSyntaxException: Illegal/unsupported escape sequence near index 56 href=".*scoverage-report\com\nephila\attribution\common\mail/ ^ at java.util.regex.Pattern.error(Unknown Source) at java.util.regex.Pattern.escape(Unknown Source) at java.util.regex.Pattern.atom(Unknown Source) at java.util.regex.Pattern.sequence(Unknown Source) at java.util.regex.Pattern.expr(Unknown Source) at java.util.regex.Pattern.compile(Unknown Source) at java.util.regex.Pattern.(Unknown Source) at java.util.regex.Pattern.compile(Unknown Source) at java.lang.String.replaceAll(Unknown Source) at org.jenkinsci.plugins.scoverage.ScoveragePublisher.processReport(ScoveragePublisher.java:128) at org.jenkinsci.plugins.scoverage.ScoveragePublisher.perform(ScoveragePublisher.java:67) at hudson.tasks.BuildStepCompatibilityLayer.perform(BuildStepCompatibilityLayer.java:76) at hudson.tasks.BuildStepMonitor$3.perform(BuildStepMonitor.java:45) at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:782) at hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:723) at hudson.model.Build$BuildExecution.post2(Build.java:185) at hudson.model.AbstractBuild$AbstractBuildExecution.post(AbstractBuild.java:668) at hudson.model.Run.execute(Run.java:1763) at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43) at hudson.model.ResourceController.execute(ResourceController.java:98) at hudson.model.Executor.run(Executor.java:410)

peterlai-roboops commented 8 years ago

package org.jenkinsci.plugins.scoverage;

Here's a mini test class to replicate the problem, the replaceAll uses Reggex pattern matching and it's causing issues when confronted with \m

public class test { public static void main(String args[]){ String line = ""; String pattern = "scoverage-report\com\nephila\attribution\common\mail"; String pete = line.replaceAll("href=" + pattern, "href="); }}

shanbin commented 8 years ago

Fixed on master.