File tree 2 files changed +17
-0
lines changed
2 files changed +17
-0
lines changed Original file line number Diff line number Diff line change 12
12
13
13
using System ;
14
14
using System . Collections . Generic ;
15
+ using System . Linq ;
15
16
using System . Management . Automation . Language ;
16
17
using Microsoft . Windows . Powershell . ScriptAnalyzer . Generic ;
17
18
using System . ComponentModel . Composition ;
18
19
using System . Globalization ;
20
+ using System . Management . Automation ;
19
21
20
22
namespace Microsoft . Windows . Powershell . ScriptAnalyzer . BuiltinRules
21
23
{
@@ -57,6 +59,15 @@ public override AstVisitAction VisitFunctionDefinition(FunctionDefinitionAst fun
57
59
return AstVisitAction . SkipChildren ;
58
60
}
59
61
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
+ ! funcAst . Body . ParamBlock . Attributes . Any ( attr => attr . TypeName . GetReflectionType ( ) == typeof ( CmdletBindingAttribute ) ) )
67
+ {
68
+ return AstVisitAction . Continue ;
69
+ }
70
+
60
71
var commandAsts = funcAst . Body . FindAll ( testAst => testAst is CommandAst , false ) ;
61
72
bool hasVerbose = false ;
62
73
Original file line number Diff line number Diff line change @@ -81,4 +81,10 @@ function Get-File
81
81
if ($pscmdlet.ShouldContinue (" Yes" , " No" )) {
82
82
}
83
83
}
84
+ }
85
+
86
+ # Write-Verbose should not be required because this is not an advanced function
87
+ function Get-SimpleFunc
88
+ {
89
+
84
90
}
You can’t perform that action at this time.
0 commit comments