Skip to content

Commit 6cbe9d8

Browse files
Fix PSScriptAnalyzer warnings: indentation, unused parameters, long line, singular noun
1 parent 1de882f commit 6cbe9d8

2 files changed

Lines changed: 63 additions & 48 deletions

File tree

scripts/Helpers.psm1

Lines changed: 57 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
function Split-CommaSeparatedList {
2-
<#
2+
<#
33
.SYNOPSIS
44
Splits a comma-separated string into a trimmed, non-empty array.
55
@@ -20,7 +20,7 @@
2020
}
2121

2222
function Read-ActionInput {
23-
<#
23+
<#
2424
.SYNOPSIS
2525
Reads and validates action inputs from environment variables.
2626
@@ -61,7 +61,7 @@ function Read-ActionInput {
6161
}
6262

6363
function Get-PublishConfiguration {
64-
<#
64+
<#
6565
.SYNOPSIS
6666
Parses the settings JSON into a publish configuration object.
6767
@@ -75,6 +75,8 @@ function Get-PublishConfiguration {
7575
.EXAMPLE
7676
$config = Get-PublishConfiguration -SettingsJson $actionInput.SettingsJson
7777
#>
78+
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSReviewUnusedParameter', '',
79+
Justification = 'Parameter is used inside LogGroup script block.')]
7880
[CmdletBinding()]
7981
[OutputType([PSCustomObject])]
8082
param(
@@ -102,24 +104,24 @@ function Get-PublishConfiguration {
102104

103105
Write-Host '-------------------------------------------------'
104106
Write-Host ([PSCustomObject]@{
105-
AutoPatching = $config.AutoPatching
106-
IncrementalPrerelease = $config.IncrementalPrerelease
107-
DatePrereleaseFormat = $config.DatePrereleaseFormat
108-
VersionPrefix = $config.VersionPrefix
109-
ReleaseType = $config.ReleaseType
110-
IgnoreLabels = $config.IgnoreLabels -join ', '
111-
MajorLabels = $config.MajorLabels -join ', '
112-
MinorLabels = $config.MinorLabels -join ', '
113-
PatchLabels = $config.PatchLabels -join ', '
114-
} | Format-List | Out-String)
107+
AutoPatching = $config.AutoPatching
108+
IncrementalPrerelease = $config.IncrementalPrerelease
109+
DatePrereleaseFormat = $config.DatePrereleaseFormat
110+
VersionPrefix = $config.VersionPrefix
111+
ReleaseType = $config.ReleaseType
112+
IgnoreLabels = $config.IgnoreLabels -join ', '
113+
MajorLabels = $config.MajorLabels -join ', '
114+
MinorLabels = $config.MinorLabels -join ', '
115+
PatchLabels = $config.PatchLabels -join ', '
116+
} | Format-List | Out-String)
115117
Write-Host '-------------------------------------------------'
116118

117119
$config
118120
}
119121
}
120122

121123
function Get-GitHubPullRequest {
122-
<#
124+
<#
123125
.SYNOPSIS
124126
Reads and validates the GitHub pull request from the event payload.
125127
@@ -155,9 +157,9 @@ function Get-GitHubPullRequest {
155157

156158
Write-Host '-------------------------------------------------'
157159
Write-Host ([PSCustomObject]@{
158-
PRHeadRef = $pr.head.ref
159-
Labels = $labels -join ', '
160-
} | Format-List | Out-String)
160+
PRHeadRef = $pr.head.ref
161+
Labels = $labels -join ', '
162+
} | Format-List | Out-String)
161163
Write-Host '-------------------------------------------------'
162164

