Skip to content

Commit 4dec4c3

Browse files
Make FunctionCount example otherwise compliant
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
1 parent 0f40e13 commit 4dec4c3

1 file changed

Lines changed: 101 additions & 6 deletions

File tree

src/docs/Frameworks/Process-PSModule/skipping-framework-tests.md

Lines changed: 101 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,38 +58,133 @@ Here's an example of a function file that skips the `FunctionCount` test because
5858
function Get-ComplexData {
5959
<#
6060
.SYNOPSIS
61-
Retrieves complex data using helper functions.
61+
Get formatted data from a file.
62+
63+
.DESCRIPTION
64+
Read data from a file and format it as a structured object.
65+
66+
.EXAMPLE
67+
Get-ComplexData -Path '.\data.txt'
68+
69+
Get the file content and its character count.
70+
71+
.INPUTS
72+
None
73+
74+
You can't pipe objects to Get-ComplexData.
75+
76+
.OUTPUTS
77+
System.Management.Automation.PSCustomObject
78+
79+
The formatted file data.
80+
81+
.NOTES
82+
This file intentionally skips only the FunctionCount framework test.
83+
84+
.LINK
85+
Get-RawData
6286
#>
87+
[OutputType([PSCustomObject])]
6388
[CmdletBinding()]
6489
param(
90+
# The path to the data file.
6591
[Parameter(Mandatory)]
92+
[ValidateNotNullOrEmpty()]
6693
[string] $Path
6794
)
6895
6996
$data = Get-RawData -Path $Path
70-
$processed = Format-ComplexData -Data $data
71-
return $processed
97+
Format-ComplexData -Data $data
7298
}
7399
74100
function Get-RawData {
101+
<#
102+
.SYNOPSIS
103+
Get unformatted data from a file.
104+
105+
.DESCRIPTION
106+
Read the complete content of a data file as one string.
107+
108+
.EXAMPLE
109+
Get-RawData -Path '.\data.txt'
110+
111+
Get the complete content of the data file.
112+
113+
.INPUTS
114+
None
115+
116+
You can't pipe objects to Get-RawData.
117+
118+
.OUTPUTS
119+
System.String
120+
121+
The unformatted file content.
122+
123+
.NOTES
124+
This function is a private helper for Get-ComplexData.
125+
126+
.LINK
127+
Get-Content
128+
#>
129+
[OutputType([string])]
75130
[CmdletBinding()]
76131
param(
132+
# The path to the data file.
77133
[Parameter(Mandatory)]
134+
[ValidateNotNullOrEmpty()]
78135
[string] $Path
79136
)
80-
# Helper function implementation
137+
138+
Get-Content -LiteralPath $Path -Raw
81139
}
82140
83141
function Format-ComplexData {
142+
<#
143+
.SYNOPSIS
144+
Format raw data as a structured object.
145+
146+
.DESCRIPTION
147+
Add useful metadata to raw data while preserving its content.
148+
149+
.EXAMPLE
150+
Format-ComplexData -Data 'example'
151+
152+
Format the string and include its character count.
153+
154+
.INPUTS
155+
None
156+
157+
You can't pipe objects to Format-ComplexData.
158+
159+
.OUTPUTS
160+
System.Management.Automation.PSCustomObject
161+
162+
The formatted data and its character count.
163+
164+
.NOTES
165+
This function is a private helper for Get-ComplexData.
166+
167+
.LINK
168+
Get-ComplexData
169+
#>
170+
[OutputType([PSCustomObject])]
84171
[CmdletBinding()]
85172
param(
173+
# The raw content to format.
86174
[Parameter(Mandatory)]
87-
$Data
175+
[ValidateNotNullOrEmpty()]
176+
[string] $Data
88177
)
89-
# Helper function implementation
178+
179+
[PSCustomObject] @{
180+
Content = $Data
181+
CharacterCount = $Data.Length
182+
}
90183
}
91184
```
92185

186+
The skip exempts only `FunctionCount`. Every function in the file must still follow the [PowerShell function standard](../../Coding-Standards/PowerShell/Functions.md), including complete comment-based help, matching `[OutputType()]` and `.OUTPUTS` metadata, typed parameters, and implicit output.
187+
93188
## Best Practices
94189

95190
- **Use skip comments sparingly**: Framework tests exist to maintain code quality and consistency. Only skip tests when absolutely necessary.

0 commit comments

Comments
 (0)