0

I'm seeing a strange error when using Sonar to analyse a C-sharp code base.

14:59:19.350 INFO - SonarLint for Visual Studio version 1.3.0.0 14:59:20.154 ERROR - 14:59:20.337 ERROR - Unhandled Exception: System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary. 14:59:20.338 ERROR - at System.Collections.Immutable.ImmutableDictionary`2.get_Item(TKey key) 14:59:20.340 ERROR - at SonarLint.Runner.Configuration.AddAnalyzerCommentRegularExpression(Builder builder) 14:59:20.341 ERROR - at SonarLint.Runner.Configuration.Analyzers() 14:59:20.341 ERROR - at SonarLint.Runner.Program.Main(String[] args)

Can anyone help me identify what key the exeception is refering to?

user3617723
  • 1,355
  • 3
  • 17
  • 37
  • Is it an option to upgrade the C# plugin? There were 6 new releases since SonarLint 1.3 version. – Tamas Mar 15 '16 at 14:24
  • It seems that an entry is missing from the configuration file that drives the analysis. There should be a SonarLint.xml file in your .sonarqube/conf folder. Could you check the part that belongs to this template rule (comment regular expression, S124)? – Tamas Mar 15 '16 at 14:36
  • @Tamas-SonarSourceTeam See my update, did you mean that SonarLint.xml should be on the Sonar server or on the machine performing the analysis? – user3617723 Mar 16 '16 at 09:00

1 Answers1

0

The Sonar server I'm using is shared among many teams so updating the plugin maybe be problematic.

I'm not able to find a file called SonarLint.xml, I have found reference to S124 in a file called analysis-input.xml in .sonar/ in the directory of the project I'm analyzing.

<Rule>
  <Key>S124</Key>
  <Parameters>
    <Parameter>
      <Key>RuleKey</Key>
      <Value>ToDo</Value>
    </Parameter>
  </Parameters>
</Rule>
user3617723
  • 1,355
  • 3
  • 17
  • 37
  • Thanks. It seems to me that this XML misses a few additional parameters, so I'm tempted to say that there was a bug in the file generator. If you can't update the plugin, then I would say that you'll need to disable this rule in the quality profile in order to not get into the XML. (BTW, in newer versions of the C# plugin we dropped support for this template rule, and implemented separate rules for "TODO" and "FIXME" comments) – Tamas Mar 16 '16 at 09:18
  • Great thanks @Tamas-SonarSourceTeam disabling that rule has fixed the crash. – user3617723 Mar 16 '16 at 12:10