ruleset with parameter

270 views
Skip to first unread message

Imre Lengyel

unread,
May 3, 2016, 12:24:37 PM5/3/16
to SonarLint
How to specify a parameter in the analyzer's ruleset file?

I want to change the max parameter for S107 to 5 (7 is the default)
<RuleSet Name="Rules for SonarLint" Description="This rule set was automatically generated from SonarQube." ToolsVersion="14.0">
  <Rules AnalyzerId="SonarAnalyzer.CSharp" RuleNamespace="SonarAnalyzer.CSharp">
    ...
    <Rule Id="S107" Action="Warning" />

I also tried to change the setting in the profile and exporting the ruleset, but always the default settings seems to be exported. This appears to be a bug, where any customisations on the profile does not appear in the ruleset export.
I do not see any customisations of the ruleset distributed in connected mode of sonarlint either.

Dinesh Bolkensteyn

unread,
May 3, 2016, 12:34:28 PM5/3/16
to Imre Lengyel, SonarLint
You cannot currently set the value of rule parameters in SonarLint - and indeed, the connected mode also doesn't help with that.

There is an open ticket to add this feature to the connected mode:

Note that, in any case, rule parameters will not be stored in the .ruleset file, because its schema doesn't allow it.

--
You received this message because you are subscribed to the Google Groups "SonarLint" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sonarlint+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/sonarlint/4724d7fd-67de-4260-a3df-5c1841ed5f82%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Imre Lengyel

unread,
May 3, 2016, 1:17:26 PM5/3/16
to SonarLint, ilen...@gmail.com
Thanks for the info Dinesh,

I noticed that the GitHub version of ParameterLoader is looking for the SonarLint.xml file (looks like will be in 1.12 version of the analyzer). If this is the case, which folder would I need to put the SonarLint.xml file? Or should the file be added to the project in the same way as Stylecop settings file discribed in: https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/Configuration.md

I also assume the SonarLint.xml scema would be similar to the SonarQube backup file for the quality profile.. so in my case I would add:
    <Rule><Key>S107</Key>
      <Parameters>
        <Parameter><Key>max</Key><Value>5</Value></Parameter>
      </Parameters>
    </Rule>

Regards

Dinesh Bolkensteyn

unread,
May 4, 2016, 2:23:21 AM5/4/16
to Imre Lengyel, SonarLint
Changing rule parameters in SonarLint for Visual Studio is not supported for the moment :)

The SonarLint.xml file you're referring to is an implementation detail that might change from one version to the next.
So even if you do manage to get something to work, be careful, as there is no guarantee that it won't break some time soon.

--
You received this message because you are subscribed to the Google Groups "SonarLint" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sonarlint+...@googlegroups.com.

Imre Lengyel

unread,
May 4, 2016, 3:19:19 AM5/4/16
to SonarLint, ilen...@gmail.com
Yep, sure, the good thing is that we don't have a lot of customisations, so as long as we can store the settings in a single location on our source repository (say next to the ruleset file), it should be easy to adapt. Currently we add the ruleset files as links.. these links and default analysers are set-up using project templates.

Jonathan Marchand

unread,
May 4, 2016, 3:48:15 AM5/4/16
to sona...@googlegroups.com

Hello,

I have the same problem with the Eclipse plugin. Is there an equivalent to SVS-5 for that plugin that I could track?

Regards.

Duarte Meneses

unread,
May 4, 2016, 5:29:46 AM5/4/16
to Jonathan Marchand, SonarLint
Hi Jonathan,

Parameters in rules are supported in Eclipse.

--
You received this message because you are subscribed to the Google Groups "SonarLint" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sonarlint+...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Duarte MENESES | SonarSource
Reply all
Reply to author
Forward
0 new messages