Compare commits

...

4 Commits

@ -129,7 +129,7 @@ public class QualityInspectController {
*/ */
@GetMapping("/problemAnalysis") @GetMapping("/problemAnalysis")
@ResponseBody @ResponseBody
public ResponseResult<ProblemAnalysisDTO> problemAnalysis(@RequestParam Integer ruleId) { public ResponseResult<ProblemAnalysisDTO> problemAnalysis(@RequestParam String ruleId) {
ProblemAnalysisDTO problemAnalysis = qualityInspectService.getProblemAnalysis(ruleId); ProblemAnalysisDTO problemAnalysis = qualityInspectService.getProblemAnalysis(ruleId);
return ResponseResult.success(problemAnalysis); return ResponseResult.success(problemAnalysis);
} }

@ -2,6 +2,7 @@ package net.educoder.ecsonar.dao;
import net.educoder.ecsonar.model.Issues; import net.educoder.ecsonar.model.Issues;
import net.educoder.ecsonar.model.dto.DegreeDTO; import net.educoder.ecsonar.model.dto.DegreeDTO;
import org.apache.ibatis.annotations.Param;
import java.util.List; import java.util.List;
@ -38,9 +39,10 @@ public interface IssuesDao {
* *
* @param projectUuid * @param projectUuid
* @param issueType * @param issueType
* @param metricName
* @return * @return
*/ */
DegreeDTO queryDegree(String projectUuid, Integer issueType, Integer metricId); DegreeDTO queryDegree(String projectUuid, Integer issueType, String metricName);
/** /**
@ -48,5 +50,5 @@ public interface IssuesDao {
* @param issueId * @param issueId
* @return * @return
*/ */
Issues queryById(Long issueId); Issues queryById(@Param("issueId") String issueId);
} }

