Skip to content

Commit 44130ce

Browse files
author
Quoc Truong
committed
Add rule documentation for useoutputtypecorrectly
1 parent 59d5a58 commit 44130ce

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#UseOutputTypeCorrectly
2+
**Severity Level: Warning**
3+
4+
5+
##Description
6+
7+
If a return type is declared, the cmdlet must return that type. If a type is returned, a return type must be declared.
8+
9+
##How to Fix
10+
11+
To fix a violation of this rule, please check the OuputType attribute lists and the types that are returned in your code. You can get more details by running “Get-Help about_Functions_OutputTypeAttribute” command in Windows PowerShell.
12+
13+
##Example
14+
15+
##Example
16+
Wrong:
17+
18+
function Get-Foo
19+
{
20+
[CmdletBinding()]
21+
[OutputType([String])]
22+
Param(
23+
)
24+
return "4
25+
}
26+
27+
Correct:
28+
29+
function Get-Foo
30+
{
31+
[CmdletBinding()]
32+
[OutputType([String])]
33+
Param(
34+
)
35+
36+
return "bar"
37+
}

0 commit comments

Comments
 (0)