12
12
13
13
using System ;
14
14
using System . Collections . Generic ;
15
- using System . Linq ;
16
15
using System . Management . Automation . Language ;
17
16
using Microsoft . Windows . Powershell . ScriptAnalyzer . Generic ;
18
17
using System . ComponentModel . Composition ;
19
18
using System . Globalization ;
20
- using System . Management . Automation ;
21
19
22
20
namespace Microsoft . Windows . Powershell . ScriptAnalyzer . BuiltinRules
23
21
{
@@ -35,11 +33,11 @@ public class ProvideVerboseMessage : SkipNamedBlock, IScriptRule
35
33
public IEnumerable < DiagnosticRecord > AnalyzeScript ( Ast ast , string fileName )
36
34
{
37
35
if ( ast == null ) throw new ArgumentNullException ( Strings . NullAstErrorMessage ) ;
38
-
36
+
39
37
ClearList ( ) ;
40
38
this . AddNames ( new List < string > ( ) { "Configuration" , "Workflow" } ) ;
41
39
DiagnosticRecords . Clear ( ) ;
42
-
40
+
43
41
this . fileName = fileName ;
44
42
//We only check that advanced functions should have Write-Verbose
45
43
ast . Visit ( this ) ;
@@ -59,17 +57,6 @@ public override AstVisitAction VisitFunctionDefinition(FunctionDefinitionAst fun
59
57
return AstVisitAction . SkipChildren ;
60
58
}
61
59
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
-
73
60
var commandAsts = funcAst . Body . FindAll ( testAst => testAst is CommandAst , false ) ;
74
61
bool hasVerbose = false ;
75
62
0 commit comments