@ -13,42 +13,66 @@ import org.springframework.stereotype.Repository;
@Mapper @Mapper
public interface ProjectDao { public interface ProjectDao {
@Select("select * from projects where name = #{name}") @Select("select uuid,kee,qualifier,name from projects where name = #{name}")
Project findByName(@Param("name")String name); Project findByName(@Param("name")String name);
@Select("select COALESCE(value,0) from project_measures where component_uuid = #{uuid} and metric_id = 19 order by id desc limit 1") /**
*
* @param uuid
* @return
*/
@Select("select COALESCE(value,0) from project_measures where component_uuid = #{uuid} and metric_uuid = select uuid from metrics m where name='file_complexity' limit 1")
Float getComplexity(@Param("uuid") String uuid); Float getComplexity(@Param("uuid") String uuid);
@Select("select COALESCE(value,0) from project_measures where component_uuid = #{uuid} and metric_id = 1 order by id desc limit 1") /**
*
* @param uuid
* @return
*/
@Select("select COALESCE(value,0) from project_measures where component_uuid = #{uuid} and metric_uuid=(select uuid from metrics m where name='lines') limit 1")
Integer getLines(@Param("uuid") String uuid); Integer getLines(@Param("uuid") String uuid);
@Select("select text_value from project_measures where component_uuid = #{uuid} and metric_id = #{metric_id} order by id desc limit 1") /**
String getLevel(@Param("uuid") String uuid, @Param("metric_id") int metric_id); *
* @param uuid
* @param metricName
* @return
*/
@Select("select text_value from project_measures where component_uuid = #{uuid} and metric_uuid=(select uuid from metrics m where name=#{metricName}}) limit 1")
String getLevel(@Param("uuid") String uuid, @Param("metricName") String metricName);
@Select("SELECT count(*) FROM issues where project_uuid=#{uuid} and " + @Select("SELECT count(*) FROM issues where project_uuid=#{uuid} and " +
"status='OPEN' and issue_type=#{issue_type} and severity=#{severity}") "status='OPEN' and issue_type=#{issue_type} and severity=#{severity}")
int getIndicator(@Param("uuid") String uuid, @Param("issue_type") int issue_type, @Param("severity") String severity); int getIndicator(@Param("uuid") String uuid, @Param("issue_type") int issue_type, @Param("severity") String severity);
/**
* 93 == AYeNSwayTEppvP7II93_
* 89 == AYeNSwayTEppvP7II94B
* 80 == AYeNSwaxTEppvP7II93y
* 19 == AYeNSwarTEppvP7II92z
* @param projectUuid
* @return
*/
@Select("select " + @Select("select " +
"(select COALESCE(value,0) complexity from project_measures where component_uuid = #{projectUuid} and metric_id = 19 order by id desc limit 1)," + "(select COALESCE(value,0) complexity from project_measures where component_uuid = #{projectUuid} and metric_uuid = (select uuid from metrics m where name='file_complexity') limit 1)," +
"(select COALESCE(value,0) lines from project_measures where component_uuid = #{projectUuid} and metric_id = 1 order by id desc limit 1)," + "(select COALESCE(value,0) lines from project_measures where component_uuid = #{projectUuid} and metric_uuid = (select uuid from metrics m where name='lines') limit 1)," +
"(SELECT COALESCE(count(*),0) block_code_smells FROM issues where project_uuid=#{projectUuid} and status='OPEN' and issue_type=1 and severity='BLOCKER'), " + "(SELECT COALESCE(count(*),0) block_code_smells FROM issues where project_uuid=#{projectUuid} and status='OPEN' and issue_type=1 and severity='BLOCKER'), " +
"(SELECT COALESCE(count(*),0) critical_code_smells FROM issues where project_uuid=#{projectUuid} and status='OPEN' and issue_type=1 and severity='CRITICAL')," + "(SELECT COALESCE(count(*),0) critical_code_smells FROM issues where project_uuid=#{projectUuid} and status='OPEN' and issue_type=1 and severity='CRITICAL')," +
"(SELECT COALESCE(count(*),0) major_code_smells FROM issues where project_uuid=#{projectUuid} and status='OPEN' and issue_type=1 and severity='MAJOR')," + "(SELECT COALESCE(count(*),0) major_code_smells FROM issues where project_uuid=#{projectUuid} and status='OPEN' and issue_type=1 and severity='MAJOR')," +
"(SELECT COALESCE(count(*),0) minor_code_smells FROM issues where project_uuid=#{projectUuid} and status='OPEN' and issue_type=1 and severity='MINOR')," + "(SELECT COALESCE(count(*),0) minor_code_smells FROM issues where project_uuid=#{projectUuid} and status='OPEN' and issue_type=1 and severity='MINOR')," +
"(select text_value code_smells from project_measures where component_uuid = #{projectUuid} and metric_id = 80 order by id desc limit 1)," + "(select text_value code_smells from project_measures where component_uuid = #{projectUuid} and metric_uuid = (select uuid from metrics m where name='sqale_rating') limit 1)," +
"(SELECT COALESCE(count(*),0) block_bugs FROM issues where project_uuid=#{projectUuid} and status='OPEN' and issue_type=2 and severity='BLOCKER'), " + "(SELECT COALESCE(count(*),0) block_bugs FROM issues where project_uuid=#{projectUuid} and status='OPEN' and issue_type=2 and severity='BLOCKER'), " +
"(SELECT COALESCE(count(*),0) critical_bugs FROM issues where project_uuid=#{projectUuid} and status='OPEN' and issue_type=2 and severity='CRITICAL')," + "(SELECT COALESCE(count(*),0) critical_bugs FROM issues where project_uuid=#{projectUuid} and status='OPEN' and issue_type=2 and severity='CRITICAL')," +
"(SELECT COALESCE(count(*),0) major_bugs FROM issues where project_uuid=#{projectUuid} and status='OPEN' and issue_type=2 and severity='MAJOR')," + "(SELECT COALESCE(count(*),0) major_bugs FROM issues where project_uuid=#{projectUuid} and status='OPEN' and issue_type=2 and severity='MAJOR')," +
"(SELECT COALESCE(count(*),0) minor_bugs FROM issues where project_uuid=#{projectUuid} and status='OPEN' and issue_type=2 and severity='MINOR')," + "(SELECT COALESCE(count(*),0) minor_bugs FROM issues where project_uuid=#{projectUuid} and status='OPEN' and issue_type=2 and severity='MINOR')," +
"(select text_value bugs from project_measures where component_uuid = #{projectUuid} and metric_id = 89 order by id desc limit 1)," + "(select text_value bugs from project_measures where component_uuid = #{projectUuid} and metric_uuid = (select uuid from metrics m where name='security_review_rating') limit 1)," +
"(SELECT COALESCE(count(*),0) block_violations FROM issues where project_uuid=#{projectUuid} and status='OPEN' and issue_type=3 and severity='BLOCKER'), " + "(SELECT COALESCE(count(*),0) block_violations FROM issues where project_uuid=#{projectUuid} and status='OPEN' and issue_type=3 and severity='BLOCKER'), " +
"(SELECT COALESCE(count(*),0) critical_violations FROM issues where project_uuid=#{projectUuid} and status='OPEN' and issue_type=3 and severity='CRITICAL')," + "(SELECT COALESCE(count(*),0) critical_violations FROM issues where project_uuid=#{projectUuid} and status='OPEN' and issue_type=3 and severity='CRITICAL')," +
"(SELECT COALESCE(count(*),0) major_violations FROM issues where project_uuid=#{projectUuid} and status='OPEN' and issue_type=3 and severity='MAJOR')," + "(SELECT COALESCE(count(*),0) major_violations FROM issues where project_uuid=#{projectUuid} and status='OPEN' and issue_type=3 and severity='MAJOR')," +
"(SELECT COALESCE(count(*),0) minor_violations FROM issues where project_uuid=#{projectUuid} and status='OPEN' and issue_type=3 and severity='MINOR')," + "(SELECT COALESCE(count(*),0) minor_violations FROM issues where project_uuid=#{projectUuid} and status='OPEN' and issue_type=3 and severity='MINOR')," +
"(select text_value violations from project_measures where component_uuid = #{projectUuid} and metric_id = 93 order by id desc limit 1)") "(select text_value violations from project_measures where component_uuid = #{projectUuid} and metric_uuid = (select uuid from metrics m where name='security_rating') limit 1)")
Metrics selectMetricsByProjectUuid(String projectUuid); Metrics selectMetricsByProjectUuid(String projectUuid);
@ -57,13 +81,16 @@ public interface ProjectDao {
@Select("select (select count(1) from issues where project_uuid=#{projectUuid} and issue_type=1) codeSmell," + @Select("select (select count(1) from issues where project_uuid=#{projectUuid} and issue_type=1) codeSmell," +
"(select count(1) from issues where project_uuid=#{projectUuid} and issue_type=2) bugs," + "(select count(1) from issues where project_uuid=#{projectUuid} and issue_type=2) bugs," +
"(select count(1) from issues where project_uuid=#{projectUuid} and issue_type=3) vulnerability," + "(select count(1) from issues where project_uuid=#{projectUuid} and issue_type=3) vulnerability," +
"(select value from project_measures pm where component_uuid=#{projectUuid} and metric_id=3) codeLines") "(select value from project_measures pm where component_uuid=#{projectUuid} and metric_uuid=(select uuid from metrics m where name='ncloc')) codeLines")
IssuesMetrics selectIssuesMetrics(String projectUuid); IssuesMetrics selectIssuesMetrics(String projectUuid);
/** /**
* rule * rule
* @param id * @param uuid
* @return * @return
*/ */
Rule findRuleById(@Param("id") Integer id); Rule findRuleById(@Param("uuid") String uuid);
// @Select("select uuid from metrics m where name=#{name}}")
// String findMetricUUIDByName(@Param("name") String name);
} }

@ -8,17 +8,20 @@ package net.educoder.ecsonar.enums;
*/ */
public enum AnalyseTypeEnum { public enum AnalyseTypeEnum {
CodeSmell(1,80), CodeSmell(1,80, "sqale_rating"),
BUG(2, 89), BUG(2, 89, "security_review_rating"),
Vulnerability(3,93); Vulnerability(3,93, "security_rating");
private Integer type; private Integer type;
private Integer metricId; private Integer metricId;
private String metricName;
AnalyseTypeEnum(Integer type, Integer metricId) {
AnalyseTypeEnum(Integer type, Integer metricId, String metricName) {
this.type = type; this.type = type;
this.metricId = metricId; this.metricId = metricId;
this.metricName = metricName;
} }
@ -30,6 +33,10 @@ public enum AnalyseTypeEnum {
return metricId; return metricId;
} }
public String getMetricName() {
return metricName;
}
public static AnalyseTypeEnum getAnalyseTypeEnum(Integer type) { public static AnalyseTypeEnum getAnalyseTypeEnum(Integer type) {
for (AnalyseTypeEnum analyseType : values()) { for (AnalyseTypeEnum analyseType : values()) {
if (analyseType.type.equals(type)) { if (analyseType.type.equals(type)) {

@ -22,7 +22,7 @@ public class FileSource {
private static final String SIZE_LIMIT_EXCEEDED_EXCEPTION_MESSAGE = "Protocol message was too large. May be malicious. " + private static final String SIZE_LIMIT_EXCEEDED_EXCEPTION_MESSAGE = "Protocol message was too large. May be malicious. " +
"Use CodedInputStream.setSizeLimit() to increase the size limit."; "Use CodedInputStream.setSizeLimit() to increase the size limit.";
private Long id; private String uuid;
private String projectUuid; private String projectUuid;
private String fileUuid; private String fileUuid;
private String lineHashes; private String lineHashes;
@ -36,7 +36,7 @@ public class FileSource {
return decodeRegularSourceData(binaryData); return decodeRegularSourceData(binaryData);
} catch (IOException e) { } catch (IOException e) {
throw new IllegalStateException( throw new IllegalStateException(
format("Fail to decompress and deserialize source data [id=%s,fileUuid=%s,projectUuid=%s]", id, fileUuid, projectUuid), format("Fail to decompress and deserialize source data [id=%s,fileUuid=%s,projectUuid=%s]", uuid, fileUuid, projectUuid),
e); e);
} }
} }

@ -11,9 +11,8 @@ import lombok.Data;
@Data @Data
public class Issues { public class Issues {
private Long id; private String id;
private String kee; private String ruleId;
private Integer ruleId;
private String severity; private String severity;
private String message; private String message;
private String status; private String status;
@ -26,10 +25,6 @@ public class Issues {
* bug * bug
*/ */
private String name; private String name;
/**
* bug
*/
private String description;
/** /**
* *
*/ */

@ -2,35 +2,36 @@ package net.educoder.ecsonar.model;
public class Project { public class Project {
private int id; private String uuid;
private boolean enabled; private String kee;
private String qualifier;
private String project_uuid;
private String name; private String name;
public boolean isEnabled() { public String getUuid() {
return enabled; return uuid;
} }
public void setEnabled(boolean enabled) { public void setUuid(String uuid) {
this.enabled = enabled; this.uuid = uuid;
} }
public int getId() { public String getKee() {
return id; return kee;
} }
public void setId(int id) { public void setKee(String kee) {
this.id = id; this.kee = kee;
} }
public String getProject_uuid() { public String getQualifier() {
return project_uuid; return qualifier;
} }
public void setProject_uuid(String project_uuid) { public void setQualifier(String qualifier) {
this.project_uuid = project_uuid; this.qualifier = qualifier;
} }
public String getName() { public String getName() {

@ -43,8 +43,8 @@ public class AnalyseDetailListDTO {
*/ */
private String uuid; private String uuid;
private Integer ruleId; private String ruleId;
private Long issueId; private String issueId;
} }

@ -12,6 +12,6 @@ public class CodeDetailVO {
private String uuid; private String uuid;
private Integer ruleId; private String ruleId;
private Long issueId; private String issueId;
} }

@ -151,7 +151,7 @@ public class CloudBrainService {
return resultVO; return resultVO;
} }
IssuesMetrics issuesMetrics = projectDao.selectIssuesMetrics(project.getProject_uuid()); IssuesMetrics issuesMetrics = projectDao.selectIssuesMetrics(project.getUuid());
resultVO.setTaskName(projectName); resultVO.setTaskName(projectName);
resultVO.setBugs(issuesMetrics.getBugs()); resultVO.setBugs(issuesMetrics.getBugs());
resultVO.setVulnerability(issuesMetrics.getVulnerability()); resultVO.setVulnerability(issuesMetrics.getVulnerability());

@ -56,7 +56,7 @@ public class DbOperateService {
if (project == null) { if (project == null) {
return null; return null;
} }
return ceActivityDao.queryActivityStatus(project.getProject_uuid()); return ceActivityDao.queryActivityStatus(project.getUuid());
} }

@ -240,9 +240,9 @@ public class QualityInspectService {
throw new BusinessException(-1, String.format("找不到分析记录homeworkId:%s,studentNo:%s", analyseDetailVO.getHomeworkId(), analyseDetailVO.getStudentNo())); throw new BusinessException(-1, String.format("找不到分析记录homeworkId:%s,studentNo:%s", analyseDetailVO.getHomeworkId(), analyseDetailVO.getStudentNo()));
} }
DegreeDTO codeSmall = issuesDao.queryDegree(project.getProject_uuid(), AnalyseTypeEnum.CodeSmell.getType(), AnalyseTypeEnum.CodeSmell.getMetricId()); DegreeDTO codeSmall = issuesDao.queryDegree(project.getUuid(), AnalyseTypeEnum.CodeSmell.getType(), AnalyseTypeEnum.CodeSmell.getMetricName());
DegreeDTO bug = issuesDao.queryDegree(project.getProject_uuid(), AnalyseTypeEnum.BUG.getType(), AnalyseTypeEnum.BUG.getMetricId()); DegreeDTO bug = issuesDao.queryDegree(project.getUuid(), AnalyseTypeEnum.BUG.getType(), AnalyseTypeEnum.BUG.getMetricName());
DegreeDTO vulnerability = issuesDao.queryDegree(project.getProject_uuid(), AnalyseTypeEnum.Vulnerability.getType(), AnalyseTypeEnum.Vulnerability.getMetricId()); DegreeDTO vulnerability = issuesDao.queryDegree(project.getUuid(), AnalyseTypeEnum.Vulnerability.getType(), AnalyseTypeEnum.Vulnerability.getMetricName());
AnalyseDetailDTO analyseDetail = new AnalyseDetailDTO(); AnalyseDetailDTO analyseDetail = new AnalyseDetailDTO();
analyseDetail.setBug(bug == null ? new DegreeDTO() : bug); analyseDetail.setBug(bug == null ? new DegreeDTO() : bug);
@ -291,11 +291,11 @@ public class QualityInspectService {
severity = degreeEnum.getValue(); severity = degreeEnum.getValue();
} }
Integer pageIssuesCount = issuesDao.getPageIssuesCount(project.getProject_uuid(), analyseTypeEnum.getType(), severity); Integer pageIssuesCount = issuesDao.getPageIssuesCount(project.getUuid(), analyseTypeEnum.getType(), severity);
rollPage.setRecordSum(pageIssuesCount); rollPage.setRecordSum(pageIssuesCount);
if (pageIssuesCount > 0) { if (pageIssuesCount > 0) {
int start = (analyseDetailListVO.getCurrentPage() - 1) * analyseDetailListVO.getPageSize(); int start = (analyseDetailListVO.getCurrentPage() - 1) * analyseDetailListVO.getPageSize();
List<Issues> pageIssues = issuesDao.getPageIssues(project.getProject_uuid(), analyseTypeEnum.getType(), severity, start, analyseDetailListVO.getPageSize()); List<Issues> pageIssues = issuesDao.getPageIssues(project.getUuid(), analyseTypeEnum.getType(), severity, start, analyseDetailListVO.getPageSize());
processPageIssues(pageIssues, rollPage); processPageIssues(pageIssues, rollPage);
} else { } else {
rollPage.setRecordList(new ArrayList(0)); rollPage.setRecordList(new ArrayList(0));
@ -304,7 +304,7 @@ public class QualityInspectService {
return rollPage; return rollPage;
} }
public ProblemAnalysisDTO getProblemAnalysis(Integer ruleId) { public ProblemAnalysisDTO getProblemAnalysis(String ruleId) {
Rule rule = projectDao.findRuleById(ruleId); Rule rule = projectDao.findRuleById(ruleId);
ProblemAnalysisDTO problemAnalysisDTO = new ProblemAnalysisDTO(); ProblemAnalysisDTO problemAnalysisDTO = new ProblemAnalysisDTO();
if (rule != null) { if (rule != null) {

@ -1,6 +1,7 @@
package net.educoder.ecsonar.services; package net.educoder.ecsonar.services;
import net.educoder.ecsonar.dao.ProjectDao; import net.educoder.ecsonar.dao.ProjectDao;
import net.educoder.ecsonar.enums.AnalyseTypeEnum;
import net.educoder.ecsonar.model.Metrics; import net.educoder.ecsonar.model.Metrics;
import net.educoder.ecsonar.model.Project; import net.educoder.ecsonar.model.Project;
import net.educoder.ecsonar.utils.ExcelUtil; import net.educoder.ecsonar.utils.ExcelUtil;
@ -32,7 +33,7 @@ public class ReportService {
if (project==null){ if (project==null){
return getDefault(); return getDefault();
} }
String uuid = project.getProject_uuid(); String uuid = project.getUuid();
Metrics metrics = projectDao.selectMetricsByProjectUuid(uuid); Metrics metrics = projectDao.selectMetricsByProjectUuid(uuid);
@ -162,7 +163,7 @@ public class ReportService {
*/ */
private String getViolations(String uuid) { private String getViolations(String uuid) {
//93 //93
return projectDao.getLevel(uuid, 93); return projectDao.getLevel(uuid, AnalyseTypeEnum.Vulnerability.getMetricName());
} }
@ -209,7 +210,7 @@ public class ReportService {
*/ */
private String getBugs(String uuid) { private String getBugs(String uuid) {
//89 //89
return projectDao.getLevel(uuid, 89); return projectDao.getLevel(uuid, AnalyseTypeEnum.BUG.getMetricName());
} }
@ -256,7 +257,7 @@ public class ReportService {
*/ */
private String getCodeSmells(String uuid) { private String getCodeSmells(String uuid) {
//80 //80
return projectDao.getLevel(uuid, 80); return projectDao.getLevel(uuid, AnalyseTypeEnum.CodeSmell.getMetricName());
} }

@ -42,8 +42,8 @@ public class SonarService {
@Value("${sonar.url}") @Value("${sonar.url}")
String sonarUrl; String sonarUrl;
// @Value("${sonar.token}") @Value("${sonar.token}")
// String sonarToken; String sonarToken;
@Value("${extract.path}") @Value("${extract.path}")
String extractProgramPath; String extractProgramPath;
@ -58,6 +58,7 @@ public class SonarService {
concurrentHashMap.put(Constant.JAVA, param -> { concurrentHashMap.put(Constant.JAVA, param -> {
String command = "sonar-scanner " + String command = "sonar-scanner " +
"-Dsonar.host.url=" + sonarUrl + " " + "-Dsonar.host.url=" + sonarUrl + " " +
"-Dsonar.token=" + sonarToken + " " +
"-Dsonar.sourceEncoding=utf-8 " + "-Dsonar.sourceEncoding=utf-8 " +
"-Dsonar.projectKey=" + param.getProjectKey() + " " + "-Dsonar.projectKey=" + param.getProjectKey() + " " +
"-Dsonar.java.binaries=./ " + "-Dsonar.java.binaries=./ " +
@ -70,6 +71,7 @@ public class SonarService {
concurrentHashMap.put(Constant.PYTHON, param -> { concurrentHashMap.put(Constant.PYTHON, param -> {
String command = "sonar-scanner " + String command = "sonar-scanner " +
"-Dsonar.host.url=" + sonarUrl + " " + "-Dsonar.host.url=" + sonarUrl + " " +
"-Dsonar.token=" + sonarToken + " " +
"-Dsonar.sourceEncoding=utf-8 " + "-Dsonar.sourceEncoding=utf-8 " +
"-Dsonar.projectKey=" + param.getProjectKey() + " " + "-Dsonar.projectKey=" + param.getProjectKey() + " " +
"-Dsonar.projectBaseDir=" + param.getProjectPath(); "-Dsonar.projectBaseDir=" + param.getProjectPath();
@ -81,6 +83,7 @@ public class SonarService {
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() +
"&& sonar-scanner " + "&& sonar-scanner " +
"-Dsonar.host.url=" + sonarUrl + " " + "-Dsonar.host.url=" + sonarUrl + " " +
"-Dsonar.token=" + sonarToken + " " +
"-Dsonar.sourceEncoding=utf-8 " + "-Dsonar.sourceEncoding=utf-8 " +
"-Dsonar.projectKey=" + param.getProjectKey() + " " + "-Dsonar.projectKey=" + param.getProjectKey() + " " +
"-Dsonar.cxx.cppcheck.reportPath=" + param.getCppCheckReportPath() + " " + "-Dsonar.cxx.cppcheck.reportPath=" + param.getCppCheckReportPath() + " " +
@ -92,6 +95,7 @@ public class SonarService {
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() +
"&& sonar-scanner " + "&& sonar-scanner " +
"-Dsonar.host.url=" + sonarUrl + " " + "-Dsonar.host.url=" + sonarUrl + " " +
"-Dsonar.token=" + sonarToken + " " +
"-Dsonar.sourceEncoding=utf-8 " + "-Dsonar.sourceEncoding=utf-8 " +
"-Dsonar.projectKey=" + param.getProjectKey() + " " + "-Dsonar.projectKey=" + param.getProjectKey() + " " +
"-Dsonar.cxx.cppcheck.reportPath=" + param.getCppCheckReportPath() + " " + "-Dsonar.cxx.cppcheck.reportPath=" + param.getCppCheckReportPath() + " " +

@ -6,9 +6,9 @@
spring.datasource.initSize=20 spring.datasource.initSize=20
#spring.datasource.master.url=jdbc:postgresql://127.0.0.1:5432/sonar7.7 #spring.datasource.master.url=jdbc:postgresql://127.0.0.1:5432/sonar7.7
spring.datasource.master.url=jdbc:postgresql://117.50.14.123:5432/sonar spring.datasource.master.url=jdbc:postgresql://106.75.223.53:5432/sonarqube10
spring.datasource.master.username=sonar spring.datasource.master.username=postgres
spring.datasource.master.password=sonar spring.datasource.master.password=sonarqube
spring.datasource.master.driverClassName=org.postgresql.Driver spring.datasource.master.driverClassName=org.postgresql.Driver
@ -43,10 +43,12 @@ zip.save.path=/tmp/
#excel.template.path=/Users/guange/work/java/ecsonar/src/main/resources/template.xlsx #excel.template.path=/Users/guange/work/java/ecsonar/src/main/resources/template.xlsx
excel.template.path=template.xlsx excel.template.path=template.xlsx
sonar.url=http://127.0.0.1:9000 sonar.url=http://106.75.223.53:9005
#sonar.url=http://117.50.14.123:9000 #sonar.url=http://117.50.14.123:9000
# token令牌 # token令牌
sonar.token=0253a518e824a976ea2f11aec17938cb0f8c0495 #sonar.token=0253a518e824a976ea2f11aec17938cb0f8c0495
# ??token
sonar.token=sqa_6615790f07532bfb2cc180f63808548534f75544
extract.path=/usr/local/bin/unar extract.path=/usr/local/bin/unar
#extract.path=/usr/bin/unar #extract.path=/usr/bin/unar
@ -59,4 +61,4 @@ skip.checked=true
server.port=8081 server.port=8081
mybatis.mapper-locations=classpath:mapper/* mybatis.mapper-locations=classpath:mapper/*
sonar.host=http://localhost:9000 sonar.host=http://106.75.223.53:9005

@ -5,7 +5,7 @@
<select id="findFileSourceFileUuid" parameterType="java.lang.String" resultType="net.educoder.ecsonar.model.FileSource"> <select id="findFileSourceFileUuid" parameterType="java.lang.String" resultType="net.educoder.ecsonar.model.FileSource">
select select
id, uuid,
project_uuid as projectUuid, project_uuid as projectUuid,
file_uuid as fileUuid, file_uuid as fileUuid,
binary_data as binaryData, binary_data as binaryData,

@ -8,11 +8,11 @@
select select
count(1) count(1)
from issues i from issues i
inner join rules r on i.rule_id =r.id inner join rules r on i.rule_uuid =r.uuid
inner join projects p on p.uuid =i.component_uuid inner join projects p on p.uuid =i.project_uuid
where i.project_uuid = #{projectUuid,jdbcType=VARCHAR} where i.project_uuid = #{projectUuid,jdbcType=VARCHAR}
and i.status='OPEN' and i.status='OPEN'
and p.root_uuid =#{projectUuid,jdbcType=VARCHAR} and p.uuid !=#{projectUuid,jdbcType=VARCHAR} and p."scope" ='FIL' and p.uuid =#{projectUuid,jdbcType=VARCHAR}
<if test="issueType != null"> <if test="issueType != null">
and i.issue_type=#{issueType,jdbcType=INTEGER} and i.issue_type=#{issueType,jdbcType=INTEGER}
</if> </if>
@ -24,13 +24,16 @@
<select id="getPageIssues" resultType="net.educoder.ecsonar.model.Issues"> <select id="getPageIssues" resultType="net.educoder.ecsonar.model.Issues">
select select
i.id,i.kee,i.rule_id ruleId,i.severity,i.status,i.project_uuid projectUuid,i.issue_type issueType,i.locations,i.line lines,r.name,r.description,r.language,p.path,p.uuid,i.message i.kee id,i.rule_uuid ruleId,i.severity,i.status,i.project_uuid projectUuid,i.issue_type issueType,i.locations,i.line lines,
r.name,c.path,c.uuid,r.language,i.message
from issues i from issues i
inner join rules r on i.rule_id =r.id inner join rules r on i.rule_uuid =r.uuid
inner join projects p on p.uuid =i.component_uuid inner join projects p on p.uuid =i.project_uuid
inner join components c on c.uuid =i.component_uuid
where i.project_uuid = #{projectUuid,jdbcType=VARCHAR} where i.project_uuid = #{projectUuid,jdbcType=VARCHAR}
and i.status='OPEN' and i.status='OPEN'
and p.root_uuid =#{projectUuid,jdbcType=VARCHAR} and p.uuid !=#{projectUuid,jdbcType=VARCHAR} and p."scope" ='FIL' and p.uuid =#{projectUuid,jdbcType=VARCHAR}
and c.uuid !=#{projectUuid,jdbcType=VARCHAR} and c.branch_uuid =#{projectUuid,jdbcType=VARCHAR} and c."scope" ='FIL'
<if test="issueType != null"> <if test="issueType != null">
and i.issue_type=#{issueType,jdbcType=INTEGER} and i.issue_type=#{issueType,jdbcType=INTEGER}
</if> </if>
@ -47,12 +50,13 @@
(select count(1) from issues i where project_uuid =#{projectUuid} and issue_type=#{issueType} and severity = 'MINOR' and status='OPEN') minor, (select count(1) from issues i where project_uuid =#{projectUuid} and issue_type=#{issueType} and severity = 'MINOR' and status='OPEN') minor,
(select count(1) from issues i where project_uuid =#{projectUuid} and issue_type=#{issueType} and severity = 'BLOCKER' and status='OPEN') blocker, (select count(1) from issues i where project_uuid =#{projectUuid} and issue_type=#{issueType} and severity = 'BLOCKER' and status='OPEN') blocker,
(select count(1) from issues i where project_uuid =#{projectUuid} and issue_type=#{issueType} and severity = 'CRITICAL' and status='OPEN') critical, (select count(1) from issues i where project_uuid =#{projectUuid} and issue_type=#{issueType} and severity = 'CRITICAL' and status='OPEN') critical,
(select text_value from project_measures i where component_uuid =#{projectUuid} and metric_id = #{metricId} order by id desc limit 1) levelStr (select text_value from project_measures i where component_uuid =#{projectUuid} and metric_uuid = (select uuid from metrics where name=#{metricName}) limit 1) levelStr
</select> </select>
<select id="queryById" parameterType="java.lang.Long" resultType="net.educoder.ecsonar.model.Issues"> <select id="queryById" parameterType="java.lang.String" resultType="net.educoder.ecsonar.model.Issues">
select i.id,i.kee,i.rule_id ruleId,i.severity,i.status,i.project_uuid projectUuid,i.issue_type issueType,i.locations,i.line lines,i.message from issues i where id=#{issueId} select i.kee id,i.rule_uuid ruleId,i.severity,i.status,i.project_uuid projectUuid,i.issue_type issueType,i.locations,i.line lines,i.message
from issues i where kee=#{issueId}
</select> </select>

@ -3,16 +3,18 @@
<mapper namespace="net.educoder.ecsonar.dao.ProjectDao"> <mapper namespace="net.educoder.ecsonar.dao.ProjectDao">
<select id="findRuleById" parameterType="java.lang.Integer" resultType="net.educoder.ecsonar.model.Rule"> <select id="findRuleById" parameterType="java.lang.String" resultType="net.educoder.ecsonar.model.Rule">
select select
id, r.uuid,
name, r.name,
description, r.language,
language, r.def_remediation_base_effort defRemediationBaseEffort,
def_remediation_base_effort defRemediationBaseEffort, r.system_tags tags,
system_tags tags, r.created_at createTime,
created_at createTime rds.content description
from rules where id=#{id,jdbcType=INTEGER} from rules r
inner join rule_desc_sections rds on r.uuid=rds.rule_uuid
where r.uuid=#{uuid,jdbcType=VARCHAR}
</select> </select>

@ -36,7 +36,7 @@ public class EcsonarApplicationTests {
@Test @Test
public void contextLoads() { public void contextLoads() {
Project demo_maven_webapp = projectDao.findByName("demo Maven Webapp"); Project demo_maven_webapp = projectDao.findByName("demo Maven Webapp");
System.out.println(demo_maven_webapp.getProject_uuid()); System.out.println(demo_maven_webapp.getUuid());
} }
@Test @Test

Loading…
Cancel
Save