@@ -30,6 +30,8 @@ namespace Microsoft.Windows.PowerShell.ScriptAnalyzer.BuiltinRules
3030#endif
3131 class UseSupportsShouldProcess : ConfigurableRule
3232 {
33+ private const char whitespace = ' ' ;
34+ private const int indentationSize = 4 ;
3335 private Ast ast ;
3436 private Token [ ] tokens ;
3537 /// <summary>
@@ -180,7 +182,7 @@ private List<CorrectionExtent> GetCorrections(
180182
181183 // This is how we handle multiple edits-
182184 // create separate edits
183- // apply those edits to the original script extent1
185+ // apply those edits to the original script extent
184186 // and then give the corrected extent as suggested correction.
185187
186188 // sort in descending order of start position
@@ -216,8 +218,7 @@ private CorrectionExtent GetCorrectionToAddParamBlock(
216218 {
217219 var funcStartScriptPos = funcDefnAst . Extent . StartScriptPosition ;
218220 var paramBlockText = WriteParamBlock ( parameterAsts ) ;
219- // TODO replace this hard coding
220- var indentation = new string ( ' ' , funcStartScriptPos . ColumnNumber + 3 ) ;
221+ var indentation = new string ( whitespace , funcStartScriptPos . ColumnNumber + 3 ) ;
221222 var lines = new List < String > ( ) ;
222223 lines . Add ( "{" ) ;
223224 lines . AddRange ( paramBlockText . Select ( line => indentation + line ) ) ;
@@ -237,8 +238,7 @@ private IList<String> WriteParamBlock(ParameterAst[] parameterAsts)
237238 lines . Add ( "[CmdletBinding(SupportsShouldProcess)]" ) ;
238239 lines . Add ( "param(" ) ;
239240
240- // TODO replace this hard coding
241- string indentation = new string ( ' ' , 4 ) ;
241+ string indentation = new string ( whitespace , indentationSize ) ;
242242 int count = 0 ;
243243 var usableParamAsts = parameterAsts . Where ( p => ! IsWhatIf ( p ) && ! IsConfirm ( p ) ) ;
244244 var usableCount = usableParamAsts . Count ( ) ;
@@ -323,7 +323,7 @@ private static CorrectionExtent GetCorrectionToAddParamBlock(ParamBlockAst param
323323 1 ,
324324 1 ,
325325 new String [ ] {
326- new String ( ' ' , paramBlockAst . Extent . StartColumnNumber - 1 )
326+ new String ( whitespace , paramBlockAst . Extent . StartColumnNumber - 1 )
327327 + "[CmdletBinding(SupportsShouldProcess)]" ,
328328 String . Empty
329329 } ,
0 commit comments