diff --git a/pom.xml b/pom.xml
index bafa246..8a5e3f4 100644
--- a/pom.xml
+++ b/pom.xml
@@ -6,7 +6,7 @@
com.stepstone.sonar.plugin
sonar-coldfusion-plugin
sonar-plugin
- 1.6.5-SNAPSHOT
+ 1.6.6-SNAPSHOT
SonarQube Coldfusion Analyzer
Enables scanning of ColdFusion source files
@@ -39,7 +39,7 @@
UTF-8
1.8
1.8
- 6.7.5
+ 6.7.6
1.2.3
diff --git a/src/main/java/com/stepstone/sonar/plugin/coldfusion/ColdFusionPlugin.java b/src/main/java/com/stepstone/sonar/plugin/coldfusion/ColdFusionPlugin.java
index 01b6637..c52821d 100644
--- a/src/main/java/com/stepstone/sonar/plugin/coldfusion/ColdFusionPlugin.java
+++ b/src/main/java/com/stepstone/sonar/plugin/coldfusion/ColdFusionPlugin.java
@@ -30,6 +30,7 @@
name = "File suffixes",
description = "Comma-separated list of suffixes of files to analyze.",
project = true,
+ multiValues = true,
global = true
),
@Property(
diff --git a/src/main/java/com/stepstone/sonar/plugin/coldfusion/ColdFusionSensor.java b/src/main/java/com/stepstone/sonar/plugin/coldfusion/ColdFusionSensor.java
index 78e325c..c6759e5 100644
--- a/src/main/java/com/stepstone/sonar/plugin/coldfusion/ColdFusionSensor.java
+++ b/src/main/java/com/stepstone/sonar/plugin/coldfusion/ColdFusionSensor.java
@@ -31,6 +31,7 @@
import javax.xml.stream.XMLStreamException;
import java.io.File;
import java.io.IOException;
+import java.nio.file.Files;
public class ColdFusionSensor implements Sensor {
@@ -63,21 +64,32 @@ public void execute(SensorContext context) {
}
}
- protected void analyze(SensorContext context) throws IOException, XMLStreamException {
- new CFLintAnalyzer(context).analyze(generateCflintConfig());
+ private void analyze(SensorContext context) throws IOException, XMLStreamException {
+ File configFile = generateCflintConfig();
+ new CFLintAnalyzer(context).analyze(configFile);
+ //when analysis is done we delete the created file
+ deleteFile(configFile);
}
- protected File generateCflintConfig() throws IOException, XMLStreamException {
+ private File generateCflintConfig() throws IOException, XMLStreamException {
final File configFile = new File(fs.workDir(), "cflint-config.xml");
new CFlintConfigExporter(ruleProfile).save(configFile);
return configFile;
}
- protected void importResults(SensorContext sensorContext) {
+ private void deleteFile(File configFile) throws IOException {
+ if(configFile!= null){
+ Files.deleteIfExists(configFile.toPath());
+ }
+ }
+
+ private void importResults(SensorContext sensorContext) throws IOException {
try {
new CFlintAnalysisResultImporter(fs, sensorContext).parse(new File(fs.workDir(), "cflint-result.xml"));
- } catch (IOException | XMLStreamException e) {
+ } catch (XMLStreamException e) {
LOGGER.error(",e");
+ } finally {
+ deleteFile(new File(fs.workDir(), "cflint-result.xml"));
}
}
diff --git a/src/main/java/com/stepstone/sonar/plugin/coldfusion/cflint/CFlintConfigExporter.java b/src/main/java/com/stepstone/sonar/plugin/coldfusion/cflint/CFlintConfigExporter.java
index 0129e62..270ace3 100644
--- a/src/main/java/com/stepstone/sonar/plugin/coldfusion/cflint/CFlintConfigExporter.java
+++ b/src/main/java/com/stepstone/sonar/plugin/coldfusion/cflint/CFlintConfigExporter.java
@@ -50,19 +50,26 @@ public void save(File configFile) throws IOException, XMLStreamException {
public void save(Writer writer) throws IOException, XMLStreamException {
final XMLOutputFactory xmlOutputFactory = XMLOutputFactory.newInstance();
- XMLStreamWriter xtw = xmlOutputFactory.createXMLStreamWriter(writer);
+ XMLStreamWriter xtw=null;
+ try {
+ xtw = xmlOutputFactory.createXMLStreamWriter(writer);
- xtw.writeStartDocument();
- xtw.writeStartElement("config");
+ xtw.writeStartDocument();
+ xtw.writeStartElement("config");
+
+ for (ActiveRule activeRule : ruleProfile.getActiveRulesByRepository(repositoryKey)) {
+ xtw.writeStartElement("includes");
+ xtw.writeAttribute("code", activeRule.getRuleKey());
+ xtw.writeEndElement();
+ }
- for (ActiveRule activeRule : ruleProfile.getActiveRulesByRepository(repositoryKey)) {
- xtw.writeStartElement("includes");
- xtw.writeAttribute("code", activeRule.getRuleKey());
xtw.writeEndElement();
+ xtw.writeEndDocument();
+ } finally {
+ if(xtw!=null) {
+ xtw.close();
+ }
}
- xtw.writeEndElement();
- xtw.writeEndDocument();
- xtw.close();
}
}