我安装了SonarQube,我们正在尝试在包含以下代码类型的产品上运行它
现在我们已经运行它来扫描除T / SQL代码之外的所有代码。
此TSQL代码与所有其他代码位于同一目录下,但没有特定的Visual Studio项目。
我们能够在SQL上运行扫描的唯一方法是使用标准的sonarqube
运行器,但这会导致在我们的仪表板上创建新产品。
任何想法或建议。
目前,如果您希望分析TSQL文件并在与其他代码相同的SonarQube项目下显示,则需要从MSBuild项目引用它。
有几种方法可以做到这一点:
1)使用如下所示的代码段将TSQL文件包含在您现有的一个项目中:
<ItemGroup>
<!-- Include additional files that should be analyzed by the SonarScanner for MSBuild -->
<None Include="*.tsql" >
<!-- Don't show the items in the Solution Explorer -->
<Visible>False</Visible>
</None>
</ItemGroup>
2)创建一个单独的虚拟MSBuild项目,其唯一目的是指定要分析的其他文件。这稍微复杂一些,因为虚拟项目需要一些额外的内容才能使它与SonarScanner for MSBuild目标一起使用。以下模板适用于扫描仪的v4.3,也适用于最近的早期版本。
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<!-- The only purpose of this project is to specify additional files to be analyzed by the SonarScanner for MSBuild -->
<!-- 1. Set a unique GUID id for the project -->
<PropertyGroup>
<ProjectGuid>{EA2BAA27-D799-4FBE-9430-7499ACF3E431}</ProjectGuid>
</PropertyGroup>
<!-- 2. Specify the files to be analysed -->
<ItemGroup>
<SonarQubeAnalysisFiles Include="**\*.js" />
</ItemGroup>
<!-- ******************************************************** -->
<!-- Boilerplate - no need to change anything below this line -->
<!-- ******************************************************** -->
<!-- Import the SQ targets (will only exist if the scanner "begin" step has been executed) -->
<PropertyGroup>
<SQImportBeforeTargets>$(localappdata)\Microsoft\MSBuild\$(MSBuildToolsVersion)\Microsoft.Common.targets\ImportBefore\SonarQube.Integration.ImportBefore.targets</SQImportBeforeTargets>
</PropertyGroup>
<Import Condition="Exists('$(SQImportBeforeTargets)')" Project="$(SQImportBeforeTargets)" />
<!-- Re-define the standard step of targets used in builds -->
<Target Name="Build" />
<Target Name="Clean" />
<Target Name="CoreCompile" />
<Target Name="Rebuild" DependsOnTargets="Clean;Build" />
<!-- Re-define one of the standard SQ targets as we have already set the list of files to analyze above -->
<Target Name="CalculateSonarQubeFilesToAnalyze" >
<PropertyGroup>
<!-- Set a property indicating whether there are any files to analyze -->
<AnalysisFilesExist Condition=" @(SonarQubeAnalysisFiles) != '' ">true</AnalysisFilesExist>
</PropertyGroup>
</Target>
</Project>