gpt4 book ai didi

java - SonarQube 5.6 是否执行使用 sonar-plugin-api 版本 4.5.2 开发的插件中的装饰器?

转载 作者:行者123 更新时间:2023-11-30 07:02:29 27 4
gpt4 key购买 nike

我安装了sonarqube 5.6,并下载了C#插件。

我决定扩展 C# 插件,因此我继续下载已安装插件的代码(版本 5.3.2)。

C#插件项目引用了sonar-plugin-api版本4.5.2

我添加了需要针对项目级别进行计算的新指标,因此,按照文档,我创建了一个 Decorator .

public class CSharpMyDecorator implements Decorator{
private static final Logger LOG = LoggerFactory.getLogger(CSharpMyDecorator.class);

@Override
public boolean shouldExecuteOnProject(Project arg0) {
// TODO Auto-generated method stub
return true;
}

@Override
public void decorate(Resource resource, DecoratorContext context) {

LOG.info(resource.getName() + " Is Project: " + Scopes.isProject(resource) +" Is project not Module:" + Qualifiers.isProject(resource, false));


if (Scopes.isProject(resource) && Qualifiers.isProject(resource, false)) {
double files = 0d;
double percentage = 0d;
LOG.info("files: "+context.getMeasure(CoreMetrics.FILES).getValue());

for (Measure measure : context.getChildrenMeasures(MyMetrics.FILES_DONT_PASS_FUNCTION_THRESHOLD)) {
files += measure.getValue();
}

percentage = files / context.getMeasure(CoreMetrics.FILES).getValue();
context.saveMeasure(MyMetrics.PERC_FILES_DONT_PASS_FUNCTION_THRESHOLD, percentage);
}

}

}

我在插件中添加类:

public class CSharpPlugin extends SonarPlugin {

public static final String LANGUAGE_KEY = "cs";
public static final String LANGUAGE_NAME = "C#";

public static final String FILE_SUFFIXES_KEY = "sonar.cs.file.suffixes";
public static final String FILE_SUFFIXES_DEFVALUE = ".cs";

public static final String CSHARP_WAY_PROFILE = "Sonar way";

public static final String REPOSITORY_KEY = "csharpsquid";
public static final String REPOSITORY_NAME = "SonarQube";

public static final String IGNORE_HEADER_COMMENTS = "sonar.cs.ignoreHeaderComments";
public static final String NUMBER_FUNCTION_THRESHOLD = "sonar.cs.numberFunctionThreshold";
public static final String NUMBER_LOC_THRESHOLD = "sonar.cs.numberLocThreshold";

@Override
public List getExtensions() {
ImmutableList.Builder builder = ImmutableList.builder();

builder.add(
CSharp.class,
CSharpSonarRulesDefinition.class,
CSharpSonarWayProfile.class,
CSharpCommonRulesEngine.class,
CSharpCommonRulesDecorator.class,
CSharpSourceCodeColorizer.class,
RuleRunnerExtractor.class,
CSharpSensor.class,
CSharpCPDMapping.class,
SonarLintProfileExporter.class,
SonarLintFakeProfileImporter.class,
RoslynProfileExporter.class,
MyMetrics.class,
CSharpMyDecorator.class
);

builder.addAll(CSharpFxCopProvider.extensions());
builder.addAll(CSharpCodeCoverageProvider.extensions());
builder.addAll(CSharpUnitTestResultsProvider.extensions());
builder.addAll(CSharpMsBuildIntegrationProvider.extensions());
builder.addAll(RoslynProfileExporter.sonarLintRepositoryProperties());

return builder.build();
}

}

当我执行分析时,既不会创建指标,也不会存储度量。

查看生成的日志(我启用了详细选项),我没有发现任何对装饰器执行的引用。甚至装饰器中的代码也没有预期的 LOG 条目。

我正在使用 MSBuild.SonarQube.Runner.exe 版本 2.0

为什么不调用装饰器?是 SonarQube 版本的问题吗?

最佳答案

扩展点装饰器在 5.2 版本中被删除,因为它不是为 5.x 系列最需要的功能之一而设计的:将扫描仪与数据库隔离。

更多详情请访问 http://docs.sonarqube.org/display/DEV/API+Changes并在群里https://groups.google.com/forum/#!forum/sonarqube

关于java - SonarQube 5.6 是否执行使用 sonar-plugin-api 版本 4.5.2 开发的插件中的装饰器?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40663669/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com