diff --git a/src/main/java/org/sonar/plugins/scala/cobertura/ScalaCoberturaReportParser.java b/src/main/java/org/sonar/plugins/scala/cobertura/ScalaCoberturaReportParser.java index 06ed6ad..a84562f 100644 --- a/src/main/java/org/sonar/plugins/scala/cobertura/ScalaCoberturaReportParser.java +++ b/src/main/java/org/sonar/plugins/scala/cobertura/ScalaCoberturaReportParser.java @@ -17,6 +17,9 @@ * License along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 */ +/* + * SonarQube Cobertura Plugin + */ package org.sonar.plugins.scala.cobertura; import static java.util.Locale.ENGLISH; @@ -28,7 +31,6 @@ import javax.xml.stream.XMLStreamException; -import org.apache.commons.io.FilenameUtils; import org.apache.commons.lang.StringUtils; import org.codehaus.staxmate.in.SMHierarchicCursor; import org.codehaus.staxmate.in.SMInputCursor; @@ -47,7 +49,7 @@ public class ScalaCoberturaReportParser { - private static final Logger LOG = LoggerFactory.getLogger(ScalaCoberturaReportParser.class); + private static final Logger LOG = LoggerFactory.getLogger(ScalaCoberturaReportParser.class); private final SensorContext context; private FileSystem fileSystem; @@ -58,7 +60,7 @@ private ScalaCoberturaReportParser(SensorContext context, FileSystem fileSystem) /** * Parse a Cobertura xml report and create measures accordingly - * @param fileSystem + * @param fileSystem */ public static void parseReport(File xmlFile, SensorContext context, FileSystem fileSystem) { new ScalaCoberturaReportParser(context, fileSystem).parse(xmlFile); @@ -84,11 +86,8 @@ private void collectPackageMeasures(SMInputCursor pack) throws XMLStreamExceptio Map builderByFilename = Maps.newHashMap(); collectFileMeasures(pack.descendantElementCursor("class"), builderByFilename); for (Map.Entry entry : builderByFilename.entrySet()) { - String className = sanitizeFilename(entry.getKey()); - String filename = className.replace('.', '/') + ".scala"; FilePredicates filePredicates = fileSystem.predicates(); - - InputFile resource = fileSystem.inputFile(filePredicates.matchesPathPattern("**/*" + filename)); + InputFile resource = fileSystem.inputFile(filePredicates.matchesPathPattern("**/*" + entry.getKey())); if (resource != null){ for (Measure measure : entry.getValue().createMeasures()) { context.saveMeasure(resource, measure); @@ -131,10 +130,4 @@ private void collectFileData(SMInputCursor clazz, CoverageMeasuresBuilder builde } } - private static String sanitizeFilename(String s) { - String fileName = FilenameUtils.removeExtension(s); - fileName = fileName.replace('/', '.').replace('\\', '.'); - return fileName; - } - }