File tree Expand file tree Collapse file tree 2 files changed +17
-0
lines changed
Expand file tree Collapse file tree 2 files changed +17
-0
lines changed Original file line number Diff line number Diff line change 1212
1313using System ;
1414using System . Collections . Generic ;
15+ using System . Linq ;
1516using System . Management . Automation . Language ;
1617using Microsoft . Windows . Powershell . ScriptAnalyzer . Generic ;
1718using System . ComponentModel . Composition ;
1819using System . Globalization ;
20+ using System . Management . Automation ;
1921
2022namespace Microsoft . Windows . Powershell . ScriptAnalyzer . BuiltinRules
2123{
@@ -57,6 +59,15 @@ public override AstVisitAction VisitFunctionDefinition(FunctionDefinitionAst fun
5759 return AstVisitAction . SkipChildren ;
5860 }
5961
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+
6071 var commandAsts = funcAst . Body . FindAll ( testAst => testAst is CommandAst , false ) ;
6172 bool hasVerbose = false ;
6273
Original file line number Diff line number Diff line change @@ -81,4 +81,10 @@ function Get-File
8181 if ($pscmdlet.ShouldContinue (" Yes" , " No" )) {
8282 }
8383 }
84+ }
85+
86+ # Write-Verbose should not be required because this is not an advanced function
87+ function Get-SimpleFunc
88+ {
89+
8490}
You can’t perform that action at this time.
0 commit comments