From d05a5f497afb410ed6b4e21271de57ddcefadd03 Mon Sep 17 00:00:00 2001 From: Louis MARTIN Date: Thu, 22 Aug 2019 16:34:54 +0200 Subject: [PATCH 1/3] fix null pointer exception --- .../report/exporters/docx/DataAdapter.java | 32 ++++++++++++------- 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/src/main/java/fr/cnes/sonar/report/exporters/docx/DataAdapter.java b/src/main/java/fr/cnes/sonar/report/exporters/docx/DataAdapter.java index d2d47135..d9c53f90 100644 --- a/src/main/java/fr/cnes/sonar/report/exporters/docx/DataAdapter.java +++ b/src/main/java/fr/cnes/sonar/report/exporters/docx/DataAdapter.java @@ -679,20 +679,28 @@ class RuleComparator implements Comparator{ } public int compare(String o1, String o2) { + int compare; + if(o1.isEmpty() || o2.isEmpty())return 0; + if(report.getRule(o1) == null || report.getRule(o1) == null)return 0; - int compare = report - .getRule(o1) - .getType() - .compareTo( - report.getRule(o2).getType() - ); - if (compare == 0) compare = report.getRule(o1).getSeverity().compareTo( - report.getRule(o2).getSeverity() - ); - if (compare == 0) compare = report.getRule(o1).getKey().compareTo( - report.getRule(o2).getKey() - ); + try { + compare = report + .getRule(o1) + .getType() + .compareTo( + report.getRule(o2).getType() + ); + if (compare == 0) compare = report.getRule(o1).getSeverity().compareTo( + report.getRule(o2).getSeverity() + ); + if (compare == 0) compare = report.getRule(o1).getKey().compareTo( + report.getRule(o2).getKey() + ); + } + catch (NullPointerException e){ + compare = 0; + } return compare; } From 543dea417ac06bbe27df612c57eba609e095675a Mon Sep 17 00:00:00 2001 From: Louis MARTIN Date: Fri, 23 Aug 2019 11:09:38 +0200 Subject: [PATCH 2/3] FIX: comparator fail when rules are removed since last analysis --- .../report/exporters/docx/DataAdapter.java | 28 +++++++++++-------- .../sonar/report/factory/ServerFactory.java | 2 +- 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/src/main/java/fr/cnes/sonar/report/exporters/docx/DataAdapter.java b/src/main/java/fr/cnes/sonar/report/exporters/docx/DataAdapter.java index d9c53f90..cd05a790 100644 --- a/src/main/java/fr/cnes/sonar/report/exporters/docx/DataAdapter.java +++ b/src/main/java/fr/cnes/sonar/report/exporters/docx/DataAdapter.java @@ -247,7 +247,7 @@ public final class DataAdapter { /** * List of possible issue types */ - private static final String[] ISSUE_TYPES = {"VULNERABILITY", "BUG", "CODE_SMELL"}; + private static final String[] ISSUE_TYPES = {"VULNERABILITY", "BUG", "CODE_SMELL", "SECURITY_HOTSPOT"}; /** * List of possible issue severities */ @@ -669,7 +669,7 @@ private static String findMeasure(List measures, String metric) { } /** - * RuleComparator is used to compare 2 issues to sort them by severityq + * RuleComparator is used to compare 2 issues to sort them by type & severity */ class RuleComparator implements Comparator{ Report report; @@ -679,28 +679,34 @@ class RuleComparator implements Comparator{ } public int compare(String o1, String o2) { - int compare; + int compare = 0; - if(o1.isEmpty() || o2.isEmpty())return 0; - if(report.getRule(o1) == null || report.getRule(o1) == null)return 0; + if(o1.isEmpty() || o2.isEmpty())compare = 1; - try { + //If rule is removed in quality gate, the issue is send to the end of list + if(report.getRule(o1) == null){compare = 1;} + else if(report.getRule(o2) == null){compare = -1;} + + if (compare == 0){ compare = report .getRule(o1) .getType() .compareTo( report.getRule(o2).getType() ); - if (compare == 0) compare = report.getRule(o1).getSeverity().compareTo( + } + + if (compare == 0) { + compare = report.getRule(o1).getSeverity().compareTo( report.getRule(o2).getSeverity() ); - if (compare == 0) compare = report.getRule(o1).getKey().compareTo( + } + + if (compare == 0){ + compare = report.getRule(o1).getKey().compareTo( report.getRule(o2).getKey() ); } - catch (NullPointerException e){ - compare = 0; - } return compare; } diff --git a/src/main/java/fr/cnes/sonar/report/factory/ServerFactory.java b/src/main/java/fr/cnes/sonar/report/factory/ServerFactory.java index 52371da2..0444dc22 100644 --- a/src/main/java/fr/cnes/sonar/report/factory/ServerFactory.java +++ b/src/main/java/fr/cnes/sonar/report/factory/ServerFactory.java @@ -32,7 +32,7 @@ public class ServerFactory { /** List of SonarQube versions which are supported by cnesreport. */ private static final List SUPPORTED_VERSIONS = Arrays.asList( - "5.6.*", "6.*", "7.*"); + "6.6", "6.6.*", "6.7", "6.7.*", "7.*", "8.*"); /** Url of the SonarQube server. */ private String url; From 7502fef0c2cd4b6044954221eb27b987dc913df1 Mon Sep 17 00:00:00 2001 From: Louis MARTIN Date: Fri, 23 Aug 2019 13:23:26 +0200 Subject: [PATCH 3/3] Update version number --- README.md | 2 +- pom.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 1d76ecec..e345ce42 100644 --- a/README.md +++ b/README.md @@ -113,7 +113,7 @@ java -Dhttps.proxyHost=https://myproxy -Dhttps.proxyPort=42 2.0.0
Standalone only
2.1.0
Standalone only
2.2.0
Standalone + Plugin
- 3.0.0
Standalone + Plugin
+ 3.0.x
Standalone + Plugin
3.7.x (LTS) diff --git a/pom.xml b/pom.xml index 12ee8903..10d644f7 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ fr.cnes.sonar cnesreport - 3.0.0 + 3.0.1 sonar-plugin SonarQube CNES Report