Modify default parameter rule in SonarQube

一世执手 提交于 2020-04-14 04:09:38

问题


I am using sonarqube to check the quality of my code and I would like to override a rule but I don't manage to do it even by following the documentation. The rule I want to modify is about the exceeding code length in C# which by default uses the maximumLineLength parameter. I would like to modify and increase the value of this parameter but I don't find anywhere the chance to do it. Any help please?


回答1:


Try setting the attribute in your sonar-project.properties file. That way the default value will stay intact, but it will be set to your desired value per-project...

sonar.maximumLineLength = 300 (or whatever value you need)

Let us know if it worked.




回答2:


Add the following Rule in SonarLint.xml

<?xml version="1.0" encoding="UTF-8"?>
<AnalysisInput>
  <Settings>
  </Settings>
  <Rules>
    <Rule>
      <Key>S103</Key>
      <Parameters>
        <Parameter>
          <Key>maximumLineLength</Key>
          <Value>240</Value>
        </Parameter>
      </Parameters>
    </Rule>
  </Rules>
  <Files>
  </Files>
</AnalysisInput>

and Modify the .csproj file to add the following.

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



来源:https://stackoverflow.com/questions/45479939/modify-default-parameter-rule-in-sonarqube

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!