Other

项目介绍

SonarSource/sonar-dotnet 是一个托管在 GitHub 上的开源项目,主要使用 C# 编写,采用 Other 许可证,目前获得 923 个 Star、244 次 Fork。

仓库全名
SonarSource/sonar-dotnet
开源许可证
Other
Star 数
923
Fork 数
244
未关闭 Issue
261

README 摘要

Product|Quality Gate|Coverage| :--:|:--:|:--:| SonarQube analyzers for .NET SonarQube analyzers for .NET inspect C# and VB.NET code for bugs, vulnerabilities, and maintainability issues. They surface findings while developers work in their IDE and when teams analyze projects with SonarQube Server or SonarQube Cloud. This repository contains the source for the Roslyn analyzers and the Java plugin that integrates .NET…

完整内容见 GitHub 原始 README 或本页 。

常见问题

sonar-dotnet 用什么语言开发?

主要使用 C# 编写,采用 Other 许可证,目前有 923 个 Star。

sonar-dotnet 可以免费商用吗?

仓库标注的许可证为 Other,商用前请先阅读仓库 LICENSE 文件确认授权范围。

如何获取 sonar-dotnet 的源码?

可以直接克隆仓库:git clone https://github.com/SonarSource/sonar-dotnet.git,默认分支为 master;安装与运行步骤见仓库 README。

sonar-dotnet 最近还在维护吗?

仓库最近一次更新为 18 小时前,当前有 261 个未关闭 Issue;Star 数为 923,可作为社区活跃度的参考。

关于

GitHub 原始描述(英文)

Code analyzer for C# and VB.NET projects

描述取自 GitHub 官方 API,保持仓库作者书写的原文。

简要分析

热度分
1461
价值分
618
活跃状态
活跃

语言占比

Batchfile
C#
HTML
Java
PowerShell
PureBasic
Shell
Smalltalk
Visual Basic .NET

Release

README

Sonar logo

Build Status

Product Quality Gate Coverage
Analyzer Quality Gate Coverage
Plugin Quality Gate Coverage

NuGet GitHub stars License Community forum

SonarQube analyzers for .NET

SonarQube analyzers for .NET inspect C# and VB.NET code for bugs, vulnerabilities, and maintainability issues. They surface findings while developers work in their IDE and when teams analyze projects with SonarQube Server or SonarQube Cloud.

This repository contains the source for the Roslyn analyzers and the Java plugin that integrates .NET analysis with SonarQube. The analyzers apply the same rules to developer-written and AI-generated code, giving teams a consistent way to verify code before it reaches production.

Learn more about SonarQube analysis for C#.

Features

  • 490+ C# rules and 210+ VB.​NET rules
  • Metrics (cognitive complexity, duplications, number of lines, etc.)
  • Import of test coverage reports from Visual Studio Code Coverage, dotCover, OpenCover, Coverlet, Altcover.
  • Import of third-party Roslyn Analyzers results
  • Support for custom rules

The analyzers work with SonarQube Server, SonarQube Cloud, and SonarQube for IDE.

Useful public resources

Nuget.org packages

Integration with SonarQube

Do you have a question or feedback?

Get started

How to contribute

There are many ways you can contribute to the sonar-dotnet project. When contributing, please respect our Code of Conduct.

Join the discussions

One of the easiest ways to contribute is to share your feedback with us (see give feedback) and also answer questions from our community forum. You can also monitor the activity on this repository (opened issues, opened PRs) to get more acquainted with what we do.

Pull Request (PR)

If you want to fix an issue, please read the Get started pages first and make sure that you follow our coding style. We suggest avoiding the implementation of new rules, as a specification process is required first.

Before submitting the PR, make sure all tests are passing (all checks must be green).

If you did not sign the Contributor License Agreement in the past, please let us know in the PR your user handle from our Community Forum. We will arrange the signing via private message.

Note: Our CI does not get automatically triggered on the PRs from external contributors. A member of our team will review the code and trigger the CI on demand by adding a comment on the PR (see Azure Pipelines Comment triggers docs):

  • /azp run Sonar.Net - It will run the full pipeline, including plugin tests and promotion

Custom Rules

To request new rules, Contact us on our Community Forum.

If you have an idea for a rule but you are not sure that everyone needs it, you can implement your own Roslyn analyzer.

Configuring Rules

SonarQube for IDE

The easiest way is to configure a Quality Profile in SonarQube. Use SonarQube for IDE Connected Mode to connect to SonarQube Server or Cloud.

Standalone NuGet

The rules from standalone NuGet packages can be enabled or disabled in the same way as the other analyzers based on Roslyn, by using the .globalconfig or .editorconfig files. See: https://learn.microsoft.com/en-us/visualstudio/code-quality/use-roslyn-analyzers?view=vs-2022#set-rule-severity-in-an-editorconfig-file

If the rules are parameterized, the parameter values can be changed using SonarLint.xml additional files.

The first step is to create a new file, named SonarLint.xml, that has the following structure:

<?xml version="1.0" encoding="utf-8"?>
<AnalysisInput xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <Settings>
    <Setting>
      <Key>sonar.cs.analyzeGeneratedCode</Key>
      <Value>false</Value>
    </Setting>
  </Settings>
  <Rules>
    <Rule>
      <Key>S107</Key>
      <Parameters>
        <Parameter>
          <Key>max</Key>
          <Value>2</Value>
        </Parameter>
      </Parameters>
    </Rule>
  </Rules>
</AnalysisInput>

Then, update the projects to include this additional file:

<ItemGroup>
  <AdditionalFiles Include="SonarLint.xml" />
</ItemGroup>

Security Issues

If you believe you have discovered a security vulnerability in Sonar’s products, please check this document.

License

Copyright SonarSource Sàrl.

Licensed under the SONAR Source-Available License v1.0

评论

暂无评论