forked from jenkinsci/analysis-model
-
Notifications
You must be signed in to change notification settings - Fork 0
/
SonarQubeIssuesParser.java
33 lines (26 loc) · 1008 Bytes
/
SonarQubeIssuesParser.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package edu.hm.hafner.analysis.parser;
import org.json.JSONObject;
/**
* Class which parses SonarQube reports taken from the Sonarqube API (api/issues/search).
*
* @author Carles Capdevila
*/
public class SonarQubeIssuesParser extends SonarQubeParser {
private static final long serialVersionUID = -8213765181968340929L;
private static final String ISSUE_SUB_PROJECT= "subProject";
@Override
public String parseFilename(final JSONObject issue) {
//Get component
String componentKey = issue.optString(ISSUE_COMPONENT, null);
JSONObject component = findComponentByKey(componentKey);
if (component != null) {
//Get file path inside module
String filePath = component.optString(COMPONENT_PATH);
//Get module file path
String modulePath = parseModulePath(issue, ISSUE_SUB_PROJECT);
return modulePath + filePath;
} else {
return super.parseFilename(issue);
}
}
}