26
26
using SonarAnalyzer . Rules . CSharp ;
27
27
using SonarAnalyzer . SymbolicExecution . Roslyn . RuleChecks . CSharp ;
28
28
using SonarAnalyzer . Test . Helpers ;
29
+ using SonarAnalyzer . Test . PackagingTests ;
29
30
30
31
namespace SonarAnalyzer . Test . Common
31
32
{
@@ -150,7 +151,7 @@ public void AllParameterizedRules_AreDisabledByDefault() =>
150
151
. Where ( RuleFinder . IsParameterized )
151
152
. Select ( type => ( DiagnosticAnalyzer ) Activator . CreateInstance ( type ) )
152
153
. SelectMany ( analyzer => analyzer . SupportedDiagnostics )
153
- . Where ( analyzer => ! TestHelper . IsSecurityHotspot ( analyzer ) )
154
+ . Where ( analyzer => ! IsSecurityHotspot ( analyzer ) )
154
155
. ToList ( )
155
156
. ForEach ( diagnostic => diagnostic . IsEnabledByDefault . Should ( ) . BeFalse ( ) ) ;
156
157
@@ -172,7 +173,7 @@ public void AllRulesEnabledByDefault_ContainSonarWayCustomTag()
172
173
var descriptors = RuleFinder . RuleAnalyzerTypes . SelectMany ( SupportedDiagnostics )
173
174
// Security hotspots are enabled by default, but they will report issues only
174
175
// when their ID is contained in SonarLint.xml
175
- . Where ( descriptor => ! TestHelper . IsSecurityHotspot ( descriptor ) ) ;
176
+ . Where ( descriptor => ! IsSecurityHotspot ( descriptor ) ) ;
176
177
177
178
foreach ( var descriptor in descriptors )
178
179
{
@@ -228,7 +229,7 @@ public void AllRules_SonarWayTagPresenceMatchesIsEnabledByDefault()
228
229
229
230
foreach ( var diagnostic in RuleFinder . RuleAnalyzerTypes . SelectMany ( SupportedDiagnostics ) )
230
231
{
231
- if ( TestHelper . IsSecurityHotspot ( diagnostic ) )
232
+ if ( IsSecurityHotspot ( diagnostic ) )
232
233
{
233
234
// Security hotspots are enabled by default, but they will report issues only when their ID is contained in SonarLint.xml
234
235
// DiagnosticDescriptorFactory adds WellKnownDiagnosticTags.NotConfigurable to prevent rule supression and deactivation.
@@ -339,7 +340,6 @@ public void UnchangedFiles_ReportDiagnosticIfNonGeneratedBasedRule(string unchan
339
340
UnchangedFiles_Verify ( builder , unchangedFileName , expectEmptyResults ) ;
340
341
}
341
342
342
- [ AssertionMethod ]
343
343
private static void AllRulesAreConfigurable ( AnalyzerLanguage language )
344
344
{
345
345
foreach ( var diagnostic in SupportedDiagnostics ( language ) )
@@ -403,6 +403,12 @@ private static void VerifyNoExceptionThrown(string path, DiagnosticAnalyzer[] di
403
403
DiagnosticVerifier . VerifyNoExceptionThrown ( diagnostics ) ;
404
404
}
405
405
406
+ private static bool IsSecurityHotspot ( DiagnosticDescriptor diagnostic )
407
+ {
408
+ var type = RuleTypeMappingCS . Rules . GetValueOrDefault ( diagnostic . Id ) ?? RuleTypeMappingVB . Rules . GetValueOrDefault ( diagnostic . Id ) ;
409
+ return type == "SECURITY_HOTSPOT" ;
410
+ }
411
+
406
412
[ DiagnosticAnalyzer ( LanguageNames . CSharp ) ]
407
413
private class ConcurrentExecutionReader : SonarDiagnosticAnalyzer
408
414
{
0 commit comments