提交 868822a5 authored 作者: 马晨俊's avatar 马晨俊

mcj:新增文件名称匹配,修改kmp匹配bug

上级 54d56c08
......@@ -306,6 +306,7 @@ public class Inspector {
if (path1.toAbsolutePath().toString().endsWith("jar") || path1.toAbsolutePath().toString().endsWith("class")) {
continue;
}
valiWarn(rules, path1, path1.getFileName().toString(), 0);
//将文件的每一行都与规则匹配
List<String> strings = Files.readAllLines(path1);
for (int i = 0; i < strings.size(); i++) {
......@@ -446,15 +447,13 @@ public class Inspector {
rule.setTechnologyId(techJavaSupport.getId());
rule.setTarget(dependency.getGroupId());
rule.setTechnologyName(techJavaSupport.getTechnologyName());
//?
rule.setSuffix("*");
rule.setId(UUIDUtil.getUUID());
Rule rule1 = new Rule();
rule1.setTechnologyId(techJavaSupport.getId());
rule1.setTarget(dependency.getArtifactId());
rule.setTechnologyName(techJavaSupport.getTechnologyName());
//?
rule1.setTechnologyName(techJavaSupport.getTechnologyName());
rule1.setSuffix("*");
rule1.setId(UUIDUtil.getUUID());
......@@ -495,7 +494,7 @@ public class Inspector {
//匹配字符串
int index = KmpUtil.kmpMatch(data, rule.getTarget());
//当index>0时代表data中有当前规则
if (index > 0) {
if (index > -1) {
//判断当前规则是否是不支持规则
Warn warn = new Warn();
//如果是不支持规则则需要保存匹配信息
......@@ -529,4 +528,9 @@ public class Inspector {
return i;
}
}
public static void main(String[] args) {
int vue = KmpUtil.kmpMatch("vue.js", "vue");
System.out.println(vue);
}
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论