Skip to content

Commit 8b88e4a

Browse files

16 files changed

+40
-407
lines changed

src/ConnectedMode.UnitTests/Binding/CSharpVBBindingConfigProviderTests.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,16 +42,16 @@ public class CSharpVBBindingConfigProviderTests
4242
private SonarQubeQualityProfile validQualityProfile;
4343

4444
private static readonly SonarQubeRule ActiveRuleWithUnsupportedSeverity = new SonarQubeRule("activeHotspot", "any1",
45-
true, SonarQubeIssueSeverity.Blocker, null, null, null, SonarQubeIssueType.SecurityHotspot, null, null, null, null, null, null);
45+
true, SonarQubeIssueSeverity.Blocker, null, null, null, SonarQubeIssueType.SecurityHotspot);
4646

4747
private static readonly SonarQubeRule InactiveRuleWithUnsupportedSeverity = new SonarQubeRule("inactiveHotspot", "any2",
48-
false, SonarQubeIssueSeverity.Blocker, null, null, null, SonarQubeIssueType.SecurityHotspot, null, null, null, null, null, null);
48+
false, SonarQubeIssueSeverity.Blocker, null, null, null, SonarQubeIssueType.SecurityHotspot);
4949

5050
private static readonly SonarQubeRule ActiveTaintAnalysisRule = new SonarQubeRule("activeTaint", "roslyn.sonaranalyzer.security.foo",
51-
true, SonarQubeIssueSeverity.Blocker, null, null,null, SonarQubeIssueType.CodeSmell, null, null, null, null, null, null);
51+
true, SonarQubeIssueSeverity.Blocker, null, null,null, SonarQubeIssueType.CodeSmell);
5252

5353
private static readonly SonarQubeRule InactiveTaintAnalysisRule = new SonarQubeRule("inactiveTaint", "roslyn.sonaranalyzer.security.bar",
54-
false, SonarQubeIssueSeverity.Blocker, null, null, null, SonarQubeIssueType.CodeSmell, null, null, null, null, null, null);
54+
false, SonarQubeIssueSeverity.Blocker, null, null, null, SonarQubeIssueType.CodeSmell);
5555

5656
[TestInitialize]
5757
public void TestInitialize()
@@ -60,7 +60,7 @@ public void TestInitialize()
6060

6161
validRules = new List<SonarQubeRule>
6262
{
63-
new SonarQubeRule("key", "repoKey", true, SonarQubeIssueSeverity.Blocker, null, null, null, SonarQubeIssueType.Bug, null, null, null, null, null, null)
63+
new SonarQubeRule("key", "repoKey", true, SonarQubeIssueSeverity.Blocker, null, null, null, SonarQubeIssueType.Bug)
6464
};
6565

6666
anyProperties = Array.Empty<SonarQubeProperty>();
@@ -261,13 +261,13 @@ public void IsSupportedRule_TaintRules(string repositoryKey, bool expected)
261261
[DataRow(SonarQubeIssueType.Vulnerability, true)]
262262
public void IsSupportedRule_Severity(SonarQubeIssueType issueType, bool expected)
263263
{
264-
var rule = new SonarQubeRule("any", "any", true, SonarQubeIssueSeverity.Blocker, null, null, null, issueType, null, null, null, null, null, null);
264+
var rule = new SonarQubeRule("any", "any", true, SonarQubeIssueSeverity.Blocker, null, null, null, issueType);
265265

266266
CSharpVBBindingConfigProvider.IsSupportedRule(rule).Should().Be(expected);
267267
}
268268

269269
private static SonarQubeRule CreateRule(string ruleKey, string repoKey, bool isActive) =>
270-
new SonarQubeRule(ruleKey, repoKey, isActive, SonarQubeIssueSeverity.Blocker, null, null, null, SonarQubeIssueType.CodeSmell, null, null, null, null, null, null);
270+
new SonarQubeRule(ruleKey, repoKey, isActive, SonarQubeIssueSeverity.Blocker, null, null, null, SonarQubeIssueType.CodeSmell);
271271

272272
private class TestEnvironmentBuilder
273273
{

src/ConnectedMode.UnitTests/Binding/GlobalConfigGeneratorTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ public void GetVSSeverity_Invalid_Throws(SonarQubeIssueSeverity sqSeverity)
133133
}
134134

