@@ -24,7 +24,7 @@ namespace Microsoft.Windows.PowerShell.ScriptAnalyzer.Commands
24
24
/// GetScriptAnalyzerRuleCommand: Cmdlet to list all the analyzer rule names and descriptions.
25
25
/// </summary>
26
26
[ Cmdlet ( VerbsCommon . Get , "ScriptAnalyzerRule" , HelpUri = "http://go.microsoft.com/fwlink/?LinkId=525913" ) ]
27
- public class GetScriptAnalyzerRuleCommand : PSCmdlet
27
+ public class GetScriptAnalyzerRuleCommand : PSCmdlet , IOutputWriter
28
28
{
29
29
#region Parameters
30
30
/// <summary>
@@ -69,68 +69,22 @@ public string[] Severity
69
69
70
70
#endregion Parameters
71
71
72
- #region Private Members
73
-
74
- Dictionary < string , List < string > > validationResults = new Dictionary < string , List < string > > ( ) ;
75
-
76
- #endregion
77
-
78
72
#region Overrides
79
73
80
74
/// <summary>
81
75
/// BeginProcessing : TBD
82
76
/// </summary>
83
77
protected override void BeginProcessing ( )
84
78
{
85
- #region Set PSCmdlet property of Helper
86
-
87
- Helper . Instance . MyCmdlet = this ;
88
-
89
- #endregion
90
- // Verifies rule extensions
91
- if ( customizedRulePath != null )
92
- {
93
- validationResults = ScriptAnalyzer . Instance . CheckRuleExtension ( customizedRulePath , this ) ;
94
- foreach ( string extension in validationResults [ "InvalidPaths" ] )
95
- {
96
- WriteWarning ( string . Format ( CultureInfo . CurrentCulture , Strings . MissingRuleExtension , extension ) ) ;
97
- }
98
- }
99
- else
100
- {
101
- validationResults . Add ( "InvalidPaths" , new List < string > ( ) ) ;
102
- validationResults . Add ( "ValidModPaths" , new List < string > ( ) ) ;
103
- validationResults . Add ( "ValidDllPaths" , new List < string > ( ) ) ;
104
- }
105
-
106
- try
107
- {
108
- if ( validationResults [ "ValidDllPaths" ] . Count == 0 )
109
- {
110
- ScriptAnalyzer . Instance . Initialize ( ) ;
111
- }
112
- else
113
- {
114
- ScriptAnalyzer . Instance . Initilaize ( validationResults ) ;
115
- }
116
- }
117
- catch ( Exception ex )
118
- {
119
- ThrowTerminatingError ( new ErrorRecord ( ex , ex . HResult . ToString ( "X" , CultureInfo . CurrentCulture ) ,
120
- ErrorCategory . NotSpecified , this ) ) ;
121
- }
79
+ ScriptAnalyzer . Instance . Initialize ( this , customizedRulePath ) ;
122
80
}
123
81
124
82
/// <summary>
125
83
/// ProcessRecord : TBD
126
84
/// </summary>
127
85
protected override void ProcessRecord ( )
128
86
{
129
- string [ ] modNames = null ;
130
- if ( validationResults [ "ValidModPaths" ] . Count > 0 )
131
- {
132
- modNames = validationResults [ "ValidModPaths" ] . ToArray < string > ( ) ;
133
- }
87
+ string [ ] modNames = ScriptAnalyzer . Instance . GetValidModulePaths ( ) ;
134
88
135
89
IEnumerable < IRule > rules = ScriptAnalyzer . Instance . GetRule ( modNames , name ) ;
136
90
if ( rules == null )
0 commit comments