@@ -20,14 +20,26 @@ Describe "ReviewUnusedParameter" {
20
20
$Violations.Count | Should - Be 2
21
21
}
22
22
23
- It " has 1 violation - function with 1 parameter with ValueFromPipeline set to false and `$ _ usage" {
24
- $ScriptDefinition = ' function BadFunc1 { param ([Parameter(ValueFromPipeline = $false)] $Param1) $_ }'
23
+ It " has 1 violation - function with 1 parameter with ValueFromPipeline set to false and `$ _ usage inside process block " {
24
+ $ScriptDefinition = ' function BadFunc1 { param ([Parameter(ValueFromPipeline = $false)] $Param1) process {$_} }'
25
25
$Violations = Invoke-ScriptAnalyzer - ScriptDefinition $ScriptDefinition - IncludeRule $RuleName
26
26
$Violations.Count | Should - Be 1
27
27
}
28
28
29
- It " has 1 violation - function with 1 parameter with ValueFromPipeline set to false and `$ PSItem usage" {
30
- $ScriptDefinition = ' function BadFunc1 { param ([Parameter(ValueFromPipeline = $false)] $Param1) $PSItem}'
29
+ It " has 1 violation - function with 1 parameter with ValueFromPipeline set to false and `$ PSItem usage inside process block" {
30
+ $ScriptDefinition = ' function BadFunc1 { param ([Parameter(ValueFromPipeline = $false)] $Param1) process {$PSItem}}'
31
+ $Violations = Invoke-ScriptAnalyzer - ScriptDefinition $ScriptDefinition - IncludeRule $RuleName
32
+ $Violations.Count | Should - Be 1
33
+ }
34
+
35
+ It " has 1 violation - function with 1 parameter with ValueFromPipeline set to true and `$ _ usage outside process block" {
36
+ $ScriptDefinition = ' function BadFunc1 { param ([Parameter(ValueFromPipeline = $true)] $Param1) $_}'
37
+ $Violations = Invoke-ScriptAnalyzer - ScriptDefinition $ScriptDefinition - IncludeRule $RuleName
38
+ $Violations.Count | Should - Be 1
39
+ }
40
+
41
+ It " has 1 violation - function with 1 parameter with ValueFromPipeline set to true and `$ PSItem usage outside process block" {
42
+ $ScriptDefinition = ' function BadFunc1 { param ([Parameter(ValueFromPipeline = $true)] $Param1) $PSItem}'
31
43
$Violations = Invoke-ScriptAnalyzer - ScriptDefinition $ScriptDefinition - IncludeRule $RuleName
32
44
$Violations.Count | Should - Be 1
33
45
}
@@ -71,26 +83,26 @@ Describe "ReviewUnusedParameter" {
71
83
$Violations.Count | Should - Be 0
72
84
}
73
85
74
- It " has no violation - function with 1 parameter with ValueFromPipeline explictly set to true and `$ _ usage" {
75
- $ScriptDefinition = ' function BadFunc1 { param ([Parameter(ValueFromPipeline = $true)] $Param1) $_ }'
86
+ It " has no violation - function with 1 parameter with ValueFromPipeline explictly set to true and `$ _ usage inside process block " {
87
+ $ScriptDefinition = ' function BadFunc1 { param ([Parameter(ValueFromPipeline = $true)] $Param1) process {$_} }'
76
88
$Violations = Invoke-ScriptAnalyzer - ScriptDefinition $ScriptDefinition - IncludeRule $RuleName
77
89
$Violations.Count | Should - Be 0
78
90
}
79
91
80
- It " has no violation - function with 1 parameter with ValueFromPipeline explictly set to true and `$ PSItem usage" {
81
- $ScriptDefinition = ' function BadFunc1 { param ([Parameter(ValueFromPipeline = $true)] $Param1) $PSItem}'
92
+ It " has no violation - function with 1 parameter with ValueFromPipeline explictly set to true and `$ PSItem usage inside process block " {
93
+ $ScriptDefinition = ' function BadFunc1 { param ([Parameter(ValueFromPipeline = $true)] $Param1) process { $PSItem} }'
82
94
$Violations = Invoke-ScriptAnalyzer - ScriptDefinition $ScriptDefinition - IncludeRule $RuleName
83
95
$Violations.Count | Should - Be 0
84
96
}
85
97
86
- It " has no violation - function with 1 parameter with ValueFromPipeline implicitly set to true and `$ _ usage" {
87
- $ScriptDefinition = ' function BadFunc1 { param ([Parameter(ValueFromPipeline)] $Param1) $_ }'
98
+ It " has no violation - function with 1 parameter with ValueFromPipeline implicitly set to true and `$ _ usage inside process block " {
99
+ $ScriptDefinition = ' function BadFunc1 { param ([Parameter(ValueFromPipeline)] $Param1) process{$_} }'
88
100
$Violations = Invoke-ScriptAnalyzer - ScriptDefinition $ScriptDefinition - IncludeRule $RuleName
89
101
$Violations.Count | Should - Be 0
90
102
}
91
103
92
- It " has no violation - function with 1 parameter with ValueFromPipeline implicitly set to true and `$ PSItem usage" {
93
- $ScriptDefinition = ' function BadFunc1 { param ([Parameter(ValueFromPipeline)] $Param1) $PSItem}'
104
+ It " has no violation - function with 1 parameter with ValueFromPipeline implicitly set to true and `$ PSItem usage inside process block " {
105
+ $ScriptDefinition = ' function BadFunc1 { param ([Parameter(ValueFromPipeline)] $Param1) process{ $PSItem} }'
94
106
$Violations = Invoke-ScriptAnalyzer - ScriptDefinition $ScriptDefinition - IncludeRule $RuleName
95
107
$Violations.Count | Should - Be 0
96
108
}
0 commit comments