|
|
@ -65,7 +65,7 @@ public class SonarService {
|
|
|
|
"-Dsonar.projectBaseDir=" + param.getProjectPath();
|
|
|
|
"-Dsonar.projectBaseDir=" + param.getProjectPath();
|
|
|
|
|
|
|
|
|
|
|
|
SystemUtil.ExecuteResp executeResp = SystemUtil.executeAndGetExitStatus(command);
|
|
|
|
SystemUtil.ExecuteResp executeResp = SystemUtil.executeAndGetExitStatus(command);
|
|
|
|
log.info("java语言:command{},result:{}",command,executeResp.getOutput());
|
|
|
|
log.info("java语言:command{},result:{}", command, executeResp.getOutput());
|
|
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
});
|
|
|
|
concurrentHashMap.put(Constant.PYTHON, param -> {
|
|
|
|
concurrentHashMap.put(Constant.PYTHON, param -> {
|
|
|
@ -77,7 +77,7 @@ public class SonarService {
|
|
|
|
"-Dsonar.projectBaseDir=" + param.getProjectPath();
|
|
|
|
"-Dsonar.projectBaseDir=" + param.getProjectPath();
|
|
|
|
|
|
|
|
|
|
|
|
SystemUtil.ExecuteResp executeResp = SystemUtil.executeAndGetExitStatus(command);
|
|
|
|
SystemUtil.ExecuteResp executeResp = SystemUtil.executeAndGetExitStatus(command);
|
|
|
|
log.info("python语言:command{},result:{}",command,executeResp.getOutput());
|
|
|
|
log.info("python语言:command{},result:{}", command, executeResp.getOutput());
|
|
|
|
});
|
|
|
|
});
|
|
|
|
concurrentHashMap.put(Constant.C, param -> {
|
|
|
|
concurrentHashMap.put(Constant.C, param -> {
|
|
|
|
String command = "cppcheck --xml --xml-version=2 --enable=all " + param.getProjectPath() + " 2> " + param.getCppCheckReportPath() +
|
|
|
|
String command = "cppcheck --xml --xml-version=2 --enable=all " + param.getProjectPath() + " 2> " + param.getCppCheckReportPath() +
|
|
|
@ -89,7 +89,7 @@ public class SonarService {
|
|
|
|
"-Dsonar.cxx.cppcheck.reportPath=" + param.getCppCheckReportPath() + " " +
|
|
|
|
"-Dsonar.cxx.cppcheck.reportPath=" + param.getCppCheckReportPath() + " " +
|
|
|
|
"-Dsonar.projectBaseDir=" + param.getProjectPath();
|
|
|
|
"-Dsonar.projectBaseDir=" + param.getProjectPath();
|
|
|
|
SystemUtil.ExecuteResp executeResp = SystemUtil.executeAndGetExitStatus(command);
|
|
|
|
SystemUtil.ExecuteResp executeResp = SystemUtil.executeAndGetExitStatus(command);
|
|
|
|
log.info("c语言:command{},result:{}",command,executeResp.getOutput());
|
|
|
|
log.info("c语言:command{},result:{}", command, executeResp.getOutput());
|
|
|
|
});
|
|
|
|
});
|
|
|
|
concurrentHashMap.put(Constant.CXX, param -> {
|
|
|
|
concurrentHashMap.put(Constant.CXX, param -> {
|
|
|
|
String command = "cppcheck --xml --xml-version=2 --enable=all " + param.getProjectPath() + " 2> " + param.getCppCheckReportPath() +
|
|
|
|
String command = "cppcheck --xml --xml-version=2 --enable=all " + param.getProjectPath() + " 2> " + param.getCppCheckReportPath() +
|
|
|
@ -103,6 +103,30 @@ public class SonarService {
|
|
|
|
SystemUtil.ExecuteResp executeResp = SystemUtil.executeAndGetExitStatus(command);
|
|
|
|
SystemUtil.ExecuteResp executeResp = SystemUtil.executeAndGetExitStatus(command);
|
|
|
|
log.info("c++: command:{}, result:{}", command, executeResp.getOutput());
|
|
|
|
log.info("c++: command:{}, result:{}", command, executeResp.getOutput());
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
concurrentHashMap.put(Constant.H, param -> {
|
|
|
|
|
|
|
|
String command = "sonar-scanner " +
|
|
|
|
|
|
|
|
"-Dsonar.host.url=" + sonarUrl + " " +
|
|
|
|
|
|
|
|
"-Dsonar.sourceEncoding=utf-8 " +
|
|
|
|
|
|
|
|
"-Dsonar.login=" + sonarToken + " " +
|
|
|
|
|
|
|
|
"-Dsonar.projectKey=" + param.getProjectKey() + " " +
|
|
|
|
|
|
|
|
"-Dsonar.projectBaseDir=" + param.getProjectPath();
|
|
|
|
|
|
|
|
SystemUtil.ExecuteResp executeResp = SystemUtil.executeAndGetExitStatus(command);
|
|
|
|
|
|
|
|
log.info("H语言 command: {},result:{}", command, executeResp.getOutput());
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
concurrentHashMap.put(Constant.OTHER, param -> {
|
|
|
|
|
|
|
|
String command = "sonar-scanner " +
|
|
|
|
|
|
|
|
"-Dsonar.host.url=" + sonarUrl + " " +
|
|
|
|
|
|
|
|
"-Dsonar.sourceEncoding=utf-8 " +
|
|
|
|
|
|
|
|
"-Dsonar.projectKey=" + param.getProjectKey() + " " +
|
|
|
|
|
|
|
|
"-Dsonar.login=" + sonarToken + " " +
|
|
|
|
|
|
|
|
"-Dsonar.projectBaseDir=" + param.getProjectPath();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SystemUtil.ExecuteResp executeResp = SystemUtil.executeAndGetExitStatus(command);
|
|
|
|
|
|
|
|
log.info("Other语言 command:{},result:{}", command, executeResp.getOutput());
|
|
|
|
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
@ -182,7 +206,7 @@ public class SonarService {
|
|
|
|
public void sonar(String language, SonarScannerParam sonarScannerParam) {
|
|
|
|
public void sonar(String language, SonarScannerParam sonarScannerParam) {
|
|
|
|
Consumer<SonarScannerParam> consumer = concurrentHashMap.get(language.toLowerCase());
|
|
|
|
Consumer<SonarScannerParam> consumer = concurrentHashMap.get(language.toLowerCase());
|
|
|
|
if (consumer != null) {
|
|
|
|
if (consumer != null) {
|
|
|
|
log.info("语言:{},projectName:{},path:{}找到了consumer", language, sonarScannerParam.getProjectKey(),sonarScannerParam.getProjectPath());
|
|
|
|
log.info("语言:{},projectName:{},path:{}找到了consumer", language, sonarScannerParam.getProjectKey(), sonarScannerParam.getProjectPath());
|
|
|
|
consumer.accept(sonarScannerParam);
|
|
|
|
consumer.accept(sonarScannerParam);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -202,10 +226,11 @@ public class SonarService {
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 是否是支持的语言
|
|
|
|
* 是否是支持的语言
|
|
|
|
|
|
|
|
*
|
|
|
|
* @param language
|
|
|
|
* @param language
|
|
|
|
* @return
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public boolean supportLanguage(String language){
|
|
|
|
public boolean supportLanguage(String language) {
|
|
|
|
return concurrentHashMap.containsKey(language.toLowerCase());
|
|
|
|
return concurrentHashMap.containsKey(language.toLowerCase());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|