diff --git a/sonar-swift-plugin/src/main/java/com/backelite/sonarqube/swift/complexity/LizardReportParser.java b/sonar-swift-plugin/src/main/java/com/backelite/sonarqube/swift/complexity/LizardReportParser.java index 0872a4b1..cc13ebb4 100644 --- a/sonar-swift-plugin/src/main/java/com/backelite/sonarqube/swift/complexity/LizardReportParser.java +++ b/sonar-swift-plugin/src/main/java/com/backelite/sonarqube/swift/complexity/LizardReportParser.java @@ -171,27 +171,31 @@ public boolean isFile() { private void addComplexityFileMeasures(InputFile component, NodeList values) { LOGGER.debug("File measures for {}",component.toString()); - int complexity = Integer.parseInt(values.item(cyclomaticComplexityIndex).getTextContent()); - - context.newMeasure() - .on(component) - .forMetric(CoreMetrics.COMPLEXITY) - .withValue(complexity) - .save(); - - int numberOfFunctions = Integer.parseInt(values.item(functionCountIndex).getTextContent()); - context.newMeasure() - .on(component) - .forMetric(CoreMetrics.FUNCTIONS) - .withValue(numberOfFunctions) - .save(); - - int numberOfLines = Integer.parseInt(values.item(lineCountIndex).getTextContent()); - context.newMeasure() - .on(component) - .forMetric(CoreMetrics.LINES) - .withValue(numberOfLines) - .save(); + try { + int complexity = Integer.parseInt(values.item(cyclomaticComplexityIndex).getTextContent()); + + context.newMeasure() + .on(component) + .forMetric(CoreMetrics.COMPLEXITY) + .withValue(complexity) + .save(); + + int numberOfFunctions = Integer.parseInt(values.item(functionCountIndex).getTextContent()); + context.newMeasure() + .on(component) + .forMetric(CoreMetrics.FUNCTIONS) + .withValue(numberOfFunctions) + .save(); + + int numberOfLines = Integer.parseInt(values.item(lineCountIndex).getTextContent()); + context.newMeasure() + .on(component) + .forMetric(CoreMetrics.LINES) + .withValue(numberOfLines) + .save(); + } catch (Exception e) { + LOGGER.debug("unable to create complexity " + e.getMessage()); + } } private void addComplexityFunctionMeasures(InputComponent component, NodeList values) {