diff --git a/analyzers/tests/SonarAnalyzer.UnitTest/Helpers/ParameterLoaderTest.cs b/analyzers/tests/SonarAnalyzer.UnitTest/Helpers/ParameterLoaderTest.cs index bcf46ee97b6..5ed1026cd73 100644 --- a/analyzers/tests/SonarAnalyzer.UnitTest/Helpers/ParameterLoaderTest.cs +++ b/analyzers/tests/SonarAnalyzer.UnitTest/Helpers/ParameterLoaderTest.cs @@ -37,7 +37,7 @@ public class ParameterLoaderTest public void SetParameterValues_WhenNoSonarLintIsGiven_DoesNotPopulateParameters(string filePath) { // Arrange - var compilation = CreateCompilationWithOption(filePath, SourceText.From(File.ReadAllText("ResourceTests\\SonarLint.xml"))); + var compilation = CreateCompilationWithOption(filePath, SourceText.From(File.ReadAllText("ResourceTests\\SonarLintXml\\All_properties_cs\\SonarLint.xml"))); var analyzer = new ExpressionComplexity(); // Cannot use mock because we use reflection to find properties. // Act @@ -53,7 +53,7 @@ public void SetParameterValues_WhenNoSonarLintIsGiven_DoesNotPopulateParameters( public void SetParameterValues_WhenGivenValidSonarLintFilePath_PopulatesProperties(string filePath) { // Arrange - var compilation = CreateCompilationWithOption(filePath, SourceText.From(File.ReadAllText("ResourceTests\\SonarLint.xml"))); + var compilation = CreateCompilationWithOption(filePath, SourceText.From(File.ReadAllText("ResourceTests\\SonarLintXml\\All_properties_cs\\SonarLint.xml"))); var analyzer = new ExpressionComplexity(); // Cannot use mock because we use reflection to find properties. // Act @@ -67,7 +67,7 @@ public void SetParameterValues_WhenGivenValidSonarLintFilePath_PopulatesProperti public void SetParameterValues_WhenGivenSonarLintFileHasIntParameterType_PopulatesProperties() { // Arrange - var compilation = CreateCompilationWithOption("ResourceTests\\SonarLint.xml"); + var compilation = CreateCompilationWithOption("ResourceTests\\SonarLintXml\\All_properties_cs\\SonarLint.xml"); var analyzer = new ExpressionComplexity(); // Cannot use mock because we use reflection to find properties. // Act @@ -81,7 +81,7 @@ public void SetParameterValues_WhenGivenSonarLintFileHasIntParameterType_Populat public void SetParameterValues_WhenGivenSonarLintFileHasStringParameterType_OnlyOneParameter_PopulatesProperty() { // Arrange - var compilation = CreateCompilationWithOption("ResourceTests\\RuleWithStringParameter\\SonarLint.xml"); + var compilation = CreateCompilationWithOption("ResourceTests\\SonarLintXml\\RuleWithStringParameter\\SonarLint.xml"); var analyzer = new EnumNameShouldFollowRegex(); // Cannot use mock because we use reflection to find properties. // Act @@ -95,7 +95,7 @@ public void SetParameterValues_WhenGivenSonarLintFileHasStringParameterType_Only public void SetParameterValues_WhenGivenSonarLintFileHasBooleanParameterType_OnlyOneParameter_PopulatesProperty() { // Arrange - var compilation = CreateCompilationWithOption("ResourceTests\\RuleWithBooleanParameter\\SonarLint.xml"); + var compilation = CreateCompilationWithOption("ResourceTests\\SonarLintXml\\RuleWithBooleanParameter\\SonarLint.xml"); var analyzer = new CheckFileLicense(); // Cannot use mock because we use reflection to find properties. // Act @@ -109,7 +109,7 @@ public void SetParameterValues_WhenGivenSonarLintFileHasBooleanParameterType_Onl public void SetParameterValues_WhenGivenValidSonarLintFileAndDoesNotContainAnalyzerParameters_DoesNotPopulateProperties() { // Arrange - var compilation = CreateCompilationWithOption("ResourceTests\\SonarLint.xml"); + var compilation = CreateCompilationWithOption("ResourceTests\\SonarLintXml\\All_properties_cs\\SonarLint.xml"); var analyzer = new LineLength(); // Cannot use mock because we use reflection to find properties. // Act @@ -180,7 +180,7 @@ public void SetParameterValues_WithMalformedXml_DoesNotPopulateProperties(string public void SetParameterValues_WithWrongPropertyType_StringInsteadOfInt_DoesNotPopulateProperties() { // Arrange - var compilation = CreateCompilationWithOption("ResourceTests\\StringInsteadOfInt\\SonarLint.xml"); + var compilation = CreateCompilationWithOption("ResourceTests\\SonarLintXml\\StringInsteadOfInt\\SonarLint.xml"); var analyzer = new ExpressionComplexity(); // Cannot use mock because we use reflection to find properties. // Act @@ -194,7 +194,7 @@ public void SetParameterValues_WithWrongPropertyType_StringInsteadOfInt_DoesNotP public void SetParameterValues_WithWrongPropertyType_StringInsteadOfBoolean_DoesNotPopulateProperties() { // Arrange - var compilation = CreateCompilationWithOption("ResourceTests\\StringInsteadOfBoolean\\SonarLint.xml"); + var compilation = CreateCompilationWithOption("ResourceTests\\SonarLintXml\\StringInsteadOfBoolean\\SonarLint.xml"); var analyzer = new CheckFileLicense(); // Cannot use mock because we use reflection to find properties. // Act diff --git a/analyzers/tests/SonarAnalyzer.UnitTest/Helpers/SonarLintXmlReaderTest.cs b/analyzers/tests/SonarAnalyzer.UnitTest/Helpers/SonarLintXmlReaderTest.cs index 737148185f8..009508344c2 100644 --- a/analyzers/tests/SonarAnalyzer.UnitTest/Helpers/SonarLintXmlReaderTest.cs +++ b/analyzers/tests/SonarAnalyzer.UnitTest/Helpers/SonarLintXmlReaderTest.cs @@ -41,7 +41,7 @@ public void SonarLintXmlReader_WhenAllValuesAreSet_ExpectedValues(string languag AssertArrayContent(sut.TestInclusions, nameof(sut.TestInclusions)); AssertArrayContent(sut.GlobalTestExclusions, nameof(sut.GlobalTestExclusions)); - sut.ParametrizedRules.Should().HaveCount(8); + sut.ParametrizedRules.Should().HaveCount(2); var rule = sut.ParametrizedRules.First(x => x.Key.Equals("S2342")); rule.Parameters[0].Key.Should().Be("format"); rule.Parameters[0].Value.Should().Be("^([A-Z]{1,3}[a-z0-9]+)*([A-Z]{2})?$"); diff --git a/analyzers/tests/SonarAnalyzer.UnitTest/Helpers/SonarLintXmlTest.cs b/analyzers/tests/SonarAnalyzer.UnitTest/Helpers/SonarLintXmlTest.cs index b27c8f4b38d..47c834dbe53 100644 --- a/analyzers/tests/SonarAnalyzer.UnitTest/Helpers/SonarLintXmlTest.cs +++ b/analyzers/tests/SonarAnalyzer.UnitTest/Helpers/SonarLintXmlTest.cs @@ -30,7 +30,7 @@ public class SonarLintXmlTest public void SonarLintXml_DeserializeFile_ExpectedValues() { var deserializer = new XmlSerializer(typeof(SonarLintXml)); - using TextReader textReader = new StreamReader("ResourceTests\\SonarLintXml\\All_properties_small_template\\SonarLint.xml"); + using TextReader textReader = new StreamReader("ResourceTests\\SonarLintXml\\All_properties_cs\\SonarLint.xml"); var sonarLintXml = (SonarLintXml)deserializer.Deserialize(textReader); AssertSettings(sonarLintXml.Settings); @@ -58,20 +58,20 @@ private static void AssertRules(List rules) rules.Should().HaveCount(4); rules.Where(x => x.Parameters.Any()).Should().HaveCount(2); - rules[0].Key.Should().BeEquivalentTo("S0001"); + rules[0].Key.Should().BeEquivalentTo("S2225"); rules[0].Parameters.Should().BeEmpty(); - rules[1].Key.Should().BeEquivalentTo("S0002"); - rules[1].Parameters.Should().BeEmpty(); - rules[2].Key.Should().BeEquivalentTo("S0003"); - rules[2].Parameters.Should().HaveCount(2); - AssertKeyValuePair(rules[2].Parameters[0], "format", "^([A-Z]{1,3}[a-z0-9]+)*([A-Z]{2})?$"); - AssertKeyValuePair(rules[2].Parameters[1], "flagsAttributeFormat", "^([A-Z]{1,3}[a-z0-9]+)*([A-Z]{2})?s$"); + rules[1].Key.Should().BeEquivalentTo("S2342"); + rules[1].Parameters.Should().HaveCount(2); + AssertKeyValuePair(rules[1].Parameters[0], "format", "^([A-Z]{1,3}[a-z0-9]+)*([A-Z]{2})?$"); + AssertKeyValuePair(rules[1].Parameters[1], "flagsAttributeFormat", "^([A-Z]{1,3}[a-z0-9]+)*([A-Z]{2})?s$"); - rules[3].Key.Should().BeEquivalentTo("S0004"); - rules[3].Parameters.Should().HaveCount(2); - AssertKeyValuePair(rules[3].Parameters[0], "threshold", "15"); - AssertKeyValuePair(rules[3].Parameters[1], "propertyThreshold", "3"); + rules[2].Key.Should().BeEquivalentTo("S2346"); + rules[2].Parameters.Should().BeEmpty(); + + rules[3].Key.Should().BeEquivalentTo("S1067"); + rules[3].Parameters.Should().HaveCount(1); + AssertKeyValuePair(rules[3].Parameters[0], "max", "1"); } private static void AssertKeyValuePair(SonarLintXmlKeyValuePair pair, string expectedKey, string expectedValue) diff --git a/analyzers/tests/SonarAnalyzer.UnitTest/ResourceTests/AnalyzeGeneratedFalse/SonarLint.xml b/analyzers/tests/SonarAnalyzer.UnitTest/ResourceTests/AnalyzeGeneratedFalse/SonarLint.xml deleted file mode 100644 index 06ff5bc2533..00000000000 --- a/analyzers/tests/SonarAnalyzer.UnitTest/ResourceTests/AnalyzeGeneratedFalse/SonarLint.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - sonar.cs.analyzeGeneratedCode - false - - - diff --git a/analyzers/tests/SonarAnalyzer.UnitTest/ResourceTests/AnalyzeGeneratedFalseVbnet/SonarLint.xml b/analyzers/tests/SonarAnalyzer.UnitTest/ResourceTests/AnalyzeGeneratedFalseVbnet/SonarLint.xml deleted file mode 100644 index a3e4d99a79d..00000000000 --- a/analyzers/tests/SonarAnalyzer.UnitTest/ResourceTests/AnalyzeGeneratedFalseVbnet/SonarLint.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - sonar.vbnet.analyzeGeneratedCode - false - - - diff --git a/analyzers/tests/SonarAnalyzer.UnitTest/ResourceTests/AnalyzeGeneratedTrue/SonarLint.xml b/analyzers/tests/SonarAnalyzer.UnitTest/ResourceTests/AnalyzeGeneratedTrue/SonarLint.xml deleted file mode 100644 index 058877ce0c4..00000000000 --- a/analyzers/tests/SonarAnalyzer.UnitTest/ResourceTests/AnalyzeGeneratedTrue/SonarLint.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - sonar.cs.analyzeGeneratedCode - true - - - diff --git a/analyzers/tests/SonarAnalyzer.UnitTest/ResourceTests/AnalyzeGeneratedTrueVbnet/SonarLint.xml b/analyzers/tests/SonarAnalyzer.UnitTest/ResourceTests/AnalyzeGeneratedTrueVbnet/SonarLint.xml deleted file mode 100644 index 60d17ee38f1..00000000000 --- a/analyzers/tests/SonarAnalyzer.UnitTest/ResourceTests/AnalyzeGeneratedTrueVbnet/SonarLint.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - sonar.vbnet.analyzeGeneratedCode - true - - - diff --git a/analyzers/tests/SonarAnalyzer.UnitTest/ResourceTests/IgnoreHeaderCommentsFalseCSharp/SonarLint.xml b/analyzers/tests/SonarAnalyzer.UnitTest/ResourceTests/IgnoreHeaderCommentsFalseCSharp/SonarLint.xml deleted file mode 100644 index 4656ffb30d8..00000000000 --- a/analyzers/tests/SonarAnalyzer.UnitTest/ResourceTests/IgnoreHeaderCommentsFalseCSharp/SonarLint.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - sonar.cs.ignoreHeaderComments - false - - - diff --git a/analyzers/tests/SonarAnalyzer.UnitTest/ResourceTests/IgnoreHeaderCommentsFalseVbnet/SonarLint.xml b/analyzers/tests/SonarAnalyzer.UnitTest/ResourceTests/IgnoreHeaderCommentsFalseVbnet/SonarLint.xml deleted file mode 100644 index 19364407ace..00000000000 --- a/analyzers/tests/SonarAnalyzer.UnitTest/ResourceTests/IgnoreHeaderCommentsFalseVbnet/SonarLint.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - sonar.vbnet.ignoreHeaderComments - false - - - diff --git a/analyzers/tests/SonarAnalyzer.UnitTest/ResourceTests/IgnoreHeaderCommentsTrueCSharp/SonarLint.xml b/analyzers/tests/SonarAnalyzer.UnitTest/ResourceTests/IgnoreHeaderCommentsTrueCSharp/SonarLint.xml deleted file mode 100644 index b9a6871be55..00000000000 --- a/analyzers/tests/SonarAnalyzer.UnitTest/ResourceTests/IgnoreHeaderCommentsTrueCSharp/SonarLint.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - sonar.cs.ignoreHeaderComments - true - - - diff --git a/analyzers/tests/SonarAnalyzer.UnitTest/ResourceTests/IgnoreHeaderCommentsTrueVbnet/SonarLint.xml b/analyzers/tests/SonarAnalyzer.UnitTest/ResourceTests/IgnoreHeaderCommentsTrueVbnet/SonarLint.xml deleted file mode 100644 index 89a7cfce399..00000000000 --- a/analyzers/tests/SonarAnalyzer.UnitTest/ResourceTests/IgnoreHeaderCommentsTrueVbnet/SonarLint.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - sonar.vbnet.ignoreHeaderComments - true - - - diff --git a/analyzers/tests/SonarAnalyzer.UnitTest/ResourceTests/SonarLint.xml b/analyzers/tests/SonarAnalyzer.UnitTest/ResourceTests/SonarLint.xml deleted file mode 100644 index b99df9c60f6..00000000000 --- a/analyzers/tests/SonarAnalyzer.UnitTest/ResourceTests/SonarLint.xml +++ /dev/null @@ -1,30 +0,0 @@ - - - - - sonar.cs.ignoreHeaderComments - true - - - sonar.cs.analyzeGeneratedCode - false - - - sonar.cs.file.suffixes - .cs - - - - - S1067 - - - max - 1 - - - - - - - diff --git a/analyzers/tests/SonarAnalyzer.UnitTest/ResourceTests/SonarLintXml/All_properties_cs/SonarLint.xml b/analyzers/tests/SonarAnalyzer.UnitTest/ResourceTests/SonarLintXml/All_properties_cs/SonarLint.xml index 0dc284bc00d..54a1ed9e464 100644 --- a/analyzers/tests/SonarAnalyzer.UnitTest/ResourceTests/SonarLintXml/All_properties_cs/SonarLint.xml +++ b/analyzers/tests/SonarAnalyzer.UnitTest/ResourceTests/SonarLintXml/All_properties_cs/SonarLint.xml @@ -46,36 +46,6 @@ S2225 - - S2346 - - - S2589 - - - S3433 - - - S1135 - - - S2223 - - - S2344 - - - S2345 - - - S4524 - - - S1134 - - - S2222 - S2342 @@ -90,799 +60,17 @@ - S2115 - - - S2583 - - - S3447 - - - S2234 - - - S2479 - - - S3444 - - - S3445 - - - S1144 - - - S1264 - - - S2114 - - - S3442 - - - S3443 - - - S3329 - - - S3440 - - - S3449 - - - S3655 - - - S3776 - - - threshold - 15 - - - propertyThreshold - 3 - - - - - S3897 - - - S2201 - - - S2688 - - - S4502 - - - S1110 - - - S1117 - - - S1118 - - - S2328 - - - S2681 - - - S2326 - - - S3415 - - - S4507 - - - S1116 - - - S1125 + S2346 - - S1479 + + S1067 - maximum - 30 + max + 1 - - S2699 - - - S4635 - - - S1123 - - - S2696 - - - S1121 - - - S2692 - - - S1006 - - - S1481 - - - S2219 - - - S3237 - - - S3427 - - - S3236 - - - S3358 - - - S3598 - - - S2386 - - - S3597 - - - S4200 - - - S5773 - - - S1172 - - - S4201 - - - S5659 - - - S3249 - - - S4456 - - - S4457 - - - S3005 - - - S3246 - - - S3247 - - - S5547 - - - S3244 - - - S4211 - - - S5542 - - - S1066 - - - S4210 - - - S1185 - - - S1186 - - - S2275 - - - S2368 - - - S3241 - - - S3457 - - - S3458 - - - S4423 - - - S1155 - - - S2245 - - - S3453 - - - S3456 - - - S4426 - - - S2123 - - - S2365 - - - S2486 - - - S3451 - - - S3330 - - - S4428 - - - S5753 - - - S3217 - - - S3218 - - - S3459 - - - S927 - - - S3450 - - - S5766 - - - S1048 - - - S1168 - - - S2259 - - - S3466 - - - S2257 - - - S3343 - - - S3346 - - - S3464 - - - S2376 - - - S3220 - - - S4433 - - - S1163 - - - S2252 - - - S4790 - - - S818 - - - S2251 - - - S2372 - - - S2743 - - - S4792 - - - S1656 - - - S907 - - - S2995 - - - S3600 - - - S2996 - - - S3963 - - - S2755 - - - S2757 - - - S3604 - - - S2997 - - - S3603 - - - S3966 - - - S1751 - - - S1871 - - - S1643 - - - S1764 - - - S2737 - - - S2971 - - - S2612 - - - S2857 - - - S3875 - - - S3871 - - - S1210 - - - S1450 - - - S2306 - - - S3877 - - - S3998 - - - S1104 - - - S1215 - - - S1699 - - - S3887 - - - S3400 - - - S3884 - - - S3885 - - - S2551 - - - S3881 - - - S2436 - - - maxMethod - 3 - - - max - 2 - - - - - S3889 - - - S1313 - - - S2437 - - - S3972 - - - S2761 - - - S3610 - - - S3973 - - - S3971 - - - S3984 - - - S4830 - - - S3981 - - - S1206 - - - S3626 - - - S3869 - - - S1940 - - - S1944 - - - S1939 - - - S1905 - - - S5034 - - - S4061 - - - S5042 - - - S1854 - - - S4070 - - - S1862 - - - S3925 - - - S3926 - - - S3927 - - - S3928 - - - S2953 - - - S3923 - - - S125 - - - S1607 - - - S1848 - - - S2930 - - - S2933 - - - S3903 - - - S3904 - - - S2934 - - - S6422 - - - S110 - - - max - 5 - - - - - S2068 - - - credentialWords - password, passwd, pwd, passphrase - - - - - S5332 - - - S112 - - - S6424 - - - S2187 - - - S3397 - - - S4487 - - - S2184 - - - S6420 - - - S2183 - - - S5693 - - - fileUploadSizeLimit - 8000000 - - - - - S107 - - - max - 7 - - - - - S108 - - - S3169 - - - S4019 - - - S3168 - - - S4015 - - - S4136 - - - S2077 - - - S2190 - - - S1199 - - - S3376 - - - S3011 - - - S3256 - - - S1075 - - - S4581 - - - S4586 - - - S3010 - - - S3251 - - - S4220 - - - S4583 - - - S2178 - - - S3264 - - - S3267 - - - S5443 - - - S101 - - - S3265 - - - S5445 - - - S3262 - - - S6419 - - - S2053 - - - S3263 - - - S2292 - - - S3260 - - - S3261 - - - S2290 - - - S2291 - - - S4144 - - - S6444 - - - S3172 - - - S4143 - - - S4159 - - - S4260 - - - S4036 - - - S4158 - - - S4277 - - - S4035 - - - S4275 - - - S2092 - - - S3060 - - - S5122 - diff --git a/analyzers/tests/SonarAnalyzer.UnitTest/ResourceTests/SonarLintXml/All_properties_small_template/SonarLint.xml b/analyzers/tests/SonarAnalyzer.UnitTest/ResourceTests/SonarLintXml/All_properties_small_template/SonarLint.xml deleted file mode 100644 index 70ca0115566..00000000000 --- a/analyzers/tests/SonarAnalyzer.UnitTest/ResourceTests/SonarLintXml/All_properties_small_template/SonarLint.xml +++ /dev/null @@ -1,81 +0,0 @@ - - - - - sonar.cs.ignoreHeaderComments - true - - - sonar.cs.analyzeGeneratedCode - false - - - sonar.cs.file.suffixes - .cs - - - sonar.cs.roslyn.ignoreIssues - false - - - sonar.exclusions - Fake/Exclusions/**/*,Fake/Exclusions/Second*/**/* - - - sonar.inclusions - Fake/Inclusions/**/*,Fake/Inclusions/Second*/**/* - - - sonar.global.exclusions - Fake/GlobalExclusions/**/*,Fake/GlobalExclusions/Second*/**/* - - - sonar.test.exclusions - Fake/TestExclusions/**/*,Fake/TestExclusions/Second*/**/* - - - sonar.test.inclusions - Fake/TestInclusions/**/*,Fake/TestInclusions/Second*/**/* - - - sonar.global.test.exclusions - Fake/GlobalTestExclusions/**/*,Fake/GlobalTestExclusions/Second*/**/* - - - - - S0001 - - - S0002 - - - S0003 - - - format - ^([A-Z]{1,3}[a-z0-9]+)*([A-Z]{2})?$ - - - flagsAttributeFormat - ^([A-Z]{1,3}[a-z0-9]+)*([A-Z]{2})?s$ - - - - - S0004 - - - threshold - 15 - - - propertyThreshold - 3 - - - - - - - diff --git a/analyzers/tests/SonarAnalyzer.UnitTest/ResourceTests/SonarLintXml/All_properties_vbnet/SonarLint.xml b/analyzers/tests/SonarAnalyzer.UnitTest/ResourceTests/SonarLintXml/All_properties_vbnet/SonarLint.xml index f848061efac..270c5c95dd8 100644 --- a/analyzers/tests/SonarAnalyzer.UnitTest/ResourceTests/SonarLintXml/All_properties_vbnet/SonarLint.xml +++ b/analyzers/tests/SonarAnalyzer.UnitTest/ResourceTests/SonarLintXml/All_properties_vbnet/SonarLint.xml @@ -46,36 +46,6 @@ S2225 - - S2346 - - - S2589 - - - S3433 - - - S1135 - - - S2223 - - - S2344 - - - S2345 - - - S4524 - - - S1134 - - - S2222 - S2342 @@ -92,51 +62,6 @@ S2115 - - S2583 - - - S3447 - - - S2234 - - - S2479 - - - S3444 - - - S3445 - - - S1144 - - - S1264 - - - S2114 - - - S3442 - - - S3443 - - - S3329 - - - S3440 - - - S3449 - - - S3655 - S3776 @@ -150,739 +75,6 @@ - - S3897 - - - S2201 - - - S2688 - - - S4502 - - - S1110 - - - S1117 - - - S1118 - - - S2328 - - - S2681 - - - S2326 - - - S3415 - - - S4507 - - - S1116 - - - S1125 - - - S1479 - - - maximum - 30 - - - - - S2699 - - - S4635 - - - S1123 - - - S2696 - - - S1121 - - - S2692 - - - S1006 - - - S1481 - - - S2219 - - - S3237 - - - S3427 - - - S3236 - - - S3358 - - - S3598 - - - S2386 - - - S3597 - - - S4200 - - - S5773 - - - S1172 - - - S4201 - - - S5659 - - - S3249 - - - S4456 - - - S4457 - - - S3005 - - - S3246 - - - S3247 - - - S5547 - - - S3244 - - - S4211 - - - S5542 - - - S1066 - - - S4210 - - - S1185 - - - S1186 - - - S2275 - - - S2368 - - - S3241 - - - S3457 - - - S3458 - - - S4423 - - - S1155 - - - S2245 - - - S3453 - - - S3456 - - - S4426 - - - S2123 - - - S2365 - - - S2486 - - - S3451 - - - S3330 - - - S4428 - - - S5753 - - - S3217 - - - S3218 - - - S3459 - - - S927 - - - S3450 - - - S5766 - - - S1048 - - - S1168 - - - S2259 - - - S3466 - - - S2257 - - - S3343 - - - S3346 - - - S3464 - - - S2376 - - - S3220 - - - S4433 - - - S1163 - - - S2252 - - - S4790 - - - S818 - - - S2251 - - - S2372 - - - S2743 - - - S4792 - - - S1656 - - - S907 - - - S2995 - - - S3600 - - - S2996 - - - S3963 - - - S2755 - - - S2757 - - - S3604 - - - S2997 - - - S3603 - - - S3966 - - - S1751 - - - S1871 - - - S1643 - - - S1764 - - - S2737 - - - S2971 - - - S2612 - - - S2857 - - - S3875 - - - S3871 - - - S1210 - - - S1450 - - - S2306 - - - S3877 - - - S3998 - - - S1104 - - - S1215 - - - S1699 - - - S3887 - - - S3400 - - - S3884 - - - S3885 - - - S2551 - - - S3881 - - - S2436 - - - maxMethod - 3 - - - max - 2 - - - - - S3889 - - - S1313 - - - S2437 - - - S3972 - - - S2761 - - - S3610 - - - S3973 - - - S3971 - - - S3984 - - - S4830 - - - S3981 - - - S1206 - - - S3626 - - - S3869 - - - S1940 - - - S1944 - - - S1939 - - - S1905 - - - S5034 - - - S4061 - - - S5042 - - - S1854 - - - S4070 - - - S1862 - - - S3925 - - - S3926 - - - S3927 - - - S3928 - - - S2953 - - - S3923 - - - S125 - - - S1607 - - - S1848 - - - S2930 - - - S2933 - - - S3903 - - - S3904 - - - S2934 - - - S6422 - - - S110 - - - max - 5 - - - - - S2068 - - - credentialWords - password, passwd, pwd, passphrase - - - - - S5332 - - - S112 - - - S6424 - - - S2187 - - - S3397 - - - S4487 - - - S2184 - - - S6420 - - - S2183 - - - S5693 - - - fileUploadSizeLimit - 8000000 - - - - - S107 - - - max - 7 - - - - - S108 - - - S3169 - - - S4019 - - - S3168 - - - S4015 - - - S4136 - - - S2077 - - - S2190 - - - S1199 - - - S3376 - - - S3011 - - - S3256 - - - S1075 - - - S4581 - - - S4586 - - - S3010 - - - S3251 - - - S4220 - - - S4583 - - - S2178 - - - S3264 - - - S3267 - - - S5443 - - - S101 - - - S3265 - - - S5445 - - - S3262 - - - S6419 - - - S2053 - - - S3263 - - - S2292 - - - S3260 - - - S3261 - - - S2290 - - - S2291 - - - S4144 - - - S6444 - - - S3172 - - - S4143 - - - S4159 - - - S4260 - - - S4036 - - - S4158 - - - S4277 - - - S4035 - - - S4275 - - - S2092 - - - S3060 - - - S5122 - diff --git a/analyzers/tests/SonarAnalyzer.UnitTest/ResourceTests/RuleWithBooleanParameter/SonarLint.xml b/analyzers/tests/SonarAnalyzer.UnitTest/ResourceTests/SonarLintXml/RuleWithBooleanParameter/SonarLint.xml similarity index 100% rename from analyzers/tests/SonarAnalyzer.UnitTest/ResourceTests/RuleWithBooleanParameter/SonarLint.xml rename to analyzers/tests/SonarAnalyzer.UnitTest/ResourceTests/SonarLintXml/RuleWithBooleanParameter/SonarLint.xml diff --git a/analyzers/tests/SonarAnalyzer.UnitTest/ResourceTests/RuleWithStringParameter/SonarLint.xml b/analyzers/tests/SonarAnalyzer.UnitTest/ResourceTests/SonarLintXml/RuleWithStringParameter/SonarLint.xml similarity index 100% rename from analyzers/tests/SonarAnalyzer.UnitTest/ResourceTests/RuleWithStringParameter/SonarLint.xml rename to analyzers/tests/SonarAnalyzer.UnitTest/ResourceTests/SonarLintXml/RuleWithStringParameter/SonarLint.xml diff --git a/analyzers/tests/SonarAnalyzer.UnitTest/ResourceTests/StringInsteadOfBoolean/SonarLint.xml b/analyzers/tests/SonarAnalyzer.UnitTest/ResourceTests/SonarLintXml/StringInsteadOfBoolean/SonarLint.xml similarity index 100% rename from analyzers/tests/SonarAnalyzer.UnitTest/ResourceTests/StringInsteadOfBoolean/SonarLint.xml rename to analyzers/tests/SonarAnalyzer.UnitTest/ResourceTests/SonarLintXml/StringInsteadOfBoolean/SonarLint.xml diff --git a/analyzers/tests/SonarAnalyzer.UnitTest/ResourceTests/StringInsteadOfInt/SonarLint.xml b/analyzers/tests/SonarAnalyzer.UnitTest/ResourceTests/SonarLintXml/StringInsteadOfInt/SonarLint.xml similarity index 100% rename from analyzers/tests/SonarAnalyzer.UnitTest/ResourceTests/StringInsteadOfInt/SonarLint.xml rename to analyzers/tests/SonarAnalyzer.UnitTest/ResourceTests/SonarLintXml/StringInsteadOfInt/SonarLint.xml diff --git a/analyzers/tests/SonarAnalyzer.UnitTest/ResourceTests/ToChange/SonarLint.xml b/analyzers/tests/SonarAnalyzer.UnitTest/ResourceTests/ToChange/SonarLint.xml deleted file mode 100644 index b99df9c60f6..00000000000 --- a/analyzers/tests/SonarAnalyzer.UnitTest/ResourceTests/ToChange/SonarLint.xml +++ /dev/null @@ -1,30 +0,0 @@ - - - - - sonar.cs.ignoreHeaderComments - true - - - sonar.cs.analyzeGeneratedCode - false - - - sonar.cs.file.suffixes - .cs - - - - - S1067 - - - max - 1 - - - - - - - diff --git a/analyzers/tests/SonarAnalyzer.UnitTest/Rules/Utilities/UtilityAnalyzerBaseTest.cs b/analyzers/tests/SonarAnalyzer.UnitTest/Rules/Utilities/UtilityAnalyzerBaseTest.cs index 8f03a14688f..d1e6b4e61b2 100644 --- a/analyzers/tests/SonarAnalyzer.UnitTest/Rules/Utilities/UtilityAnalyzerBaseTest.cs +++ b/analyzers/tests/SonarAnalyzer.UnitTest/Rules/Utilities/UtilityAnalyzerBaseTest.cs @@ -34,6 +34,7 @@ public class UtilityAnalyzerBaseTest { private const string DefaultSonarProjectConfig = @"ResourceTests\SonarProjectConfig\Path_Windows\SonarProjectConfig.xml"; private const string DefaultProjectOutFolderPath = @"ResourceTests\ProjectOutFolderPath.txt"; + public TestContext TestContext { get; set; } [DataTestMethod] [DataRow(LanguageNames.CSharp, DefaultProjectOutFolderPath, @"path\output-cs")] @@ -43,7 +44,7 @@ public class UtilityAnalyzerBaseTest public void ReadConfig_OutPath(string language, string additionalPath, string expectedOutPath) { // We do not test what is read from the SonarLint file, but we need it - var utilityAnalyzer = new TestUtilityAnalyzer(language, @"ResourceTests\SonarLint.xml", additionalPath); + var utilityAnalyzer = new TestUtilityAnalyzer(language, @"ResourceTests\SonarLintXml\All_properties_cs\SonarLint.xml", additionalPath); utilityAnalyzer.TestOutPath.Should().Be(expectedOutPath); utilityAnalyzer.TestIsAnalyzerEnabled.Should().BeTrue(); @@ -55,35 +56,37 @@ public void ReadConfig_OutPath(string language, string additionalPath, string ex public void ReadConfig_OutPath_FromSonarProjectConfig_HasPriority(string firstFile, string secondFile) { // We do not test what is read from the SonarLint file, but we need it - var utilityAnalyzer = new TestUtilityAnalyzer(LanguageNames.CSharp, @"ResourceTests\SonarLint.xml", firstFile, secondFile); + var utilityAnalyzer = new TestUtilityAnalyzer(LanguageNames.CSharp, @"ResourceTests\SonarLintXml\All_properties_cs\SonarLint.xml", firstFile, secondFile); utilityAnalyzer.TestOutPath.Should().Be(@"C:\foo\bar\.sonarqube\out\0\output-cs"); utilityAnalyzer.TestIsAnalyzerEnabled.Should().BeTrue(); } [DataTestMethod] - [DataRow(LanguageNames.CSharp, @"ResourceTests\AnalyzeGeneratedTrue\SonarLint.xml", true)] - [DataRow(LanguageNames.CSharp, @"ResourceTests\AnalyzeGeneratedFalse\SonarLint.xml", false)] - [DataRow(LanguageNames.VisualBasic, @"ResourceTests\AnalyzeGeneratedTrueVbnet\SonarLint.xml", true)] - [DataRow(LanguageNames.VisualBasic, @"ResourceTests\AnalyzeGeneratedFalseVbnet\SonarLint.xml", false)] - public void ReadsSettings_AnalyzeGenerated(string language, string sonarLintXmlPath, bool expectedAnalyzeGeneratedCodeValue) + [DataRow(LanguageNames.CSharp, true)] + [DataRow(LanguageNames.CSharp, false)] + [DataRow(LanguageNames.VisualBasic, true)] + [DataRow(LanguageNames.VisualBasic, false)] + public void ReadsSettings_AnalyzeGenerated(string language, bool analyzeGenerated) { + var sonarLintXmlPath = AnalysisScaffolding.CreateSonarLintXml(TestContext, language: language, analyzeGeneratedCode: analyzeGenerated); var utilityAnalyzer = new TestUtilityAnalyzer(language, sonarLintXmlPath, DefaultSonarProjectConfig); - utilityAnalyzer.TestAnalyzeGeneratedCode.Should().Be(expectedAnalyzeGeneratedCodeValue); + utilityAnalyzer.TestAnalyzeGeneratedCode.Should().Be(analyzeGenerated); utilityAnalyzer.TestIsAnalyzerEnabled.Should().BeTrue(); } [DataTestMethod] - [DataRow(LanguageNames.CSharp, @"ResourceTests\IgnoreHeaderCommentsTrueCSharp\SonarLint.xml", true)] - [DataRow(LanguageNames.CSharp, @"ResourceTests\IgnoreHeaderCommentsFalseCSharp\SonarLint.xml", false)] - [DataRow(LanguageNames.VisualBasic, @"ResourceTests\IgnoreHeaderCommentsTrueVbnet\SonarLint.xml", true)] - [DataRow(LanguageNames.VisualBasic, @"ResourceTests\IgnoreHeaderCommentsFalseVbnet\SonarLint.xml", false)] - public void ReadsSettings_IgnoreHeaderComments(string language, string sonarLintXmlPath, bool expectedIgnoreHeaderComments) + [DataRow(LanguageNames.CSharp, true)] + [DataRow(LanguageNames.CSharp, false)] + [DataRow(LanguageNames.VisualBasic, true)] + [DataRow(LanguageNames.VisualBasic, false)] + public void ReadsSettings_IgnoreHeaderComments(string language, bool ignoreHeaderComments) { + var sonarLintXmlPath = AnalysisScaffolding.CreateSonarLintXml(TestContext, language: language, ignoreHeaderComments: ignoreHeaderComments); var utilityAnalyzer = new TestUtilityAnalyzer(language, sonarLintXmlPath, DefaultSonarProjectConfig); - utilityAnalyzer.TestIgnoreHeaderComments.Should().Be(expectedIgnoreHeaderComments); + utilityAnalyzer.TestIgnoreHeaderComments.Should().Be(ignoreHeaderComments); utilityAnalyzer.TestIsAnalyzerEnabled.Should().BeTrue(); } @@ -96,7 +99,7 @@ public void NoSonarLintXml_AnalyzerNotEnabled() [TestMethod] public void NoOutputPath_AnalyzerNotEnabled() => - new TestUtilityAnalyzer(LanguageNames.CSharp, @"ResourceTests\AnalyzeGeneratedTrue\SonarLint.xml").TestIsAnalyzerEnabled.Should().BeFalse(); + new TestUtilityAnalyzer(LanguageNames.CSharp, AnalysisScaffolding.CreateSonarLintXml(TestContext, analyzeGeneratedCode: true)).TestIsAnalyzerEnabled.Should().BeFalse(); [TestMethod] public void GetTextRange() diff --git a/analyzers/tests/SonarAnalyzer.UnitTest/TestFramework/AnalysisScaffolding.cs b/analyzers/tests/SonarAnalyzer.UnitTest/TestFramework/AnalysisScaffolding.cs index aa476e1131e..6c6b8ef5e42 100644 --- a/analyzers/tests/SonarAnalyzer.UnitTest/TestFramework/AnalysisScaffolding.cs +++ b/analyzers/tests/SonarAnalyzer.UnitTest/TestFramework/AnalysisScaffolding.cs @@ -86,6 +86,7 @@ public static string CreateSonarProjectConfigWithFilesToAnalyze(TestContext cont TestContext context, string language = LanguageNames.CSharp, bool analyzeGeneratedCode = false, + bool ignoreHeaderComments = false, string[] exclusions = null, string[] inclusions = null, string[] globalExclusions = null, @@ -93,11 +94,12 @@ public static string CreateSonarProjectConfigWithFilesToAnalyze(TestContext cont string[] testInclusions = null, string[] globalTestExclusions = null, List rulesParameters = null) => - TestHelper.WriteFile(context, "SonarLint.xml", GenerateSonarLintXmlContent(language, analyzeGeneratedCode, exclusions, inclusions, globalExclusions, testExclusions, testInclusions, globalTestExclusions, rulesParameters)); + TestHelper.WriteFile(context, "SonarLint.xml", GenerateSonarLintXmlContent(language, analyzeGeneratedCode, ignoreHeaderComments, exclusions, inclusions, globalExclusions, testExclusions, testInclusions, globalTestExclusions, rulesParameters)); public static string GenerateSonarLintXmlContent( string language = LanguageNames.CSharp, bool analyzeGeneratedCode = false, + bool ignoreHeaderComments = false, string[] exclusions = null, string[] inclusions = null, string[] globalExclusions = null, @@ -110,6 +112,7 @@ public static string CreateSonarProjectConfigWithFilesToAnalyze(TestContext cont new XElement("AnalysisInput", new XElement("Settings", CreateSetting($"sonar.{(language == LanguageNames.CSharp ? "cs" : "vbnet")}.analyzeGeneratedCode", analyzeGeneratedCode.ToString()), + CreateSetting($"sonar.{(language == LanguageNames.CSharp ? "cs" : "vbnet")}.ignoreHeaderComments", ignoreHeaderComments.ToString()), CreateSetting("sonar.exclusions", ConcatenateStringArray(exclusions)), CreateSetting("sonar.inclusions", ConcatenateStringArray(inclusions)), CreateSetting("sonar.global.exclusions", ConcatenateStringArray(globalExclusions)),