提交 5a4236c7 authored 作者: 马晨俊's avatar 马晨俊

mcj:新增重构后不需要检查后端依赖逻辑

上级 64e4019f
......@@ -26,4 +26,11 @@ public interface RuleDao extends JpaRepository<Rule,String>,JpaSpecificationExec
List<Rule> findAllByTargetLike(String target);
Rule findByTarget(String target);
/**
* 根据技术id查询规则
* @param ids 技术id
* @return
*/
List<Rule> findAllByTechnologyIdIn(List<String> ids);
}
......@@ -40,4 +40,11 @@ public interface TechnologyDao extends JpaRepository<Technology,String>, JpaSpec
* @return
*/
int countAllBySupportIsNot(Integer support);
/**
* 查询前端或者后端依赖技术
* @param backOrFront
* @return
*/
List<Technology> findAllByBackorfrontEquals(String backOrFront);
}
......@@ -50,7 +50,8 @@ public class Technology {
* 1:前端技术
* 2:后端技术
*/
private Integer backOrFront=2;
@Column(name = "back_or_front")
private Integer backorfront =2;
/**
* 数据创建时间
*/
......
......@@ -57,7 +57,7 @@ public class Inspector {
* key:mysql-connect : *
* mysql-connect:*
* mysql-connect:.java
*
* <p>
* value:随意
*/
private HashMap<String, Rule> ruleMap = new HashMap<>();
......@@ -132,18 +132,15 @@ public class Inspector {
* @return 报告
*/
public ReportVo inspect() {
ruleSuffixFileMap=new HashMap<>();
ruleSuffixFileMap = new HashMap<>();
ruleSuffixMap = new HashMap<>();
warns.clear();
rules.clear();
//查询技术,构造支持与非支持技术对象
findExistTechnology();
//统计项目组成文件构成
statisticsLanguage();
this.ruleList=ruleDao.findAll();
//统计项目组成文件构成
//统计配置文件地址
statisticsConfigFile();
//查询所有规则
ruleTransform();
try {
//以下为计算文件名称匹配正则表达式
FileSystem aDefault = FileSystems.getDefault();
......@@ -179,7 +176,7 @@ public class Inspector {
//通过正则表达式匹配.java类型后缀文件,并+1
if (entry.getValue().matches(file)) {
long length = file.toFile().length();
codeSize+=length/1024;
codeSize += length / 1024;
languageMatchMap.get(entry.getKey()).plus();
}
}
......@@ -228,7 +225,7 @@ public class Inspector {
pomDependency.setSupport(1);
} else {
//为普通用户上传,依赖需要检查是否支持。
int i = valiWarn(ruleList, file,patten, 0);
int i = valiWarn(ruleList, file, patten, 0);
//如果值为0则代表是有不支持技术到匹配
pomDependency.setSupport(i);
}
......@@ -263,6 +260,11 @@ public class Inspector {
public ReportVo analysis() {
DependencyVo dependencyVo = new DependencyVo();
setReportLanguageAndFrame();
//查询技术,构造支持与非支持技术对象
findExistTechnology();
//查询所有规则
ruleTransform(report.getRecastMethod());
//解析配置文件集合
for (Map.Entry<String, List<Path>> entry : configFileTypePathsMapping.entrySet()) {
switch (entry.getKey()) {
......@@ -367,7 +369,7 @@ public class Inspector {
if (entry.getValue().getNumber() > maxnum) {
most = suffixLanguageMapping.get(entry.getKey()).name();
Language language = Language.valueOf(most);
mostStatus=language.getStatus();
mostStatus = language.getStatus();
maxnum = entry.getValue().getNumber();
}
}
......@@ -386,8 +388,14 @@ public class Inspector {
/**
* rule所需要数据装配
*/
private void ruleTransform() {
this.ruleList = ruleDao.findAll();
private void ruleTransform(int i) {
if(i==1){
List<Technology> front = technologyDao.findAllByBackorfrontEquals("1");
List<String> ids = front.stream().map(Technology::getId).collect(Collectors.toList());
this.ruleList=ruleDao.findAllByTechnologyIdIn(ids);
}else{
this.ruleList=ruleDao.findAll();
}
Set<String> id = ruleList.stream().map(Rule::getTechnologyId).collect(Collectors.toSet());
List<Technology> technologies = technologyDao.findAllByIdIn(new ArrayList<>(id));
for (Technology technology : technologies) {
......@@ -401,10 +409,10 @@ public class Inspector {
}
//根据后缀名进行规则收集
for (Rule rule : ruleList) {
if(!ruleSuffixMap.containsKey(rule.getSuffix())){
if (!ruleSuffixMap.containsKey(rule.getSuffix())) {
ruleSuffixMap.put(rule.getSuffix(), new ArrayList<>());
ruleSuffixMap.get(rule.getSuffix()).add(rule);
}else{
} else {
ruleSuffixMap.get(rule.getSuffix()).add(rule);
}
}
......@@ -522,7 +530,7 @@ public class Inspector {
} else if (technologyHashMap.get(rule.getTechnologyId()).getSupport() == 3) {
warns.add(warn);
supportStatus = 3;
}else if (technologyHashMap.get(rule.getTechnologyId()).getSupport() == 1) {
} else if (technologyHashMap.get(rule.getTechnologyId()).getSupport() == 1) {
warns.add(warn);
supportStatus = 1;
}
......
......@@ -35,6 +35,7 @@ public class BudgetUitl {
// TODO: 2020-03-05 查询年复利率,查询修改,适配和重构占比
inspectParameter.setMoneyRate(1.04);
//代码重构比
double refactorProportion = 0D;
//代码修改比
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论