parent
216ddf8838
commit
c95eb3fc6d
|
@ -0,0 +1,157 @@
|
||||
"2015551306","李明洋","未发现附件"
|
||||
"2015551317","佘思博","未发现附件"
|
||||
"2015551432","周蓝","未发现附件"
|
||||
"2015551407","李绍禹","未发现附件"
|
||||
"2015551406","刘蕴泽","未发现附件"
|
||||
"2015962037","张鋆","未发现附件"
|
||||
"2015962015","邓联杰","未发现附件"
|
||||
"2015962039","周铭锐","未发现附件"
|
||||
"2015962133","袁凌","未发现附件"
|
||||
"2015962125","王芳华","未发现附件"
|
||||
"2015962131","易程","未发现附件"
|
||||
"2014551331","周敏敏","未发现附件"
|
||||
"2014551309","周杨萍","未发现附件"
|
||||
"2015962036","张星","未发现附件"
|
||||
"2015962011","曹峻源","未发现附件"
|
||||
"2015962037","张鋆","未发现附件"
|
||||
"2015801008","杨旭","未发现附件"
|
||||
"2015962005","林慧","未发现附件"
|
||||
"","p79601584","未发现附件"
|
||||
"2015962033","肖巨","未发现附件"
|
||||
"2015962023","廖广平","未发现附件"
|
||||
"2015962039","周铭锐","未发现附件"
|
||||
"2015962034","杨坤","未发现附件"
|
||||
"2015962031","王耀武","未发现附件"
|
||||
"2015551127","符燕群","未发现附件"
|
||||
"2015962132","尹李杰","未发现附件"
|
||||
"2013960815","李明烈","未发现附件"
|
||||
"2015962118","刘清伟","未发现附件"
|
||||
"2015962103","刘芳芳","未发现附件"
|
||||
"2015551226","张斌","未发现附件"
|
||||
"2015962127","吴俊杰","未发现附件"
|
||||
"2015551217","陈鑫祯","未发现附件"
|
||||
"2015962130","杨旭","未发现附件"
|
||||
"2015962115","李德安","未发现附件"
|
||||
"","p26485079","未发现附件"
|
||||
"2015551220","丁弟","未发现附件"
|
||||
"2015551301","殷昌健","未发现附件"
|
||||
"","txuboy","未发现附件"
|
||||
"2015551216","梁晶","未发现附件"
|
||||
"2015551225","周杰","未发现附件"
|
||||
"20159200204","阳文献","未发现附件"
|
||||
"20159201014","邹子怡","未发现附件"
|
||||
"","p57032168","未发现附件"
|
||||
"20159201017","朱春霖","未发现附件"
|
||||
"2015962102","赖慰锋","未发现附件"
|
||||
"20159200205","李泽湘","未发现附件"
|
||||
"2015551506","姚金城","未发现附件"
|
||||
"","p45037219","未发现附件"
|
||||
"","杨奇为","未发现附件"
|
||||
"2015551535","ZHUxueyi","未发现附件"
|
||||
"edu2015551505","李小庆","未发现附件"
|
||||
"2015551619","唐昭敏","未发现附件"
|
||||
"","p10928657","未发现附件"
|
||||
"2015551614","戴宁","未发现附件"
|
||||
"","p80674219","未发现附件"
|
||||
"","p25804791","未发现附件"
|
||||
"","p95284761","未发现附件"
|
||||
"2015551624","白杰","未发现附件"
|
||||
"2013551512","柯维隆","未发现附件"
|
||||
"2015962036","张星","未发现附件"
|
||||
"","m29345816","未发现附件"
|
||||
"2015551625","斯海洋","未发现附件"
|
||||
"20159200213","黄海兵","未发现附件"
|
||||
"","p92780145","未发现附件"
|
||||
"2015651103","孟世斌","未发现附件"
|
||||
"2015551339","王孟轩","未发现附件"
|
||||
"2015551328","肖兰建","未发现附件"
|
||||
"2015551335","靳付棋","未发现附件"
|
||||
"2015551326","黄趾雄","未发现附件"
|
||||
"2015551302","谢伟胜","未发现附件"
|
||||
"2015551313","罗钦","未发现附件"
|
||||
"","陶索菲","项目文件夹不存在"
|
||||
"","刘振","项目文件夹不存在"
|
||||
"","杨志","项目文件夹不存在"
|
||||
"","陈雅丽","Mapper method itive return type (float)."
|
||||
"","周怡","项目文件夹不存在"
|
||||
"","陶索菲","项目文件夹不存在"
|
||||
"","刘振","项目文件夹不存在"
|
||||
"","杨志","项目文件夹不存在"
|
||||
"","周怡","项目文件夹不存在"
|
||||
"","温豪杰","连接超时 (Read failed)"
|
||||
"","金徽","项目文件夹不存在"
|
||||
"","李航","项目文件夹不存在"
|
||||
"","李一鸣","项目文件夹不存在"
|
||||
""," 董国超","项目文件夹不存在"
|
||||
"","李超","项目文件夹不存在"
|
||||
"","刘圣凯","项目文件夹不存在"
|
||||
"","黄岩珍","项目文件夹不存在"
|
||||
"","周为","项目文件夹不存在"
|
||||
"","李邓平","项目文件夹不存在"
|
||||
"","尹嘉俊","项目文件夹不存在"
|
||||
"","殷昌健","项目文件夹不存在"
|
||||
"","李小庆","项目文件夹不存在"
|
||||
"","李鸿伟","项目文件夹不存在"
|
||||
"","胡锦宇","项目文件夹不存在"
|
||||
"","陈怀泽","项目文件夹不存在"
|
||||
"","高宇博","项目文件夹不存在"
|
||||
"","李耀","项目文件夹不存在"
|
||||
"","杨帆","项目文件夹不存在"
|
||||
"","周蓝","项目文件夹不存在"
|
||||
"","梁晶","项目文件夹不存在"
|
||||
"","刘洋","项目文件夹不存在"
|
||||
"","陶索菲","项目文件夹不存在"
|
||||
"","刘振","项目文件夹不存在"
|
||||
"","杨志","项目文件夹不存在"
|
||||
"","周怡","项目文件夹不存在"
|
||||
"","金徽","项目文件夹不存在"
|
||||
"","李航","项目文件夹不存在"
|
||||
"","李一鸣","项目文件夹不存在"
|
||||
""," 董国超","项目文件夹不存在"
|
||||
"","李超","项目文件夹不存在"
|
||||
"","刘圣凯","项目文件夹不存在"
|
||||
"","黄岩珍","项目文件夹不存在"
|
||||
"","周为","项目文件夹不存在"
|
||||
"","李邓平","项目文件夹不存在"
|
||||
"","尹嘉俊","项目文件夹不存在"
|
||||
"","殷昌健","项目文件夹不存在"
|
||||
"","李小庆","项目文件夹不存在"
|
||||
"","李鸿伟","项目文件夹不存在"
|
||||
"","胡锦宇","项目文件夹不存在"
|
||||
"","陈怀泽","项目文件夹不存在"
|
||||
"","高宇博","项目文件夹不存在"
|
||||
"","李耀","项目文件夹不存在"
|
||||
"","杨帆","项目文件夹不存在"
|
||||
"","周蓝","项目文件夹不存在"
|
||||
"","梁晶","项目文件夹不存在"
|
||||
"","刘洋","项目文件夹不存在"
|
||||
"","阮会姗","项目文件夹不存在"
|
||||
"","毛胤灿","项目文件夹不存在"
|
||||
"","张斌","项目文件夹不存在"
|
||||
"","王梦媛","项目文件夹不存在"
|
||||
"","陈藏宇","项目文件夹不存在"
|
||||
"","曾苗","项目文件夹不存在"
|
||||
"","吴嘉杰","项目文件夹不存在"
|
||||
"","邹昱夫","项目文件夹不存在"
|
||||
"","Claudrick","项目文件夹不存在"
|
||||
"","肖瀚","项目文件夹不存在"
|
||||
"","张萌","项目文件夹不存在"
|
||||
"","王芳华","项目文件夹不存在"
|
||||
"","赵新阳","项目文件夹不存在"
|
||||
"","佘思博","项目文件夹不存在"
|
||||
"","王立杰","项目文件夹不存在"
|
||||
"","武张浩","项目文件夹不存在"
|
||||
"","江杰","项目文件夹不存在"
|
||||
"","刘卫","项目文件夹不存在"
|
||||
"","唐耀辉","项目文件夹不存在"
|
||||
"","李谦","项目文件夹不存在"
|
||||
"","李成龙","项目文件夹不存在"
|
||||
"","袁双雄","项目文件夹不存在"
|
||||
"","赵新宇","项目文件夹不存在"
|
||||
"","黄文","项目文件夹不存在"
|
||||
"","林滨","项目文件夹不存在"
|
||||
"","张铃崎","项目文件夹不存在"
|
||||
"","张皓钦","项目文件夹不存在"
|
||||
"","袁骏","项目文件夹不存在"
|
||||
"","吴俊杰","项目文件夹不存在"
|
||||
"","蒋浩","项目文件夹不存在"
|
@ -0,0 +1,4 @@
|
||||
cat post1.json | curl -H "Content-Type:application/json" -X POST -d @- http://localhost:8081/api/sonar
|
||||
|
||||
#单个代码文件检测
|
||||
cat post1.json | curl -H "Content-Type:application/json" -X POST -d @- http://localhost:8081/api/sonarSingle
|
@ -0,0 +1,13 @@
|
||||
package net.educoder.ecsonar;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
@SpringBootApplication
|
||||
public class EcsonarApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(EcsonarApplication.class, args);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
package net.educoder.ecsonar.config;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
|
||||
@Configuration
|
||||
public class ThreadPoolConfig {
|
||||
|
||||
@Bean
|
||||
public ExecutorService getThreadPool(){
|
||||
return Executors.newFixedThreadPool(10);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,44 @@
|
||||
package net.educoder.ecsonar.controller;
|
||||
|
||||
import net.educoder.ecsonar.model.api.SonarRequest;
|
||||
import net.educoder.ecsonar.services.EcsonarService;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api")
|
||||
public class MainController {
|
||||
private Logger log = LoggerFactory.getLogger(getClass());
|
||||
|
||||
@Autowired
|
||||
EcsonarService ecsonarService;
|
||||
|
||||
@RequestMapping(value = "/sonar", method = RequestMethod.POST)
|
||||
@CrossOrigin
|
||||
public String sonar(@RequestBody SonarRequest sonarRequest) throws IOException {
|
||||
log.info("sonar: {}", sonarRequest);
|
||||
ecsonarService.sonar(sonarRequest);
|
||||
return "success";
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/sonarSingle", method = RequestMethod.POST)
|
||||
@CrossOrigin
|
||||
public String sonarSingle(@RequestBody SonarRequest sonarRequest) throws IOException {
|
||||
log.info("sonarSingle: {}", sonarRequest);
|
||||
ecsonarService.sonarSingle(sonarRequest);
|
||||
return "success";
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/fit", method = RequestMethod.GET)
|
||||
public String fit(@RequestParam String fileName,
|
||||
@RequestParam String homeworkId) throws Exception {
|
||||
ecsonarService.fit(fileName, homeworkId);
|
||||
return "success";
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
package net.educoder.ecsonar.dao;
|
||||
|
||||
import net.educoder.ecsonar.model.Project;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
@Mapper
|
||||
public interface ProjectDao {
|
||||
|
||||
@Select("select * from projects where name = #{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")
|
||||
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")
|
||||
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);
|
||||
|
||||
@Select("SELECT count(*) FROM issues where project_uuid=#{uuid} and " +
|
||||
"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);
|
||||
}
|
@ -0,0 +1,190 @@
|
||||
package net.educoder.ecsonar.model;
|
||||
|
||||
public class Metrics {
|
||||
|
||||
private String complexity;
|
||||
|
||||
private int lines;
|
||||
|
||||
//漏洞
|
||||
private int block_violations;
|
||||
private int critical_violations;
|
||||
private int major_violations;
|
||||
private int minor_violations;
|
||||
private String violations;
|
||||
|
||||
|
||||
//缺陷
|
||||
private int block_bugs;
|
||||
private int critical_bugs;
|
||||
private int major_bugs;
|
||||
private int minor_bugs;
|
||||
private String bugs;
|
||||
|
||||
//代码风格
|
||||
private int block_code_smells;
|
||||
private int critical_code_smells;
|
||||
private int major_code_smells;
|
||||
private int minor_code_smells;
|
||||
private String code_smells;
|
||||
|
||||
|
||||
public String getComplexity() {
|
||||
return complexity;
|
||||
}
|
||||
|
||||
public void setComplexity(String complexity) {
|
||||
this.complexity = complexity;
|
||||
}
|
||||
|
||||
public int getLines() {
|
||||
return lines;
|
||||
}
|
||||
|
||||
public void setLines(int lines) {
|
||||
this.lines = lines;
|
||||
}
|
||||
|
||||
public int getBlock_violations() {
|
||||
return block_violations;
|
||||
}
|
||||
|
||||
public void setBlock_violations(int block_violations) {
|
||||
this.block_violations = block_violations;
|
||||
}
|
||||
|
||||
public int getCritical_violations() {
|
||||
return critical_violations;
|
||||
}
|
||||
|
||||
public void setCritical_violations(int critical_violations) {
|
||||
this.critical_violations = critical_violations;
|
||||
}
|
||||
|
||||
public int getMajor_violations() {
|
||||
return major_violations;
|
||||
}
|
||||
|
||||
public void setMajor_violations(int major_violations) {
|
||||
this.major_violations = major_violations;
|
||||
}
|
||||
|
||||
public int getMinor_violations() {
|
||||
return minor_violations;
|
||||
}
|
||||
|
||||
public void setMinor_violations(int minor_violations) {
|
||||
this.minor_violations = minor_violations;
|
||||
}
|
||||
|
||||
public String getViolations() {
|
||||
return violations;
|
||||
}
|
||||
|
||||
public void setViolations(String violations) {
|
||||
this.violations = violations;
|
||||
}
|
||||
|
||||
public int getBlock_bugs() {
|
||||
return block_bugs;
|
||||
}
|
||||
|
||||
public void setBlock_bugs(int block_bugs) {
|
||||
this.block_bugs = block_bugs;
|
||||
}
|
||||
|
||||
public int getCritical_bugs() {
|
||||
return critical_bugs;
|
||||
}
|
||||
|
||||
public void setCritical_bugs(int critical_bugs) {
|
||||
this.critical_bugs = critical_bugs;
|
||||
}
|
||||
|
||||
public int getMajor_bugs() {
|
||||
return major_bugs;
|
||||
}
|
||||
|
||||
public void setMajor_bugs(int major_bugs) {
|
||||
this.major_bugs = major_bugs;
|
||||
}
|
||||
|
||||
public int getMinor_bugs() {
|
||||
return minor_bugs;
|
||||
}
|
||||
|
||||
public void setMinor_bugs(int minor_bugs) {
|
||||
this.minor_bugs = minor_bugs;
|
||||
}
|
||||
|
||||
public String getBugs() {
|
||||
return bugs;
|
||||
}
|
||||
|
||||
public void setBugs(String bugs) {
|
||||
this.bugs = bugs;
|
||||
}
|
||||
|
||||
public int getBlock_code_smells() {
|
||||
return block_code_smells;
|
||||
}
|
||||
|
||||
public void setBlock_code_smells(int block_code_smells) {
|
||||
this.block_code_smells = block_code_smells;
|
||||
}
|
||||
|
||||
public int getCritical_code_smells() {
|
||||
return critical_code_smells;
|
||||
}
|
||||
|
||||
public void setCritical_code_smells(int critical_code_smells) {
|
||||
this.critical_code_smells = critical_code_smells;
|
||||
}
|
||||
|
||||
public int getMajor_code_smells() {
|
||||
return major_code_smells;
|
||||
}
|
||||
|
||||
public void setMajor_code_smells(int major_code_smells) {
|
||||
this.major_code_smells = major_code_smells;
|
||||
}
|
||||
|
||||
public int getMinor_code_smells() {
|
||||
return minor_code_smells;
|
||||
}
|
||||
|
||||
public void setMinor_code_smells(int minor_code_smells) {
|
||||
this.minor_code_smells = minor_code_smells;
|
||||
}
|
||||
|
||||
public String getCode_smells() {
|
||||
return code_smells;
|
||||
}
|
||||
|
||||
public void setCode_smells(String code_smells) {
|
||||
this.code_smells = code_smells;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Metrics{" +
|
||||
"complexity='" + complexity + '\'' +
|
||||
", lines=" + lines +
|
||||
", block_violations=" + block_violations +
|
||||
", critical_violations=" + critical_violations +
|
||||
", major_violations=" + major_violations +
|
||||
", minor_violations=" + minor_violations +
|
||||
", violations='" + violations + '\'' +
|
||||
", block_bugs=" + block_bugs +
|
||||
", critical_bugs=" + critical_bugs +
|
||||
", major_bugs=" + major_bugs +
|
||||
", minor_bugs=" + minor_bugs +
|
||||
", bugs='" + bugs + '\'' +
|
||||
", block_code_smells=" + block_code_smells +
|
||||
", critical_code_smells=" + critical_code_smells +
|
||||
", major_code_smells=" + major_code_smells +
|
||||
", minor_code_smells=" + minor_code_smells +
|
||||
", code_smells='" + code_smells + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
@ -0,0 +1,43 @@
|
||||
package net.educoder.ecsonar.model;
|
||||
|
||||
|
||||
public class Project {
|
||||
private int id;
|
||||
|
||||
private boolean enabled;
|
||||
|
||||
private String project_uuid;
|
||||
private String name;
|
||||
|
||||
public boolean isEnabled() {
|
||||
return enabled;
|
||||
}
|
||||
|
||||
public void setEnabled(boolean enabled) {
|
||||
this.enabled = enabled;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getProject_uuid() {
|
||||
return project_uuid;
|
||||
}
|
||||
|
||||
public void setProject_uuid(String project_uuid) {
|
||||
this.project_uuid = project_uuid;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
}
|
@ -0,0 +1,41 @@
|
||||
package net.educoder.ecsonar.model.api;
|
||||
|
||||
public class Person {
|
||||
private String uid;
|
||||
private String name;
|
||||
private String downloadUrl;
|
||||
|
||||
|
||||
public String getUid() {
|
||||
return uid;
|
||||
}
|
||||
|
||||
public void setUid(String uid) {
|
||||
this.uid = uid;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getDownloadUrl() {
|
||||
return downloadUrl;
|
||||
}
|
||||
|
||||
public void setDownloadUrl(String downloadUrl) {
|
||||
this.downloadUrl = downloadUrl;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Person{" +
|
||||
"uid='" + uid + '\'' +
|
||||
", name='" + name + '\'' +
|
||||
", downloadUrl='" + downloadUrl + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
package net.educoder.ecsonar.model.api;
|
||||
|
||||
public class ResultRequest {
|
||||
private int homeworkId;
|
||||
|
||||
public int getHomeworkId() {
|
||||
return homeworkId;
|
||||
}
|
||||
|
||||
public void setHomeworkId(int homeworkId) {
|
||||
this.homeworkId = homeworkId;
|
||||
}
|
||||
}
|
@ -0,0 +1,34 @@
|
||||
package net.educoder.ecsonar.model.api;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class SonarRequest {
|
||||
private int homeworkId;
|
||||
|
||||
private List<Person> personList;
|
||||
|
||||
public List<Person> getPersonList() {
|
||||
return personList;
|
||||
}
|
||||
|
||||
public void setPersonList(List<Person> personList) {
|
||||
this.personList = personList;
|
||||
}
|
||||
|
||||
public int getHomeworkId() {
|
||||
return homeworkId;
|
||||
}
|
||||
|
||||
public void setHomeworkId(int homeworkId) {
|
||||
this.homeworkId = homeworkId;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "SonarRequest{" +
|
||||
"homeworkId=" + homeworkId +
|
||||
", personList=" + personList +
|
||||
'}';
|
||||
}
|
||||
}
|
@ -0,0 +1,236 @@
|
||||
package net.educoder.ecsonar.services;
|
||||
|
||||
import net.educoder.ecsonar.dao.ProjectDao;
|
||||
import net.educoder.ecsonar.model.Metrics;
|
||||
import net.educoder.ecsonar.model.Project;
|
||||
import net.educoder.ecsonar.utils.ExcelUtil;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
@Service
|
||||
public class ReportService {
|
||||
|
||||
Logger log = LoggerFactory.getLogger(getClass());
|
||||
|
||||
@Autowired
|
||||
ProjectDao projectDao;
|
||||
|
||||
|
||||
/**
|
||||
* 获取分析指标数据
|
||||
*
|
||||
* @param name
|
||||
* @return
|
||||
*/
|
||||
public Metrics getMetrics(String name) {
|
||||
Project project = projectDao.findByName(name);
|
||||
if (project==null){
|
||||
return null;
|
||||
}
|
||||
String uuid = project.getProject_uuid();
|
||||
|
||||
Metrics metrics = new Metrics();
|
||||
metrics.setComplexity(getComplexity(uuid));
|
||||
metrics.setLines(getLines(uuid));
|
||||
metrics.setBlock_bugs(getBlockBugs(uuid));
|
||||
metrics.setBlock_code_smells(getBlockCodeSmells(uuid));
|
||||
metrics.setBlock_violations(getBlockViolations(uuid));
|
||||
metrics.setCritical_bugs(getCriticalBugs(uuid));
|
||||
metrics.setCritical_code_smells(getCriticalCodeSmells(uuid));
|
||||
metrics.setCritical_violations(getCriticalViolations(uuid));
|
||||
metrics.setMajor_bugs(getMajorBugs(uuid));
|
||||
metrics.setMajor_code_smells(getMajorCodeSmells(uuid));
|
||||
metrics.setMajor_violations(getMajorViolations(uuid));
|
||||
metrics.setMinor_bugs(getMinorBugs(uuid));
|
||||
metrics.setMinor_code_smells(getMinorCodeSmells(uuid));
|
||||
metrics.setMinor_violations(getMinorViolations(uuid));
|
||||
metrics.setBugs(getBugs(uuid));
|
||||
metrics.setViolations(getViolations(uuid));
|
||||
metrics.setCode_smells(getCodeSmells(uuid));
|
||||
|
||||
return metrics;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 将结果写进excel
|
||||
*
|
||||
* @param metrics
|
||||
*/
|
||||
public void writeToExcel(String stuId, String name,
|
||||
Metrics metrics, String excelPath, int index) throws IOException {
|
||||
// ExcelUtil.writeMetrics(metrics, stuId, name, excelPath, index);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取复杂度
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
private String getComplexity(String uuid) {
|
||||
Float num = projectDao.getComplexity(uuid);
|
||||
if (num == null) {
|
||||
return "0";
|
||||
}
|
||||
return "" + projectDao.getComplexity(uuid);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取总行数
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
private int getLines(String uuid) {
|
||||
Integer num = projectDao.getLines(uuid);
|
||||
if (num == null) {
|
||||
return 0;
|
||||
}
|
||||
return projectDao.getLines(uuid);
|
||||
}
|
||||
|
||||
/**
|
||||
* 漏洞-阻断
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
private int getBlockViolations(String uuid) {
|
||||
return projectDao.getIndicator(uuid, 3, "BLOCKER");
|
||||
}
|
||||
|
||||
/**
|
||||
* 漏洞-严重
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
private int getCriticalViolations(String uuid) {
|
||||
return projectDao.getIndicator(uuid, 3, "CRITICAL");
|
||||
}
|
||||
|
||||
/**
|
||||
* 漏洞-主要
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
private int getMajorViolations(String uuid) {
|
||||
return projectDao.getIndicator(uuid, 3, "MAJOR");
|
||||
}
|
||||
|
||||
/**
|
||||
* 漏洞-次要
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
private int getMinorViolations(String uuid) {
|
||||
return projectDao.getIndicator(uuid, 3, "MINOR");
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 漏洞-等级
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
private String getViolations(String uuid) {
|
||||
//93
|
||||
return projectDao.getLevel(uuid, 93);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 缺陷-阻断
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
private int getBlockBugs(String uuid) {
|
||||
return projectDao.getIndicator(uuid, 2, "BLOCKER");
|
||||
}
|
||||
|
||||
/**
|
||||
* 缺陷-严重
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
private int getCriticalBugs(String uuid) {
|
||||
return projectDao.getIndicator(uuid, 2, "CRITICAL");
|
||||
}
|
||||
|
||||
/**
|
||||
* 缺陷-主要
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
private int getMajorBugs(String uuid) {
|
||||
return projectDao.getIndicator(uuid, 2, "MAJOR");
|
||||
}
|
||||
|
||||
/**
|
||||
* 缺陷-次要
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
private int getMinorBugs(String uuid) {
|
||||
return projectDao.getIndicator(uuid, 2, "MINOR");
|
||||
}
|
||||
|
||||
/**
|
||||
* 缺陷-等级
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
private String getBugs(String uuid) {
|
||||
//89
|
||||
return projectDao.getLevel(uuid, 89);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 缺陷-阻断
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
private int getBlockCodeSmells(String uuid) {
|
||||
return projectDao.getIndicator(uuid, 1, "BLOCKER");
|
||||
}
|
||||
|
||||
/**
|
||||
* 缺陷-严重
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
private int getCriticalCodeSmells(String uuid) {
|
||||
return projectDao.getIndicator(uuid, 1, "CRITICAL");
|
||||
}
|
||||
|
||||
/**
|
||||
* 缺陷-主要
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
private int getMajorCodeSmells(String uuid) {
|
||||
return projectDao.getIndicator(uuid, 1, "MAJOR");
|
||||
}
|
||||
|
||||
/**
|
||||
* 缺陷-次要
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
private int getMinorCodeSmells(String uuid) {
|
||||
return projectDao.getIndicator(uuid, 1, "MINOR");
|
||||
}
|
||||
|
||||
/**
|
||||
* 缺陷-等级
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
private String getCodeSmells(String uuid) {
|
||||
//80
|
||||
return projectDao.getLevel(uuid, 80);
|
||||
}
|
||||
}
|
@ -0,0 +1,155 @@
|
||||
package net.educoder.ecsonar.services;
|
||||
|
||||
|
||||
import net.educoder.ecsonar.utils.SystemUtil;
|
||||
import net.educoder.ecsonar.utils.UrlUtil;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.io.*;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
|
||||
@Service
|
||||
public class SonarService {
|
||||
|
||||
private Logger log = LoggerFactory.getLogger(getClass());
|
||||
|
||||
|
||||
@Value("${sonar.url}")
|
||||
String sonarUrl;
|
||||
|
||||
@Value("${extract.path}")
|
||||
String extractProgramPath;
|
||||
|
||||
/**
|
||||
* 提交一个任务
|
||||
*
|
||||
* @param zipUrl
|
||||
*/
|
||||
public String scan(String zipSavePath, String zipUrl, int homeworkId, String uid, int index) throws Exception {
|
||||
String key = String.format("%d-%s", homeworkId, uid);
|
||||
|
||||
String[] split = StringUtils.split(zipUrl, "/");
|
||||
|
||||
String zipFilename = UrlUtil.getURLDecoderString(split[split.length - 1]);
|
||||
String savePath = zipSavePath + zipFilename;
|
||||
|
||||
//1. 下载文件
|
||||
// if (index==1) {
|
||||
// download(zipUrl, savePath);
|
||||
// }
|
||||
|
||||
//2. 解压目录
|
||||
String extractPath = zipSavePath + key;
|
||||
// if (index==1) {
|
||||
// extract(savePath, extractPath);
|
||||
// }
|
||||
|
||||
//3. 执行检测
|
||||
String subPath = "/" + SystemUtil.executeAndGetExitStatus("cd " + extractPath + " && ls | head -1").getOutput();
|
||||
// if (index != 1) {
|
||||
// subPath += "/毕业设计项目个人开发代码";
|
||||
//// subPath += "/个人";
|
||||
// } else {
|
||||
// subPath += "/毕业设计项目完整代码";
|
||||
//// subPath += "/完整";
|
||||
// }
|
||||
|
||||
log.info("scan zipSavePath: {}, zipFilename: {}, savePath: {}, extractPath: {}, subPath: {}", zipSavePath, zipFilename, savePath, extractPath, subPath);
|
||||
|
||||
if (!new File(extractPath + subPath).exists()){
|
||||
throw new Exception("项目文件夹不存在");
|
||||
}
|
||||
|
||||
|
||||
key = String.format("%s-%d", key, index);
|
||||
|
||||
sonar(extractPath + subPath, key);
|
||||
|
||||
return key;
|
||||
}
|
||||
|
||||
/**
|
||||
* 提交一个任务
|
||||
*/
|
||||
public String scanSingle(String codeSavePath, String codeUrl, int homeworkId, String uid, String key) throws Exception {
|
||||
|
||||
String[] split = StringUtils.split(codeUrl, "/");
|
||||
|
||||
String codeFilename = UrlUtil.getURLDecoderString(split[split.length - 1]);
|
||||
|
||||
String savePath = codeSavePath + codeFilename;
|
||||
if (!new File(savePath).exists()) {
|
||||
new File(savePath).mkdir();
|
||||
}
|
||||
// 代码文件后缀写死
|
||||
String saveFile = savePath + File.separator + codeFilename + ".cpp";
|
||||
|
||||
// 下载文件
|
||||
download(codeUrl, saveFile);
|
||||
|
||||
sonar(savePath, key);
|
||||
|
||||
return key;
|
||||
}
|
||||
|
||||
|
||||
private void sonar(String projectPath, String key) {
|
||||
SystemUtil.executeAndGetExitStatus("sonar-scanner " +
|
||||
"-Dsonar.host.url=" + sonarUrl + " " +
|
||||
"-Dsonar.sourceEncoding=utf-8 " +
|
||||
"-Dsonar.projectKey=" + key + " " +
|
||||
"-Dsonar.java.binaries=./ "+
|
||||
"-Dsonar.projectBaseDir=" + projectPath);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 解压zip文件
|
||||
*
|
||||
* @param zipFile
|
||||
*/
|
||||
private void extract(String zipFile, String extractPath) throws Exception {
|
||||
File extractFile = new File(extractPath);
|
||||
if (extractFile.exists()){
|
||||
extractFile.delete();
|
||||
}
|
||||
extractFile.mkdir();
|
||||
|
||||
SystemUtil.ExecuteResp executeResp = SystemUtil.executeAndGetExitStatus("cd "
|
||||
+ extractPath
|
||||
+ " && "+extractProgramPath+" -encoding GBK " + zipFile);
|
||||
}
|
||||
|
||||
/**
|
||||
* 下载文件
|
||||
*
|
||||
* @param zipUrl
|
||||
*/
|
||||
private void download(String zipUrl, String zipPath) throws IOException {
|
||||
log.info("下载文件: {}-{}", zipUrl, zipPath);
|
||||
|
||||
String cookie = "SL_GWPT_Show_Hide_tmp=1; SL_wptGlobTipTmp=1; autologin_trustie=69dd2e4d0d8c72c7c2e4333f4dd071131f903bf8; UM_distinctid=17975a9ac5591a-0bc2d36ddb4a99-113d6055-fa000-17975a9ac56663; Hm_lvt_871c0ce6df9548f77095372950e14e56=1620798873,1621317930; _educoder_session=007087d500b90f50cc574d80ddb95c3a; Hm_lpvt_871c0ce6df9548f77095372950e14e56=1621319115";
|
||||
URL url = new URL(zipUrl);
|
||||
URLConnection conn = url.openConnection();
|
||||
conn.setRequestProperty("Cookie", cookie);
|
||||
conn.setDoInput(true);
|
||||
|
||||
try (BufferedInputStream in = new BufferedInputStream(conn.getInputStream());
|
||||
FileOutputStream fileOutputStream = new FileOutputStream(zipPath)) {
|
||||
byte dataBuffer[] = new byte[1024];
|
||||
int bytesRead;
|
||||
while ((bytesRead = in.read(dataBuffer, 0, 1024)) != -1) {
|
||||
fileOutputStream.write(dataBuffer, 0, bytesRead);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
log.error("文件下载失败: {}-{}", zipUrl, zipPath);
|
||||
throw e;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,33 @@
|
||||
package net.educoder.ecsonar.utils;
|
||||
|
||||
import java.io.*;
|
||||
|
||||
public class FileUtil {
|
||||
|
||||
|
||||
public static String readFile(String fileName) {
|
||||
String encoding = "UTF-8";
|
||||
File file = new File(fileName);
|
||||
Long filelength = file.length();
|
||||
byte[] filecontent = new byte[filelength.intValue()];
|
||||
try {
|
||||
FileInputStream in = new FileInputStream(file);
|
||||
in.read(filecontent);
|
||||
in.close();
|
||||
} catch (FileNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
try {
|
||||
return new String(filecontent, encoding);
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
System.err.println("The OS does not support " + encoding);
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,76 @@
|
||||
package net.educoder.ecsonar.utils;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
|
||||
/**
|
||||
* Created by guange on 26/02/2017.
|
||||
*/
|
||||
public class SystemUtil {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(SystemUtil.class);
|
||||
|
||||
private static ExecutorService executor;
|
||||
|
||||
public static class ExecuteResp{
|
||||
int status;
|
||||
String output;
|
||||
|
||||
public int getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(int status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public String getOutput() {
|
||||
return output;
|
||||
}
|
||||
|
||||
public void setOutput(String output) {
|
||||
this.output = output;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 执行命令并获得输出以及退出码
|
||||
*/
|
||||
public static ExecuteResp executeAndGetExitStatus(String command) {
|
||||
ExecuteResp resp = new ExecuteResp();
|
||||
|
||||
logger.debug("execute: {}", command);
|
||||
|
||||
StringBuffer out = new StringBuffer();
|
||||
Integer exitStatus = -1;
|
||||
|
||||
ProcessBuilder pb = new ProcessBuilder(new String[]{"/bin/sh", "-c", command});
|
||||
pb.redirectErrorStream(true);
|
||||
try {
|
||||
Process process = pb.start();
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
|
||||
String line;
|
||||
while ((line = reader.readLine()) != null) {
|
||||
out.append(line);
|
||||
out.append(System.getProperty("line.separator"));
|
||||
}
|
||||
exitStatus = process.waitFor();
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
logger.info("executeAndGetExitStatus: {}", command);
|
||||
logger.error("executeAndGetExitStatus: ",e);
|
||||
}
|
||||
|
||||
logger.debug("out: {}", out.toString());
|
||||
resp.setOutput(out.toString().trim());
|
||||
resp.setStatus(exitStatus);
|
||||
|
||||
return resp;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,73 @@
|
||||
package net.educoder.ecsonar.utils;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
/**
|
||||
* url转码、解码
|
||||
*
|
||||
* @author lifq
|
||||
* @date 2015-3-17 下午04:09:35
|
||||
*/
|
||||
public class UrlUtil {
|
||||
private final static String ENCODE = "UTF8";
|
||||
/**
|
||||
* URL 解码
|
||||
*
|
||||
* @return String
|
||||
* @author lifq
|
||||
* @date 2015-3-17 下午04:09:51
|
||||
*/
|
||||
public static String getURLDecoderString(String str) {
|
||||
String result = "";
|
||||
if (null == str) {
|
||||
return "";
|
||||
}
|
||||
try {
|
||||
result = java.net.URLDecoder.decode(str, ENCODE);
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
/**
|
||||
* URL 转码
|
||||
*
|
||||
* @return String
|
||||
* @author lifq
|
||||
* @date 2015-3-17 下午04:10:28
|
||||
*/
|
||||
public static String getURLEncoderString(String str) {
|
||||
String result = "";
|
||||
if (null == str) {
|
||||
return "";
|
||||
}
|
||||
try {
|
||||
result = java.net.URLEncoder.encode(str, ENCODE);
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return void
|
||||
* @author lifq
|
||||
* @date 2015-3-17 下午04:09:16
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
//System.out.println(getURLDecoderString("15408100208-%E8%B0%A2%E9%91%AB-%E6%9C%AC%E7%A7%91%E6%AF%95%E4%B8%9A%E8%AE%BE%E8%AE%A1%E4%BB%A3%E7%A0%81"));
|
||||
long startTime = System.currentTimeMillis();
|
||||
long endTime = startTime + 6000;
|
||||
long index = 0;
|
||||
while(true){
|
||||
double x = Math.sqrt(index);
|
||||
long now = System.currentTimeMillis();
|
||||
if (now > endTime) {
|
||||
break;
|
||||
}
|
||||
index++;
|
||||
}
|
||||
System.out.println(index+" Loops in 6 seconds");
|
||||
}
|
||||
|
||||
}
|
Binary file not shown.
Binary file not shown.
@ -0,0 +1,37 @@
|
||||
#spring.datasource.url=jdbc:postgresql://127.0.0.1:5432/sonar
|
||||
spring.datasource.url=jdbc:postgresql://117.50.14.123:5432/sonar
|
||||
spring.datasource.username=sonar
|
||||
spring.datasource.password=sonar
|
||||
spring.datasource.driver-class-name=org.postgresql.Driver
|
||||
|
||||
|
||||
# Hikari will use the above plus the following to setup connection pooling
|
||||
spring.datasource.type=com.zaxxer.hikari.HikariDataSource
|
||||
spring.datasource.hikari.minimum-idle=5
|
||||
spring.datasource.hikari.maximum-pool-size=15
|
||||
spring.datasource.hikari.auto-commit=true
|
||||
spring.datasource.hikari.idle-timeout=30000
|
||||
spring.datasource.hikari.pool-name=DatebookHikariCP
|
||||
spring.datasource.hikari.max-lifetime=1800000
|
||||
spring.datasource.hikari.connection-timeout=30000
|
||||
spring.datasource.hikari.connection-test-query=SELECT 1
|
||||
|
||||
|
||||
logging.config=classpath:logback-spring.xml
|
||||
logging.level.root=DEBUG
|
||||
|
||||
zip.save.path=/tmp/
|
||||
#excel.template.path=/Users/guange/work/java/ecsonar/src/main/resources/template.xlsx
|
||||
excel.template.path=/Users/macbookpro/IdeaProjects/p9vymrkc8/src/main/resources/template.xlsx
|
||||
|
||||
#sonar.url=http://127.0.0.1:9000
|
||||
sonar.url=http://117.50.14.123:9000
|
||||
|
||||
extract.path=/usr/bin/unar
|
||||
|
||||
last.run.id=0
|
||||
|
||||
skip.checked=true
|
||||
|
||||
|
||||
server.port=8081
|
@ -0,0 +1,42 @@
|
||||
<?xml version="1.0"?>
|
||||
<configuration>
|
||||
|
||||
<!-- 彩色日志 -->
|
||||
<!-- 彩色日志依赖的渲染类 -->
|
||||
<conversionRule conversionWord="clr" converterClass="org.springframework.boot.logging.logback.ColorConverter" />
|
||||
<conversionRule conversionWord="wex" converterClass="org.springframework.boot.logging.logback.WhitespaceThrowableProxyConverter" />
|
||||
<conversionRule conversionWord="wEx"
|
||||
converterClass="org.springframework.boot.logging.logback.ExtendedWhitespaceThrowableProxyConverter" />
|
||||
<!-- 彩色日志格式 -->
|
||||
<property name="CONSOLE_LOG_PATTERN"
|
||||
value="${CONSOLE_LOG_PATTERN:-%clr(%d{yyyy-MM-dd HH:mm:ss.SSS}){faint} %clr(${LOG_LEVEL_PATTERN:-%5p}) %clr(${PID:- }){magenta} %clr(---){faint} %clr([%15.15t]){faint} %clr(%-40.40logger{39}){cyan} %clr(:){faint} %m%n${LOG_EXCEPTION_CONVERSION_WORD:-%wEx}}" />
|
||||
<!-- Console 输出设置 -->
|
||||
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<encoder>
|
||||
<pattern>${CONSOLE_LOG_PATTERN}</pattern>
|
||||
<charset>utf8</charset>
|
||||
</encoder>
|
||||
<filter class="ch.qos.logback.classic.filter.LevelFilter">
|
||||
<level>debug</level>
|
||||
<onMatch>ACCEPT</onMatch>
|
||||
<onMismatch>NEUTRAL</onMismatch>
|
||||
</filter>
|
||||
</appender>
|
||||
|
||||
<!--输出到文件-->
|
||||
<appender name="file" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||
<fileNamePattern>/tmp/ecsonar.%d{yyyy-MM-dd}.log</fileNamePattern>
|
||||
</rollingPolicy>
|
||||
<encoder>
|
||||
<pattern>%d{HH:mm:ss.SSS} %contextName [%thread] %-5level %logger{36} - %msg%n</pattern>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
|
||||
<root level="DEBUG">
|
||||
<appender-ref ref="CONSOLE"/>
|
||||
<appender-ref ref="file" />
|
||||
</root>
|
||||
|
||||
</configuration>
|
Binary file not shown.
@ -0,0 +1,54 @@
|
||||
package net.educoder.ecsonar;
|
||||
|
||||
import net.educoder.ecsonar.dao.ProjectDao;
|
||||
import net.educoder.ecsonar.model.Metrics;
|
||||
import net.educoder.ecsonar.model.Project;
|
||||
import net.educoder.ecsonar.services.ReportService;
|
||||
import net.educoder.ecsonar.services.SonarService;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest
|
||||
public class EcsonarApplicationTests {
|
||||
|
||||
@Autowired
|
||||
ProjectDao projectDao;
|
||||
|
||||
@Autowired
|
||||
SonarService sonarService;
|
||||
|
||||
@Autowired
|
||||
ReportService reportService;
|
||||
|
||||
@Test
|
||||
public void contextLoads() {
|
||||
Project demo_maven_webapp = projectDao.findByName("demo Maven Webapp");
|
||||
System.out.println(demo_maven_webapp.getProject_uuid());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testScan() throws Exception {
|
||||
sonarService.scan(
|
||||
"",
|
||||
"http://office.cn-gd.ufileos.com/2015962121-%E6%AF%9B%E8%83%A4%E7%81%BF-%E6%9C%AC%E7%A7%91%E6%AF%95%E4%B8%9A%E8%AE%BE%E8%AE%A1%E4%BB%A3%E7%A0%81.zip",
|
||||
1111,
|
||||
"1234",
|
||||
1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testReport() throws IOException {
|
||||
Metrics hello = reportService.getMetrics("hello");
|
||||
reportService.writeToExcel("111111111",
|
||||
"11",
|
||||
hello,
|
||||
"/tmp/11.xlsx",
|
||||
1);
|
||||
}
|
||||
}
|
Loading…
Reference in new issue