如何设置stylecop.json为Sonarqube创建Stylecop Anayzers插件? [英] How to set stylecop.json creating Stylecop Anayzers plugin for Sonarqube?

查看:318
本文介绍了如何设置stylecop.json为Sonarqube创建Stylecop Anayzers插件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在SonarQube中使用Roslyn的StyleCop分析器的规则,为此,并遵循建立的文档,我下载了SonarQube Roslyn SDK,并生成了插件.

I want to use the rules of the StyleCop analyzer for Roslyn in SonarQube, In order to do that and following the documentation founded, I downloaded the SonarQube Roslyn SDK, and I generate the plugin.

在我的开发环境中,我有一个添加配置的JSON文件(stylecop.json):

In my development environment I have a JSON file (stylecop.json) that add configuration:

{
  "$schema": "https://raw.githubusercontent.com/DotNetAnalyzers/StyleCopAnalyzers/master/StyleCop.Analyzers/StyleCop.Analyzers/Settings/stylecop.schema.json",
  "settings": {
    "documentationRules": {
      "companyName": "XXXXXX",
      "copyrightText": " My Copyright (c) ",
      "xmlHeader": true,
      "fileNamingConvention": "metadata"
    },
    "namingRules": {
      "allowedHungarianPrefixes": ["as", "do", "id", "if", "in", "is", "my", "no", "on", "to", "ui"]
    }
  }
}

此配置与VS2015完美配合,但是当我运行分析时,插件无法获取它,我知道在创建插件时不会设置该文件.我可以重新创建插件,但是如何为插件创建过程设置该JSON文件?

This configuration works perfectly with VS2015, but when I run the analysis, the plugin does not get it, I am aware that I do not setup that file when I create the plugin. I am able to recreate the plugin, but how do I setup that JSON file for the plugin creation process?

推荐答案

Roslyn分析器可以从文件中加载参数.该API不太严格,这意味着您可以轻松编写需要一个文件,多个文件或可以提供的任何参数加载的分析器.我们尚未在SonarQube Roslyn API中对此进行概括,因此无法定义其他文件.

Roslyn analyzers can load parameters from files. This API is not too strict, meaning you can easily write an analyzer that requires a single file, multiple files, or whatever parameter loading that you can come up with. We haven't yet generalized this in the SonarQube Roslyn API, so there's no way to define additional files.

但是,您可以将项目设置为使用stylecop.json,就像在没有SonarQube的情况下一样.然后,用于MsBuild的SonarQube扫描仪将从SonarQube服务器中拉出分析器DLL,在构建过程中将其添加到您的项目中,并且使用最新版本时,它不会清除AdditionalFiles属性,因此您的stylecop.json将传递给分析仪.

However, you can set up your projects to use your stylecop.json the same way as you'd do without SonarQube being in the picture. Then the SonarQube Scanner for MsBuild will pull down the analyzer DLLs from the SonarQube server, add them to your project during build, and with the latest version it will not clear the AdditionalFiles property, so your stylecop.json will be passed to the analyzers.

这篇关于如何设置stylecop.json为Sonarqube创建Stylecop Anayzers插件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