Skip to content

Commit

Permalink
Merge pull request #1464 from ivangalkin/disablecoveragecache
Browse files Browse the repository at this point in the history
CoberturaParser: extract loop invariant
  • Loading branch information
guwirth authored Apr 25, 2018
2 parents 2eeb8ca + 29374f4 commit 08d63c7
Showing 1 changed file with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,10 @@ public class CoberturaParser extends CxxCoverageParser {

private static final Logger LOG = Loggers.get(CoberturaParser.class);
private String baseDir;
private static final Pattern conditionsPattern = Pattern.compile("\\((.*?)\\)");

public CoberturaParser() {
// no operation but necessary for list of coverage parsers
// no operation but necessary for list of coverage parsers
}

/**
Expand Down Expand Up @@ -103,6 +104,7 @@ private static void collectFileMeasures(final String baseDir, SMInputCursor claz

private static void collectFileData(SMInputCursor clazz, CoverageMeasures builder) throws XMLStreamException {
SMInputCursor line = clazz.childElementCursor("lines").advance().childElementCursor("line");

while (line.getNext() != null) {
int lineId = Integer.parseInt(line.getAttrValue("number"));
long noHits = Long.parseLong(line.getAttrValue("hits"));
Expand All @@ -116,8 +118,7 @@ private static void collectFileData(SMInputCursor clazz, CoverageMeasures builde
String isBranch = line.getAttrValue("branch");
String text = line.getAttrValue("condition-coverage");
if (text != null && "true".equals(isBranch) && !text.trim().isEmpty()) {
Pattern p = Pattern.compile("\\((.*?)\\)");
Matcher m = p.matcher(text);
Matcher m = conditionsPattern.matcher(text);
if (m.find()) {
String[] conditions = m.group(1).split("/");
builder.setConditions(lineId, Integer.parseInt(conditions[1]), Integer.parseInt(conditions[0]));
Expand Down

0 comments on commit 08d63c7

Please sign in to comment.