Skip to content

Commit d1d1235

Browse files
committed
SONARMSBRU-151 Custom FxCop rules aren't supported with all .NET Framework versions
1 parent bb7bb94 commit d1d1235

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

SonarQube.TeamBuild.PreProcessor/SonarWebService.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,9 @@ public IDictionary<string, string> GetInternalKeys(string repository)
9595
var contents = Downloader.Download(ws);
9696

9797
var rules = JObject.Parse(contents);
98-
var keysToIds = rules["rules"].ToDictionary(r => r["key"].ToString(), r => r["internalKey"] != null ? r["internalKey"].ToString() : null);
98+
var keysToIds = rules["rules"]
99+
.Where(r => r["internalKey"] != null)
100+
.ToDictionary(r => r["key"].ToString(), r => r["internalKey"].ToString());
99101

100102
return keysToIds;
101103
}

Tests/SonarQube.TeamBuild.PreProcessor.Tests/SonarWebServiceTest.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,6 @@ public void GetInternalKeys()
123123
{
124124
downloader.Pages["http://myhost:222/api/rules/search?f=internalKey&ps=" + int.MaxValue + "&repositories=fxcop"] = "{\"total\":2,\"p\":1,\"ps\":10,\"rules\":[{\"key\":\"fxcop:My_Own_FxCop_Rule\"},{\"key\":\"fxcop:UriParametersShouldNotBeStrings\",\"internalKey\":\"CA1054\"}]}";
125125
var expected = new Dictionary<string, string>();
126-
expected["fxcop:My_Own_FxCop_Rule"] = null;
127126
expected["fxcop:UriParametersShouldNotBeStrings"] = "CA1054";
128127
var actual = ws.GetInternalKeys("fxcop");
129128

@@ -174,7 +173,6 @@ public void ServerUrlWithTrailingSlash()
174173

175174
downloader.Pages["http://myhost:222/api/rules/search?f=internalKey&ps=" + int.MaxValue + "&repositories=fxcop"] = "{\"total\":2,\"p\":1,\"ps\":10,\"rules\":[{\"key\":\"fxcop:My_Own_FxCop_Rule\"},{\"key\":\"fxcop:UriParametersShouldNotBeStrings\",\"internalKey\":\"CA1054\"}]}";
176175
var expected2 = new Dictionary<string, string>();
177-
expected2["fxcop:My_Own_FxCop_Rule"] = null;
178176
expected2["fxcop:UriParametersShouldNotBeStrings"] = "CA1054";
179177
var actual2 = ws.GetInternalKeys("fxcop");
180178

0 commit comments

Comments
 (0)