135135
private static SonarQubeRule CreateRule(string ruleKey, string repoKey, bool isActive = true) =>
136-
new SonarQubeRule(ruleKey, repoKey, isActive, SonarQubeIssueSeverity.Info, null, null, new Dictionary<string, string>(), SonarQubeIssueType.Unknown, null, null, null, null, null, null);
136+
new SonarQubeRule(ruleKey, repoKey, isActive, SonarQubeIssueSeverity.Info, null, null, new Dictionary<string, string>(), SonarQubeIssueType.Unknown);
137137

138138
private string GetRuleString(string expectedKey, string expectedSeverity) =>
139139
$"dotnet_diagnostic.{expectedKey}.severity = {expectedSeverity}";

src/Core.UnitTests/CSharpVB/RoslynPluginRuleKeyExtensionsTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public class RoslynPluginRuleKeyExtensionsTests
3838
[DataRow("vbnet", "sonaranalyzer-vbnet")] // special case for SonarVBNet
3939
public void TryGetPrefix(string ruleKey, string expectedPrefix)
4040
{
41-
var rule = new SonarQubeRule("any", ruleKey, false, SonarQubeIssueSeverity.Unknown, null, null, null, SonarQubeIssueType.Unknown, null, null, null, null, null, null);
41+
var rule = new SonarQubeRule("any", ruleKey, false, SonarQubeIssueSeverity.Unknown, null, null, null, SonarQubeIssueType.Unknown);
4242

4343
rule.TryGetRoslynPluginPropertyPrefix().Should().Be(expectedPrefix);
4444
}

src/Core.UnitTests/CSharpVB/SonarLintConfigGeneratorTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -374,8 +374,8 @@ public void Generate_Serialized_ReturnsExpectedXml()
374374
private static SonarQubeRule CreateRuleWithValidParams(string ruleKey, string repoKey) =>
375375
CreateRule(ruleKey, repoKey, ValidParams);
376376

377-
private static SonarQubeRule CreateRule(string ruleKey, string repoKey, IDictionary<string, string> parameters = null, string description = null, IReadOnlyList<SonarQubeDescriptionSection> descriptionSections = null, IReadOnlyList<string> educationPrinciples = null, string name = null, IReadOnlyList<string> tags = null, string htmlNote = null) =>
378-
new SonarQubeRule(ruleKey, repoKey, isActive: false, SonarQubeIssueSeverity.Blocker, null, null, parameters, SonarQubeIssueType.Unknown, description, descriptionSections, educationPrinciples, name, tags, htmlNote);
377+
private static SonarQubeRule CreateRule(string ruleKey, string repoKey, IDictionary<string, string> parameters = null) =>
378+
new SonarQubeRule(ruleKey, repoKey, isActive: false, SonarQubeIssueSeverity.Blocker, null, null, parameters, SonarQubeIssueType.Unknown);
379379

380380
private Language ToLanguage(string sqLanguageKey) => Language.GetLanguageFromLanguageKey(sqLanguageKey);
381381
}

src/Education/XamlGenerator/RichRuleHelpXamlBuilder.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,11 @@ internal interface IRichRuleHelpXamlBuilder
3131
/// <summary>
3232
/// Generates a XAML document containing the help information for the specified rule
3333
/// </summary>
34-
/// <remarks>Assumes that the <see cref="IRuleInfo.Description"/> and <see cref="IRuleInfo.DescriptionSections"/> are parseable as XML.
34+
/// <remarks>Assumes that the <see cref="IRuleInfo.Description"/> and <see cref="IRuleInfo.RichRuleDescriptionDto"/> contents are parseable as XML.
3535
/// Also assumes that the containing control defines a list of Style resources, one for each
3636
/// value in the enum <see cref="StyleResourceNames"/>.
3737
/// The document will still render if a style is missing, but the styling won't be correct.</remarks>
3838
/// <param name="ruleInfo">Rule description information</param>
39-
/// <param name="issueContext">Key for the How to fix it Context acquired from a specific issue</param>
4039
FlowDocument Create(IRuleInfo ruleInfo);
4140
}
4241

