Skip to content

Commit d42def4

Browse files
committed
Merge branch 'develop' of github.com:Backelite/sonar-swift into develop
* 'develop' of github.com:Backelite/sonar-swift: Fix #182 LizardSensor logs full stack trace exception instead warning if report file not exists
2 parents ff38e8f + 62ab06c commit d42def4

File tree

1 file changed

+11
-3
lines changed
  • sonar-swift-plugin/src/main/java/com/backelite/sonarqube/swift/complexity

1 file changed

+11
-3
lines changed

sonar-swift-plugin/src/main/java/com/backelite/sonarqube/swift/complexity/LizardSensor.java

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@
2828
import org.sonar.api.batch.sensor.SensorDescriptor;
2929

3030
import java.io.File;
31+
import java.io.IOException;
32+
import java.nio.file.Files;
33+
import java.nio.file.Path;
34+
import java.nio.file.Paths;
3135

3236
public class LizardSensor implements Sensor {
3337
private static final Logger LOGGER = LoggerFactory.getLogger(LizardSensor.class);
@@ -56,10 +60,14 @@ public void describe(SensorDescriptor descriptor) {
5660

5761
@Override
5862
public void execute(SensorContext context) {
59-
String reportFileName = context.fileSystem().baseDir().getPath() + File.separator + reportPath();
60-
LOGGER.info("Processing complexity report: {}",reportFileName);
63+
File reportFile = new File(context.fileSystem().baseDir(), reportPath());
64+
if (!reportFile.isFile()) {
65+
LOGGER.warn("Lizard report file not found at {}", reportFile.getAbsolutePath());
66+
return;
67+
}
6168

69+
LOGGER.info("Processing complexity report: {}", reportFile.getAbsolutePath());
6270
LizardReportParser parser = new LizardReportParser(context);
63-
parser.parseReport(new File(reportFileName));
71+
parser.parseReport(reportFile);
6472
}
6573
}

0 commit comments

Comments
 (0)