Skip to content

Commit

Permalink
fixes #99 - PSScriptAnalyzer violations in primary module build
Browse files Browse the repository at this point in the history
  • Loading branch information
techthoughts2 committed Oct 12, 2024
1 parent e3a8bee commit c1aa775
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 12 deletions.
8 changes: 8 additions & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [2.22.2]

- Catesta template module changes
- Added PSScriptAnalyzer suppression rule to `MarkdownRepair.ps1`
- Catesta primary module changes
- Addressed bug in `Catesta.build.ps1` where in certain circumstances PSScriptAnalyzer violations were not being properly detected
- Added PSScriptAnalyzer suppression rule to `MarkdownRepair.ps1`

## [2.22.0]

- Catesta template module changes
Expand Down
2 changes: 1 addition & 1 deletion docs/Catesta.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Module Name: Catesta
Module Guid: 6796b193-9013-468a-b022-837749af2d06
Download Help Link: NA
Help Version: 2.22.0
Help Version: 2.22.2
Locale: en-US
---

Expand Down
23 changes: 15 additions & 8 deletions src/Catesta.build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -165,22 +165,29 @@ Add-BuildTask Clean {
Add-BuildTask Analyze {

$scriptAnalyzerParams = @{
# Path = $script:ModuleSourcePath
Setting = 'PSScriptAnalyzerSettings.psd1'
# Recurse = $true
# Verbose = $false
}

$filesToAnalyze = Get-ChildItem -Path $script:ModuleSourcePath -Exclude "PSVault.Extension*" -Recurse
$filesToAnalyze = Get-ChildItem -Path $script:ModuleSourcePath -Exclude "PSVault.Extension*" -Recurse -File | Where-Object { $_.FullName -notlike '*\Tests\*' }
$fileCount = $filesToAnalyze.Count

Write-Build White (' Performing Module ScriptAnalyzer checks for {0} files...' -f $fileCount)
Import-Module -Name PSScriptAnalyzer -ErrorAction Stop

$scriptAnalyzerResults = New-Object System.Collections.Generic.List[Microsoft.Windows.PowerShell.ScriptAnalyzer.Generic.DiagnosticRecord]

Write-Build White ' Performing Module ScriptAnalyzer checks...'
foreach ($file in $filesToAnalyze) {
$scriptAnalyzerResults = Invoke-ScriptAnalyzer @scriptAnalyzerParams -Path $file.FullName
$results = $null
$results = Invoke-ScriptAnalyzer @scriptAnalyzerParams -Path $file.FullName
if ($results) {
foreach ($result in $results) {
$scriptAnalyzerResults.Add($result)
}
}
}
# $scriptAnalyzerResults = Invoke-ScriptAnalyzer @scriptAnalyzerParams

if ($scriptAnalyzerResults) {
$scriptAnalyzerResults | Format-Table
$scriptAnalyzerResults | Format-List *
throw ' One or more PSScriptAnalyzer errors/warnings where found.'
}
else {
Expand Down
2 changes: 1 addition & 1 deletion src/Catesta/Catesta.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
RootModule = 'Catesta.psm1'

# Version number of this module.
ModuleVersion = '2.22.0'
ModuleVersion = '2.22.2'

# Supported PSEditions
# CompatiblePSEditions = @()
Expand Down
2 changes: 1 addition & 1 deletion src/Catesta/Resources/Module/plasterManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<metadata>
<name>Catesta</name>
<id>258a61ba-566b-4c3a-8230-c2b6861a1a8d</id>
<version>2.22.0</version>
<version>2.22.2</version>
<title>Catesta</title>
<description>Scaffolds a new PowerShell module project</description>
<author>Jake Morrison</author>
Expand Down
1 change: 1 addition & 0 deletions src/Catesta/Resources/Module/src/MarkdownRepair.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#>

function Remove-CommonParameterFromMarkdown {
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseShouldProcessForStateChangingFunctions', '')]
<#
.SYNOPSIS
Remove a PlatyPS generated parameter block.
Expand Down
2 changes: 1 addition & 1 deletion src/Catesta/Resources/Vault/plasterManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<metadata>
<name>Catesta</name>
<id>d531e058-52b8-4dd2-8162-01c95d1eb8f7</id>
<version>2.22.0</version>
<version>2.22.2</version>
<title>Catesta</title>
<description>Scaffolds a new PowerShell SecretManagement extension vault module project</description>
<author>Jake Morrison</author>
Expand Down
1 change: 1 addition & 0 deletions src/MarkdownRepair.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#>

function Remove-CommonParameterFromMarkdown {
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseShouldProcessForStateChangingFunctions', '')]
<#
.SYNOPSIS
Remove a PlatyPS generated parameter block.
Expand Down

0 comments on commit c1aa775

Please sign in to comment.