163165
[PSCustomObject]@{
@@ -168,7 +170,7 @@ function Get-GitHubPullRequest {
168170
}
169171

170172
function Resolve-ReleaseDecision {
171-
<#
173+
<#
172174
.SYNOPSIS
173175
Determines whether to publish a release and what kind of version bump to apply.
174176
@@ -183,6 +185,8 @@ function Resolve-ReleaseDecision {
183185
.EXAMPLE
184186
$decision = Resolve-ReleaseDecision -Configuration $config -PullRequest $pullRequest
185187
#>
188+
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSReviewUnusedParameter', '',
189+
Justification = 'Parameter is used inside LogGroup script block.')]
186190
[CmdletBinding()]
187191
[OutputType([PSCustomObject])]
188192
param(
@@ -239,14 +243,14 @@ function Resolve-ReleaseDecision {
239243

240244
Write-Host '-------------------------------------------------'
241245
Write-Host ([PSCustomObject]@{
242-
ReleaseType = $releaseType
243-
ShouldPublish = $shouldPublish
244-
CreateRelease = $createRelease
245-
CreatePrerelease = $createPrerelease
246-
Major = $majorRelease
247-
Minor = $minorRelease
248-
Patch = $patchRelease
249-
} | Format-List | Out-String)
246+
ReleaseType = $releaseType
247+
ShouldPublish = $shouldPublish
248+
CreateRelease = $createRelease
249+
CreatePrerelease = $createPrerelease
250+
Major = $majorRelease
251+
Minor = $minorRelease
252+
Patch = $patchRelease
253+
} | Format-List | Out-String)
250254
Write-Host '-------------------------------------------------'
251255

252256
[PSCustomObject]@{
@@ -262,8 +266,8 @@ function Resolve-ReleaseDecision {
262266
}
263267
}
264268

265-
function Get-GitHubReleases {
266-
<#
269+
function Get-GitHubRelease {
270+
<#
267271
.SYNOPSIS
268272
Retrieves all releases from the current GitHub repository.
269273
@@ -287,15 +291,15 @@ function Get-GitHubReleases {
287291

288292
Write-Host '-------------------------------------------------'
289293
Write-Host ($releases | Select-Object -Property name, isPrerelease, isLatest, publishedAt |
290-
Format-Table | Out-String)
294+
Format-Table | Out-String)
291295
Write-Host '-------------------------------------------------'
292296

293297
$releases
294298
}
295299
}
296300

297301
function Get-LatestGitHubVersion {
298-
<#
302+
<#
299303
.SYNOPSIS
300304
Extracts the latest stable version from a GitHub releases list.
301305
@@ -305,6 +309,8 @@ function Get-LatestGitHubVersion {
305309
.EXAMPLE
306310
$ghVersion = Get-LatestGitHubVersion -Releases $releases
307311
#>
312+
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSReviewUnusedParameter', '',
313+
Justification = 'Parameter is used inside LogGroup script block.')]
308314
[CmdletBinding()]
309315
[OutputType([object])]
310316
param(
@@ -330,7 +336,7 @@ function Get-LatestGitHubVersion {
330336
}
331337

332338
function Get-LatestPSGalleryVersion {
333-
<#
339+
<#
334340
.SYNOPSIS
335341
Finds the latest stable version of a module in the PowerShell Gallery.
336342
@@ -344,6 +350,8 @@ function Get-LatestPSGalleryVersion {
344350
.EXAMPLE
345351
$psGalleryVersion = Get-LatestPSGalleryVersion -ModuleName 'MyModule'
346352
#>
353+
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSReviewUnusedParameter', '',
354+
Justification = 'Parameter is used inside LogGroup script block.')]
347355
[CmdletBinding()]
348356
[OutputType([object])]
349357
param(
@@ -386,7 +394,7 @@ function Get-LatestPSGalleryVersion {
386394
}
387395

388396
function Get-LatestPublishedVersion {
389-
<#
397+
<#
390398
.SYNOPSIS
391399
Returns the highest version between GitHub and the PowerShell Gallery.
392400
@@ -396,6 +404,8 @@ function Get-LatestPublishedVersion {
396404
.EXAMPLE
397405
$latestVersion = Get-LatestPublishedVersion -GitHubVersion $ghVersion -PSGalleryVersion $psGalleryVersion
398406
#>
407+
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSReviewUnusedParameter', '',
408+
Justification = 'Parameter is used inside LogGroup script block.')]
399409
[CmdletBinding()]
400410
[OutputType([object])]
401411
param(
@@ -418,7 +428,7 @@ function Get-LatestPublishedVersion {
418428
}
419429

420430
function Get-NextPrereleaseNumber {
421-
<#
431+
<#
422432
.SYNOPSIS
423433
Calculates the next incremental prerelease number across GitHub and PSGallery.
424434
@@ -491,7 +501,7 @@ function Get-NextPrereleaseNumber {
491501
}
492502

493503
function Get-NextModuleVersion {
494-
<#
504+
<#
495505
.SYNOPSIS
496506
Calculates the next module version based on the release decision.
497507
@@ -503,8 +513,11 @@ function Get-NextModuleVersion {
503513
PSSemVer representing the resolved next version.
504514
505515
.EXAMPLE
506-
$newVersion = Get-NextModuleVersion -LatestVersion $latestVersion -Decision $decision -Configuration $config -ModuleName 'MyModule' -Releases $releases
516+
$newVersion = Get-NextModuleVersion -LatestVersion $latestVersion -Decision $decision `
517+
-Configuration $config -ModuleName 'MyModule' -Releases $releases
507518
#>
519+
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSReviewUnusedParameter', '',
520+
Justification = 'Parameter is used inside LogGroup script block.')]
508521
[CmdletBinding()]
509522
[OutputType([object])]
510523
param(
@@ -574,13 +587,15 @@ function Get-NextModuleVersion {
574587
}
575588

576589
function Write-ActionOutput {
577-
<#
590+
<#
578591
.SYNOPSIS
579592
Emits the resolved version and release type as GitHub Actions step outputs.
580593
581594
.EXAMPLE
582595
Write-ActionOutput -Decision $decision -NewVersion $newVersion
583596
#>
597+
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSReviewUnusedParameter', '',
598+
Justification = 'Parameter is used inside LogGroup script block.')]
584599
[CmdletBinding()]
585600
param(
586601
# The release decision object.
@@ -617,12 +632,12 @@ function Write-ActionOutput {
617632

618633
Write-Host '-------------------------------------------------'
619634
Write-Host ([PSCustomObject]@{
620-
Version = $versionString
621-
Prerelease = $prereleaseString
622-
FullVersion = $fullVersionString
623-
ReleaseType = $resolvedReleaseType
624-
CreateRelease = $Decision.ShouldPublish
625-
} | Format-List | Out-String)
635+
Version = $versionString
636+
Prerelease = $prereleaseString
637+
FullVersion = $fullVersionString
638+
ReleaseType = $resolvedReleaseType
639+
CreateRelease = $Decision.ShouldPublish
640+
} | Format-List | Out-String)
626641
Write-Host '-------------------------------------------------'
627642
}
628643
}

scripts/main.ps1

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,17 @@ $decision = Resolve-ReleaseDecision -Configuration $config -PullRequest $pullReq
1414
$newVersion = $null
1515

1616
if ($decision.ShouldPublish) {
17-
$releases = Get-GitHubReleases
17+
$releases = Get-GitHubRelease
1818
$ghVersion = Get-LatestGitHubVersion -Releases $releases
1919
$psGalleryVersion = Get-LatestPSGalleryVersion -ModuleName $actionInput.Name
2020
$latestVersion = Get-LatestPublishedVersion -GitHubVersion $ghVersion -PSGalleryVersion $psGalleryVersion
2121

2222
$params = @{
23-
LatestVersion = $latestVersion
24-
Decision = $decision
25-
Configuration = $config
26-
ModuleName = $actionInput.Name
27-
Releases = $releases
23+
LatestVersion = $latestVersion
24+
Decision = $decision
25+
Configuration = $config
26+
ModuleName = $actionInput.Name
27+
Releases = $releases
2828
}
2929
$newVersion = Get-NextModuleVersion @params
3030
}

0 commit comments

Comments
 (0)