src/SonarQube.Client.Tests/Requests/DefaultConfiguration_Configure_Tests.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,6 @@ public void ConfigureSonarQube_Writes_Debug_Messages()
6262
"Registered SonarQube.Client.Api.V8_6.GetHotspotRequest for 8.6",
6363
"Registered SonarQube.Client.Api.V7_20.GetExclusionsRequest for 7.2",
6464
"Registered SonarQube.Client.Api.V9_4.GetSonarLintEventStream for 9.4",
65-
"Registered SonarQube.Client.Api.V9_5.GetRulesWithDescriptionSectionsRequest for 9.5",
66-
"Registered SonarQube.Client.Api.V9_6.GetRulesWithEducationPrinciplesRequest for 9.6",
6765
"Registered SonarQube.Client.Api.V9_7.SearchHotspotRequest for 9.7",
6866
"Registered SonarQube.Client.Api.V10_2.SearchHotspotRequest for 10.2",
6967
"Registered SonarQube.Client.Api.V10_2.GetRulesWithCCTRequest for 10.2",

src/SonarQube.Client.Tests/SonarQubeService_ExtensionMethods.cs

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public async Task GetAllRulesAsync_FetchesActiveAndInactive()
3636
await ConnectToSonarQube();
3737

3838
// One active rule
39-
SetupRequest("api/rules/search?activation=true&qprofile=quality-profile-1&f=repo%2CinternalKey%2Cparams%2Cactives%2ChtmlDesc%2Ctags%2Cname%2ChtmlNote&p=1&ps=500", @"
39+
SetupRequest("api/rules/search?activation=true&qprofile=quality-profile-1&f=repo%2CinternalKey%2Cparams%2Cactives&p=1&ps=500", @"
4040
{
4141
""total"": 1,
4242
""p"": 1,
@@ -48,13 +48,11 @@ public async Task GetAllRulesAsync_FetchesActiveAndInactive()
4848
""params"": [
4949
{
5050
""key"": ""format"",
51-
""htmlDesc"": ""Regular expression used to check the enumeration type names against."",
5251
""defaultValue"": ""^([A-Z]{1,3}[a-z0-9]+)*([A-Z]{2})?$"",
5352
""type"": ""STRING""
5453
},
5554
{
5655
""key"": ""flagsAttributeFormat"",
57-
""htmlDesc"": ""Regular expression used to check the flags enumeration type names against."",
5856
""defaultValue"": ""^([A-Z]{1,3}[a-z0-9]+)*([A-Z]{2})?s$"",
5957
""type"": ""STRING""
6058
}
@@ -94,7 +92,7 @@ public async Task GetAllRulesAsync_FetchesActiveAndInactive()
9492
");
9593

9694
// One inactive rule
97-
SetupRequest("api/rules/search?activation=false&qprofile=quality-profile-1&f=repo%2CinternalKey%2Cparams%2Cactives%2ChtmlDesc%2Ctags%2Cname%2ChtmlNote&p=1&ps=500", @"
95+
SetupRequest("api/rules/search?activation=false&qprofile=quality-profile-1&f=repo%2CinternalKey%2Cparams%2Cactives&p=1&ps=500", @"
9896
{
9997
""total"": 1,
10098
""p"": 1,
@@ -135,10 +133,10 @@ public async Task GetAllRulesAsync_OnlyActiveRulesExist_AreFetched()
135133

136134
// One active rule, no inactive rules
137135
var ruleJson = SingleValidRuleJson("repo1", "rule1");
138-
SetupRequest("api/rules/search?activation=true&qprofile=quality-profile-1&f=repo%2CinternalKey%2Cparams%2Cactives%2ChtmlDesc%2Ctags%2Cname%2ChtmlNote&p=1&ps=500",
136+
SetupRequest("api/rules/search?activation=true&qprofile=quality-profile-1&f=repo%2CinternalKey%2Cparams%2Cactives&p=1&ps=500",
139137
ruleJson);
140138

141-
SetupRequest("api/rules/search?activation=false&qprofile=quality-profile-1&f=repo%2CinternalKey%2Cparams%2Cactives%2ChtmlDesc%2Ctags%2Cname%2ChtmlNote&p=1&ps=500",
139+
SetupRequest("api/rules/search?activation=false&qprofile=quality-profile-1&f=repo%2CinternalKey%2Cparams%2Cactives&p=1&ps=500",
142140
NoRulesJson);
143141

144142
var result = await service.GetAllRulesAsync("quality-profile-1", CancellationToken.None);
@@ -157,10 +155,10 @@ public async Task GetAllRulesAsync_OnlyInactiveRulesExist_AreFetched()
157155

158156
// One active rule, no inactive rules
159157
var ruleJson = SingleValidRuleJson("repo1", "rule1");
160-
SetupRequest("api/rules/search?activation=true&qprofile=quality-profile-1&f=repo%2CinternalKey%2Cparams%2Cactives%2ChtmlDesc%2Ctags%2Cname%2ChtmlNote&p=1&ps=500",
158+
SetupRequest("api/rules/search?activation=true&qprofile=quality-profile-1&f=repo%2CinternalKey%2Cparams%2Cactives&p=1&ps=500",
161159
NoRulesJson);
162160

163-
SetupRequest("api/rules/search?activation=false&qprofile=quality-profile-1&f=repo%2CinternalKey%2Cparams%2Cactives%2ChtmlDesc%2Ctags%2Cname%2ChtmlNote&p=1&ps=500",
161+
SetupRequest("api/rules/search?activation=false&qprofile=quality-profile-1&f=repo%2CinternalKey%2Cparams%2Cactives&p=1&ps=500",
164162
ruleJson);
165163

166164
var result = await service.GetAllRulesAsync("quality-profile-1", CancellationToken.None);
@@ -180,10 +178,10 @@ public async Task GetAllRulesAsync_GetInactiveFails_ExceptionIsPropogated()
180178

181179
// One active rule, no inactive rules
182180
var ruleJson = SingleValidRuleJson("repo1", "rule1");
183-
SetupRequest("api/rules/search?activation=true&qprofile=quality-profile-1&f=repo%2CinternalKey%2Cparams%2Cactives%2ChtmlDesc%2Ctags%2Cname%2ChtmlNote&p=1&ps=500",
181+
SetupRequest("api/rules/search?activation=true&qprofile=quality-profile-1&f=repo%2CinternalKey%2Cparams%2Cactives&p=1&ps=500",
184182
ruleJson);
185183

186-
SetupRequestWithOperation("api/rules/search?activation=false&qprofile=quality-profile-1&f=repo%2CinternalKey%2Cparams%2Cactives%2ChtmlDesc%2Ctags%2Cname%2ChtmlNote&p=1&ps=500",
184+
SetupRequestWithOperation("api/rules/search?activation=false&qprofile=quality-profile-1&f=repo%2CinternalKey%2Cparams%2Cactives&p=1&ps=500",
187185
() => { throw new InvalidOperationException("xxx"); });
188186

189187
// Act

src/SonarQube.Client.Tests/SonarQubeService_GetRuleByKeyAsync.cs

Lines changed: 5 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public async Task GetRuleByKeyAsync_RuleIsFound_ReturnsRule()
3737
await ConnectToSonarQube("10.2.0.0");
3838

3939
SetupRequest(
40-
"api/rules/search?qprofile=qpKey&rule_key=csharpsquid%3AS2342&f=repo%2CinternalKey%2Cparams%2Cactives%2ChtmlDesc%2Ctags%2Cname%2ChtmlNote%2CdescriptionSections%2CeducationPrinciples%2CcleanCodeAttribute&p=1&ps=500",
40+
"api/rules/search?qprofile=qpKey&rule_key=csharpsquid%3AS2342&f=repo%2CinternalKey%2Cparams%2Cactives%2CcleanCodeAttribute&p=1&ps=500",
4141
@"
4242
{
4343
""total"": 1,
@@ -47,52 +47,28 @@ public async Task GetRuleByKeyAsync_RuleIsFound_ReturnsRule()
4747
{
4848
""key"": ""csharpsquid:S2342"",
4949
""repo"": ""csharpsquid"",
50-
""htmlDesc"": ""Html Description"",
51-
""htmlNote"": ""HTML Note"",
52-
""name"": ""RuleName"",
53-
""tags"": [""tag1"",""tag2""],
5450
""params"": [
5551
{
5652
""key"": ""format"",
57-
""htmlDesc"": ""Regular expression used to check the enumeration type names against."",
5853
""defaultValue"": ""^([A-Z]{1,3}[a-z0-9]+)*([A-Z]{2})?$"",
5954
""type"": ""STRING""
6055
},
6156
{
6257
""key"": ""flagsAttributeFormat"",
63-
""htmlDesc"": ""Regular expression used to check the flags enumeration type names against."",
6458
""defaultValue"": ""^([A-Z]{1,3}[a-z0-9]+)*([A-Z]{2})?s$"",
6559
""type"": ""STRING""
6660
}
6761
],
6862
""type"": ""CODE_SMELL"",
6963
""cleanCodeAttributeCategory"": ""INTENTIONAL"",
70-
""cleanCodeAttribute"": ""CLEAR"",
64+
""cleanCodeAttribute"": ""CLEAR"",
7165
""impacts"": [
7266
{
7367
""softwareQuality"": ""RELIABILITY"",
7468
""severity"": ""MEDIUM""
7569
}
76-
],
77-
""descriptionSections"" : [
78-
{
79-
""key"": ""key1"",
80-
""content"": ""content1""
81-
},
82-
{
83-
""key"": ""key2"",
84-
""content"": ""content2"",
85-
""context"":{
86-
""displayName"":""displayName"",
87-
""key"":""key""
88-
}
89-
}
90-
],
91-
""educationPrinciples"": [
92-
""education principle 1"",
93-
""education principle 2""
94-
]
95-
},
70+
]
71+
}
9672
],
9773
""actives"": {
9874
""csharpsquid:S2225"": [
@@ -153,34 +129,19 @@ public async Task GetRuleByKeyAsync_RuleIsFound_ReturnsRule()
153129

154130
result.Key.Should().Be("S2342");
155131
result.RepositoryKey.Should().Be("csharpsquid");
156-
result.Description.Should().Be("Html Description");
157-
result.HtmlNote.Should().Be("HTML Note");
158132
result.Severity.Should().Be(SonarQubeIssueSeverity.Minor);
159-
result.Name.Should().Be("RuleName");
160-
result.Tags.Should().BeEquivalentTo(new[] { "tag1", "tag2" });
161133
result.CleanCodeAttribute.Should().Be(SonarQubeCleanCodeAttribute.Clear);
162134
result.SoftwareQualitySeverities.Should().BeEquivalentTo(
163135
new Dictionary<SonarQubeSoftwareQuality, SonarQubeSoftwareQualitySeverity>
164136
{ { SonarQubeSoftwareQuality.Reliability, SonarQubeSoftwareQualitySeverity.Medium } });
165-
166-
result.DescriptionSections.Count.Should().Be(2);
167-
result.DescriptionSections[0].Key.Should().Be("key1");
168-
result.DescriptionSections[0].HtmlContent.Should().Be("content1");
169-
result.DescriptionSections[0].Context.Should().BeNull();
170-
171-
result.DescriptionSections[1].Key.Should().Be("key2");
172-
result.DescriptionSections[1].HtmlContent.Should().Be("content2");
173-
result.DescriptionSections[1].Context.Should().NotBeNull();
174-
result.DescriptionSections[1].Context.Key.Should().Be("key");
175-
result.DescriptionSections[1].Context.DisplayName.Should().Be("displayName");
176137
}
177138

178139
[TestMethod]
179140
public async Task GetRuleByKeyAsync_RuleIsNotFound_ReturnsNull()
180141
{
181142
await ConnectToSonarQube();
182143

183-
SetupRequest("api/rules/search?qprofile=qpKey&rule_key=csharpsquid%3AS2342XX&f=repo%2CinternalKey%2Cparams%2Cactives%2ChtmlDesc%2Ctags%2Cname%2ChtmlNote&p=1&ps=500", @"{
144+
SetupRequest("api/rules/search?qprofile=qpKey&rule_key=csharpsquid%3AS2342XX&f=repo%2CinternalKey%2Cparams%2Cactives&p=1&ps=500", @"{
184145
""total"": 0,
185146
""p"": 1,
186147
""ps"": 100,

0 commit comments

Comments
 (0)