|
1 |
| -// Copyright (c) Microsoft Corporation. |
2 |
| -// |
3 |
| -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
4 |
| -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
5 |
| -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
6 |
| -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
7 |
| -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
8 |
| -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
9 |
| -// THE SOFTWARE. |
| 1 | +// Copyright (c) Microsoft Corporation. All rights reserved. |
| 2 | +// Licensed under the MIT License. |
10 | 3 |
|
11 | 4 | using System;
|
12 | 5 | using System.Collections.Generic;
|
13 | 6 | #if !CORECLR
|
14 | 7 | using System.ComponentModel.Composition;
|
15 | 8 | #endif
|
16 |
| -using System.Management.Automation; |
17 | 9 | using System.Management.Automation.Language;
|
18 | 10 | using System.Globalization;
|
19 |
| -using System.Linq; |
20 | 11 | using Microsoft.Windows.PowerShell.ScriptAnalyzer.Generic;
|
21 | 12 |
|
22 | 13 | namespace Microsoft.Windows.PowerShell.ScriptAnalyzer.BuiltinRules
|
23 |
| -{ |
| 14 | +{ |
24 | 15 | /// <summary>
|
25 | 16 | /// UseShouldProcessForStateChangingFunctions: Analyzes the ast to check if ShouldProcess is included in Advanced functions if the Verb of the function could change system state.
|
26 | 17 | /// </summary>
|
@@ -61,7 +52,8 @@ public IEnumerable<DiagnosticRecord> AnalyzeScript(Ast ast, string fileName)
|
61 | 52 | private bool IsStateChangingFunctionWithNoShouldProcessAttribute(Ast ast)
|
62 | 53 | {
|
63 | 54 | var funcDefAst = ast as FunctionDefinitionAst;
|
64 |
| - if (funcDefAst == null) |
| 55 | + // SupportsShouldProcess is not supported in workflows |
| 56 | + if (funcDefAst == null || funcDefAst.IsWorkflow) |
65 | 57 | {
|
66 | 58 | return false;
|
67 | 59 | }
|
|
0 commit comments