Skip to content

Commit

Permalink
Update CFamily analyzer to v6.4
Browse files Browse the repository at this point in the history
Fixes #2958
  • Loading branch information
duncanp-sonar committed May 31, 2022
1 parent 739ad87 commit acc4bb2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/EmbeddedSonarAnalyzer.props
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<!-- Note: don't forget to upload the new packages to the package feed when changing
the SonarAnalyzer version -->
<EmbeddedSonarAnalyzerVersion>8.38.0.46746</EmbeddedSonarAnalyzerVersion>
<EmbeddedSonarCFamilyAnalyzerVersion>6.31.0.44497</EmbeddedSonarCFamilyAnalyzerVersion>
<EmbeddedSonarCFamilyAnalyzerVersion>6.34.0.48468</EmbeddedSonarCFamilyAnalyzerVersion>
<EmbeddedSonarJSAnalyzerVersion>8.6.0.16913</EmbeddedSonarJSAnalyzerVersion>
<EmbeddedSonarSecretsAnalyzerVersion>1.0.2</EmbeddedSonarSecretsAnalyzerVersion>
</PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,20 @@ public class CFamilyEmbeddedSonarWayRulesTests
// Note: how to find the expected number of active/inactive rules in SonarWay by language:
// 1. Start a local SQ instance with the correct plugin version installed
// 2. Browse to "Rules" e.g. http://localhost:9000/
// or:
// SonarCloud: C: https://sonarcloud.io/organizations/sonarsource/quality_profiles/show?name=Sonar+way&language=c
// SonarCloud: C++: https://sonarcloud.io/organizations/sonarsource/quality_profiles/show?name=Sonar+way&language=cpp
// 3. Filter by Repository = SonarAnalyzer C
// 4. Filter by Quality Profile = Sonar way C
// The QP filter has "active/inactive" tabs. The number of rules is shown in the top-right of the screen.
// 5. Repeat for C++.

// Rule data for C-Family plugin v6.31 (build 44497)
private const int Active_C_Rules = 205;
// Rule data for C-Family plugin v6.34 (build 48468)
private const int Active_C_Rules = 206;
private const int Inactive_C_Rules = 104;

private const int Active_CPP_Rules = 405;
private const int Inactive_CPP_Rules = 169;
private const int Active_CPP_Rules = 407;
private const int Inactive_CPP_Rules = 168;

private readonly CFamilySonarWayRulesConfigProvider rulesMetadataCache = new CFamilySonarWayRulesConfigProvider(CFamilyShared.CFamilyFilesDirectory);

Expand All @@ -73,15 +76,15 @@ public void Read_Active_Rules()
[TestMethod]
public void Read_Rules_Params()
{
rulesMetadataCache.GetRulesConfiguration("cpp").RulesParameters.TryGetValue("ClassComplexity", out var parameters);
rulesMetadataCache.GetRulesConfiguration("cpp").RulesParameters.TryGetValue("S1311", out var parameters);
parameters.Should()
.Contain(new System.Collections.Generic.KeyValuePair<string, string>("maximumClassComplexityThreshold", "80"));
}

[TestMethod]
public void Read_Rules_Metadata()
{
rulesMetadataCache.GetRulesConfiguration("cpp").RulesMetadata.TryGetValue("ClassComplexity", out var metadata);
rulesMetadataCache.GetRulesConfiguration("cpp").RulesMetadata.TryGetValue("S1311", out var metadata);
using (new AssertionScope())
{
metadata.Type.Should().Be(IssueType.CodeSmell);
Expand Down

0 comments on commit acc4bb2

Please sign in to comment.