Skip to content

Commit 58919ed

Browse files
committed
Prepare for new release
1 parent 88503e1 commit 58919ed

File tree

2 files changed

+46
-25
lines changed

2 files changed

+46
-25
lines changed

src/sonar-sql-plugin/pom.xml

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
<groupId>org.sonar.plugins</groupId>
77
<artifactId>sonar-sql-plugin</artifactId>
8-
<version>1.0.0</version>
8+
<version>1.0.1</version>
99
<packaging>sonar-plugin</packaging>
1010

1111
<name>SQL language plugin</name>
@@ -23,6 +23,27 @@
2323
</properties>
2424

2525
<dependencies>
26+
<!-- https://mvnrepository.com/artifact/com.sun.xml.bind/jaxb-impl -->
27+
<dependency>
28+
<groupId>javax.xml.bind</groupId>
29+
<artifactId>jaxb-api</artifactId>
30+
<version>2.2.11</version>
31+
</dependency>
32+
<dependency>
33+
<groupId>com.sun.xml.bind</groupId>
34+
<artifactId>jaxb-core</artifactId>
35+
<version>2.2.11</version>
36+
</dependency>
37+
<dependency>
38+
<groupId>com.sun.xml.bind</groupId>
39+
<artifactId>jaxb-impl</artifactId>
40+
<version>2.2.11</version>
41+
</dependency>
42+
<dependency>
43+
<groupId>javax.activation</groupId>
44+
<artifactId>activation</artifactId>
45+
<version>1.1.1</version>
46+
</dependency>
2647
<dependency>
2748
<groupId>org.reflections</groupId>
2849
<artifactId>reflections</artifactId>
@@ -35,9 +56,6 @@
3556
<version>${sonar.apiVersion}</version>
3657
<scope>provided</scope>
3758
</dependency>
38-
39-
40-
4159
<dependency>
4260
<groupId>org.apache.commons</groupId>
4361
<artifactId>commons-lang3</artifactId>
@@ -49,9 +67,6 @@
4967
<artifactId>commons-io</artifactId>
5068
<version>2.6</version>
5169
</dependency>
52-
<!-- <dependency> <groupId>org.apache.commons</groupId> <artifactId>commons-io</artifactId>
53-
<version>1.3.2</version> </dependency> -->
54-
<!-- unit tests -->
5570
<dependency>
5671
<groupId>org.sonarsource.sonarqube</groupId>
5772
<artifactId>sonar-testing-harness</artifactId>
@@ -64,8 +79,6 @@
6479
<version>4.13-beta-2</version>
6580
<scope>test</scope>
6681
</dependency>
67-
68-
<!-- https://mvnrepository.com/artifact/org.antlr/antlr4-runtime -->
6982
<dependency>
7083
<groupId>org.antlr</groupId>
7184
<artifactId>antlr4-runtime</artifactId>

src/sonar-sql-plugin/src/main/java/org/sonar/plugins/sql/sensors/CGIssuesSensor.java

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -72,19 +72,19 @@ public void execute(SensorContext context) {
7272
final String[] args = new String[] { externalTool, "-source", sourceDir, "-out",
7373
tempResultsFile.getAbsolutePath(), "/include:all" };
7474

75-
final Process process = new ProcessBuilder(args).start();
75+
final Process process = new ProcessBuilder(args).inheritIO().start();
7676
LOGGER.debug("Running SQLCodeGuard with {}", Arrays.toString(args));
7777

7878
final int result = process.waitFor();
79-
if (result != 0 || !tempResultsFile.exists() || tempResultsFile.length() == 0) {
80-
LOGGER.warn("Was not able to run SQLCodeGuard with {}", Arrays.toString(args));
79+
if (!tempResultsFile.exists() || tempResultsFile.length() == 0) {
80+
LOGGER.warn("SQLCodeGuard returned with '{}'. Arguments were: {}", result, Arrays.toString(args));
8181
return;
8282
}
83-
try (BOMInputStream stream = new BOMInputStream(new FileInputStream(tempResultsFile))) {
83+
try (final BOMInputStream stream = new BOMInputStream(new FileInputStream(tempResultsFile))) {
8484

8585
final CodeGuardIssues issues = read(stream);
8686

87-
for (org.sonar.plugins.sql.models.cgissues.CodeGuardIssues.File f : issues.getFile()) {
87+
for (final org.sonar.plugins.sql.models.cgissues.CodeGuardIssues.File f : issues.getFile()) {
8888

8989
final List<InputFile> files = find(context, f.getFullname());
9090
if (files.isEmpty()) {
@@ -94,10 +94,10 @@ public void execute(SensorContext context) {
9494
final InputFile file = files.get(0);
9595
for (final Issue is : f.getIssue()) {
9696
try {
97-
NewExternalIssue newExternalIssue = context.newExternalIssue().ruleId(is.getCode())
97+
final NewExternalIssue newExternalIssue = context.newExternalIssue().ruleId(is.getCode())
9898
.engineId(repositoryName).type(RuleType.CODE_SMELL);
99-
NewIssueLocation location = newExternalIssue.newLocation().on(file).message(is.getText())
100-
.at(file.selectLine(is.getLine()));
99+
final NewIssueLocation location = newExternalIssue.newLocation().on(file)
100+
.message(is.getText()).at(file.selectLine(is.getLine()));
101101
newExternalIssue.at(location).severity(extractSeverity(is.getSeverity())).save();
102102
} catch (Throwable e) {
103103
LOGGER.warn("Unexpected error adding issue on file " + f.getFullname(), e);
@@ -113,16 +113,24 @@ public void execute(SensorContext context) {
113113

114114
}
115115

116-
private final Severity extractSeverity(String severity) {
117-
String val = "MAJOR";
118-
119-
if (severity != null) {
120-
val = severity.toUpperCase();
116+
private final Severity extractSeverity(final String severityValue) {
117+
String severity = "MAJOR";
118+
if (severityValue != null) {
119+
severity = severityValue.toUpperCase();
120+
}
121+
if ("ERROR".equalsIgnoreCase(severity)) {
122+
return Severity.CRITICAL;
123+
}
124+
if ("WARNING".equalsIgnoreCase(severity)) {
125+
return Severity.MAJOR;
121126
}
122-
if ("WARNING".equalsIgnoreCase(val)) {
123-
val = "MAJOR";
127+
try {
128+
return Severity.valueOf(severity);
129+
} catch (Exception e) {
130+
124131
}
125-
return Severity.valueOf(val);
132+
return Severity.MAJOR;
133+
126134
}
127135

128136
}

0 commit comments

Comments
 (0)