1212
1313using System ;
1414using System . Collections . Generic ;
15- using System . Linq ;
1615using System . Management . Automation . Language ;
1716using Microsoft . Windows . Powershell . ScriptAnalyzer . Generic ;
1817using System . ComponentModel . Composition ;
1918using System . Globalization ;
20- using System . Management . Automation ;
2119
2220namespace Microsoft . Windows . Powershell . ScriptAnalyzer . BuiltinRules
2321{
@@ -35,11 +33,11 @@ public class ProvideVerboseMessage : SkipNamedBlock, IScriptRule
3533 public IEnumerable < DiagnosticRecord > AnalyzeScript ( Ast ast , string fileName )
3634 {
3735 if ( ast == null ) throw new ArgumentNullException ( Strings . NullAstErrorMessage ) ;
38-
36+
3937 ClearList ( ) ;
4038 this . AddNames ( new List < string > ( ) { "Configuration" , "Workflow" } ) ;
4139 DiagnosticRecords . Clear ( ) ;
42-
40+
4341 this . fileName = fileName ;
4442 //We only check that advanced functions should have Write-Verbose
4543 ast . Visit ( this ) ;
@@ -59,17 +57,6 @@ public override AstVisitAction VisitFunctionDefinition(FunctionDefinitionAst fun
5957 return AstVisitAction . SkipChildren ;
6058 }
6159
62- //Write-Verbose is not required for non-advanced functions
63- if ( funcAst . Body != null && funcAst . Body . ParamBlock != null
64- && funcAst . Body . ParamBlock . Attributes != null &&
65- funcAst . Body . ParamBlock . Parameters != null )
66- {
67- if ( ! funcAst . Body . ParamBlock . Attributes . Any ( attr => attr . TypeName . GetReflectionType ( ) == typeof ( CmdletBindingAttribute ) ) )
68- {
69- return AstVisitAction . Continue ;
70- }
71- }
72-
7360 var commandAsts = funcAst . Body . FindAll ( testAst => testAst is CommandAst , false ) ;
7461 bool hasVerbose = false ;
7562
0 commit comments