新增:log文件识别

wuhaoyang
RenFengJiang 10 months ago
parent 753fbddae6
commit 6fb1fd3963
  1. 3
      sonar-keyware-plugins-cxx/src/main/java/com/keyware/sonar/cxx/CxxPlugin.java
  2. 4
      sonar-keyware-plugins-cxx/src/main/java/com/keyware/sonar/cxx/CxxSquidSensor.java
  3. 37
      sonar-keyware-plugins-cxx/src/main/java/com/keyware/sonar/cxx/LogLanguage.java

@ -98,6 +98,8 @@ public final class CxxPlugin implements Plugin {
static private List<Object> getSensorsImpl() {
var l = new ArrayList<Object>();
l.add(LogLanguage.class);
// utility classes
l.add(CxxUnitTestResultsAggregator.class);
l.add(RulesDefinitionXmlLoader.class);
@ -152,6 +154,7 @@ public final class CxxPlugin implements Plugin {
l.add(CxxClangTidyRuleRepository.class);
l.add(CxxClangSARuleRepository.class);
// post jobs
l.add(FinalReport.class);

@ -286,7 +286,7 @@ public class CxxSquidSensor implements ProjectSensor {
public void describe(SensorDescriptor descriptor) {
descriptor
.name("CXX")
.onlyOnLanguage(CxxLanguage.KEY)
.onlyOnLanguages(CxxLanguage.KEY, LogLanguage.KEY)
.onlyOnFileType(InputFile.Type.MAIN)
.onlyWhenConfiguration(conf -> !conf.getBoolean(SQUID_DISABLED_KEY).orElse(false));
}
@ -373,7 +373,7 @@ public class CxxSquidSensor implements ProjectSensor {
private Iterable<InputFile> getInputFiles(SensorContext context, CxxSquidConfiguration squidConfig) {
Iterable<InputFile> inputFiles = context.fileSystem().inputFiles(
context.fileSystem().predicates().and(
context.fileSystem().predicates().hasLanguage(CxxLanguage.KEY),
context.fileSystem().predicates().hasLanguages(CxxLanguage.KEY, LogLanguage.KEY),
context.fileSystem().predicates().hasType(InputFile.Type.MAIN)
)
);

@ -0,0 +1,37 @@
/*
* Copyright (c) 2023 - 2024. KeyWare.Co.Ltd All rights reserved.
* 项目名称信息安全性设计准则检查插件
* 项目描述用于检查源代码的安全性设计准则的Sonarqube插件
* 版权说明本软件属北京关键科技股份有限公司所有在未获得北京关键科技股份有限公司正式授权情况下任何企业和个人不能获取阅读安装传播本软件涉及的任何受知识产权保护的内容
*/
package com.keyware.sonar.cxx;
import org.sonar.api.resources.AbstractLanguage;
import java.lang.module.Configuration;
/**
* TODO LogLanguage
*
* @author RenFengJiang
* @date 2024/1/16
*/
public final class LogLanguage extends AbstractLanguage {
public static final String NAME = "LOG";
public static final String KEY = "log";
private final Configuration config;
public LogLanguage( Configuration config) {
super(KEY, NAME);
this.config = config;
}
@Override
public String[] getFileSuffixes() {
String[] arr = new String[1];
arr[0] = ".log";
return arr;
}
}
Loading…
Cancel
Save