Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Modify default parameter rule in SonarQube

Tags:

c#

sonarqube

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?

like image 998
Tarta Avatar asked Sep 09 '26 01:09

Tarta


2 Answers

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.

like image 137
Eedoh Avatar answered Sep 11 '26 14:09

Eedoh


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>

like image 40
Ajith Avatar answered Sep 11 '26 14:09

Ajith



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!