Skip to content

Commit

Permalink
Merge pull request #77 from lequal/FIXnullpointer
Browse files Browse the repository at this point in the history
Fix NullPointerException in docx.DataAdapter + versions + SECURITY_HOTSPOT
  • Loading branch information
louisjdmartin authored Aug 23, 2019
2 parents 8294bbc + 7502fef commit a7f1e10
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 20 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ deploy:
provider: releases
api_key:
secure: PFc97cepts1tQHmAWMIoLUVFo3aP6o6sVVg6B+30YjguyO6SrnFf/uE+zem1ogP6S3NOcMY0xtfBM4QSHoOTWVp1C5nk7SPzvXUs/diP5J7B58Z8OhMl0vkjz2Xa4GQx6ndK07DgMUeJyxexTBatJJ47E1Y+xLHqkSbcCCALfD4LfRvAM902t9nHBcRUPONmbAX6fj2z5TRTc9AveWwwgAbfHPjsh2WvuEQ0bSttKIYO08rm4GfXiqcwcfUtBwRLij+tQEYmyj+D5ie1jfJZe61FEF9rH1bS44ARr3BMqm1Ezm6rIEYG+4f1h5xZnXjX50uYIlShH9me28+XPr7FCopOwJyim/cT4Lviypw6dki4FRtRig93+Gjj42rLXSQaL4VtA1p+KscCBrG3C4QCbIOEixtN8n/WDd1U90x3GX8X+iPxApw5pWJ/Svc7ggjh9f0WvpsFGlFowqQBsP0GrGwdDoNeu5qaHA6G1AIHses6EUcq/WZ6ZAy/cbQCNjICPIzXYSV8pBCKjnnXZWZfciZWH3Q/EghCnyyjCGLpYV2cEtHgGx50rGWQVyPHmKZZ6/B2CETWPtxpg//yXPRsTII0ssBbgFZgmeiW6Hl+TQv6AEoLK4YJhPod8XEenYKwanct2zGbOH6YH6emM0vE3HN3ldfHNRHtyhPyGsefsc0=
file: sonar-cnes-report.jar
file: target/sonar-cnes-report.jar
skip_cleanup: true
draft: true
on:
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ java -Dhttps.proxyHost=https://myproxy -Dhttps.proxyPort=42
<td><b>2.0.0<br/>Standalone only</b></td>
<td><b>2.1.0<br/>Standalone only</b></b></td>
<td><b>2.2.0<br/>Standalone + Plugin</b></td>
<td><b>3.0.0<br/>Standalone + Plugin</b></b></td>
<td><b>3.0.x<br/>Standalone + Plugin</b></b></td>
</tr>
<tr>
<td><b>3.7.x (LTS)</b></td>
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>fr.cnes.sonar</groupId>
<artifactId>cnesreport</artifactId>
<version>3.0.0</version>
<version>3.0.1</version>
<packaging>sonar-plugin</packaging>

<name>SonarQube CNES Report</name>
Expand Down
46 changes: 30 additions & 16 deletions src/main/java/fr/cnes/sonar/report/exporters/docx/DataAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down Expand Up @@ -669,7 +669,7 @@ private static String findMeasure(List<Measure> 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<String>{
Report report;
Expand All @@ -679,20 +679,34 @@ class RuleComparator implements Comparator<String>{
}

public int compare(String o1, String o2) {
if(o1.isEmpty() || o2.isEmpty())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()
);
int compare = 0;

if(o1.isEmpty() || o2.isEmpty())compare = 1;

//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(
report.getRule(o2).getSeverity()
);
}

if (compare == 0){
compare = report.getRule(o1).getKey().compareTo(
report.getRule(o2).getKey()
);
}

return compare;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public class ServerFactory {

/** List of SonarQube versions which are supported by cnesreport. */
private static final List<String> 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;
Expand Down

0 comments on commit a7f1e10

Please sign in to comment.