Skip to content

Commit

Permalink
Small refactorings and fixed some code style issues.
Browse files Browse the repository at this point in the history
  • Loading branch information
uhafner committed Jul 10, 2018
1 parent 1ec6e8e commit 08c65dc
Show file tree
Hide file tree
Showing 7 changed files with 227 additions and 262 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import org.json.JSONObject;

/**
* Class which parses SonarQube reports taken from Sonarqube differential scan report (preview).
* Class which parses SonarQube reports taken from SonarQube differential scan report (preview).
*
* @author Carles Capdevila
*/
Expand All @@ -13,28 +13,13 @@ public class SonarQubeDiffParser extends SonarQubeParser {
private static final String ISSUE_IS_NEW = "isNew";
private static final String COMPONENT_MODULE_KEY = "moduleKey";

/** {@inheritDoc} */
@Override
public boolean issueFilter(final JSONObject issue) {
public boolean filterIssue(final JSONObject issue) {
return issue.optBoolean(ISSUE_IS_NEW, false);
}

@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(component, COMPONENT_MODULE_KEY);
return modulePath + filePath;
} else {
return super.parseFilename(issue);
}
protected String getModulePath(final JSONObject component, final JSONObject issue) {
return parseModulePath(component, COMPONENT_MODULE_KEY);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -3,31 +3,17 @@
import org.json.JSONObject;

/**
* Class which parses SonarQube reports taken from the Sonarqube API (api/issues/search).
* 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";
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);
}
protected String getModulePath(final JSONObject component, final JSONObject issue) {
return parseModulePath(issue, ISSUE_SUB_PROJECT);
}

}

0 comments on commit 08c65dc

Please sign in to comment.