I am trying to customize some rules, particularly S134 but it does not take my deviation from the default max parameter into account
Repro: Create new Console App in Visual Studio, Add SonarAnalyzer.CSharp NuGet package
Add file SonarLint.xml, set Build Action to Additional Analyzer file
<?xml version="1.0" encoding="utf-8"?>
<AnalysisInput>
<Settings>
</Settings>
<Rules>
<Rule>
<Key>S134</Key>
<Parameters>
<Parameter>
<Key>max</Key>
<Value>4</Value>
</Parameter>
</Parameters>
</Rule>
</Rules>
</AnalysisInput>
Code:
internal class Program
{
protected Program(){}
static Random rnd = new Random();
static void Main(string[] args)
{
if (Random())
{
if (!Random())
{
if (Random())
{
if (!Random())
{
Console.WriteLine("Wow you're lucky");
}
}
}
}
}
static bool Random()
{
return rnd.Next(2) == 0;
}
}
Add .editorconfig
[*.cs]
dotnet_diagnostic.S134.severity = error
Result is that it still uses the default parameter of 3