Skip to content

Commit 6ffc477

Browse files
committed
Fix ScriptAnalyzer Failures from updated rules
1 parent 4ccd374 commit 6ffc477

File tree

6 files changed

+26
-29
lines changed

6 files changed

+26
-29
lines changed

Source/Private/CopyReadMe.ps1

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -21,21 +21,22 @@ function CopyReadMe {
2121
# If set, overwrite the existing readme
2222
[Switch]$Force
2323
)
24+
process {
25+
# Copy the readme file as an about_ help file
26+
Write-Verbose "Test for ReadMe: $Pwd\$($ReadMe)"
27+
if ($ReadMe -and (Test-Path $ReadMe -PathType Leaf)) {
28+
# Make sure there's a language path
29+
$LanguagePath = Join-Path $OutputDirectory $Culture
30+
if (!(Test-Path $LanguagePath -PathType Container)) {
31+
$null = New-Item $LanguagePath -Type Directory -Force
32+
}
33+
Write-Verbose "Copy ReadMe to: $LanguagePath"
2434

25-
# Copy the readme file as an about_ help file
26-
Write-Verbose "Test for ReadMe: $Pwd\$($ReadMe)"
27-
if($ReadMe -and (Test-Path $ReadMe -PathType Leaf)) {
28-
# Make sure there's a language path
29-
$LanguagePath = Join-Path $OutputDirectory $Culture
30-
if(!(Test-Path $LanguagePath -PathType Container)) {
31-
$null = New-Item $LanguagePath -Type Directory -Force
32-
}
33-
Write-Verbose "Copy ReadMe to: $LanguagePath"
34-
35-
$about_module = Join-Path $LanguagePath "about_$($ModuleName).help.txt"
36-
if(!(Test-Path $about_module)) {
37-
Write-Verbose "Turn readme into about_module"
38-
Copy-Item -LiteralPath $ReadMe -Destination $about_module
35+
$about_module = Join-Path $LanguagePath "about_$($ModuleName).help.txt"
36+
if (!(Test-Path $about_module)) {
37+
Write-Verbose "Turn readme into about_module"
38+
Copy-Item -LiteralPath $ReadMe -Destination $about_module -Force:$Force
39+
}
3940
}
4041
}
4142
}

Source/Private/GetBuildInfo.ps1

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ function GetBuildInfo {
22
[CmdletBinding()]
33
param(
44
# The path to the Build Manifest Build.psd1
5-
[Parameter()][AllowNull()]
5+
[Parameter()]
6+
[AllowNull()]
67
[string]$BuildManifest,
78

89
# Pass MyInvocation from the Build-Command so we can read parameter values

Source/Private/SetModuleContent.ps1

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ function SetModuleContent {
1010
1111
The goal here is to pretend this is a pipeline, for the sake of memory and file IO
1212
#>
13+
[Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSReviewUnusedParameter", "OutputPath", Justification = "The rule is buggy")]
14+
[Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSReviewUnusedParameter", "Encoding", Justification = "The rule is buggy ")]
1315
[CmdletBinding()]
1416
param(
1517
# Where to write the joined output
@@ -37,7 +39,7 @@ function SetModuleContent {
3739

3840
# Create a proxy command style scriptblock for Set-Content to keep the file handle open
3941
$SetContentCmd = $ExecutionContext.InvokeCommand.GetCommand('Microsoft.PowerShell.Management\Set-Content', [System.Management.Automation.CommandTypes]::Cmdlet)
40-
$SetContent = {& $SetContentCmd -Path $OutputPath -Encoding $Encoding }.GetSteppablePipeline($myInvocation.CommandOrigin)
42+
$SetContent = {& $SetContentCmd -Path $OutputPath -Encoding $Encoding}.GetSteppablePipeline($myInvocation.CommandOrigin)
4143
$SetContent.Begin($true)
4244
}
4345
process {

Source/Public/Build-Module.ps1

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ function Build-Module {
3737
#>
3838
[Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSUseApprovedVerbs", "", Justification="Build is approved now")]
3939
[Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSUseCmdletCorrectly", "")]
40+
[Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSReviewUnusedParameter", "", Justification="Parameter handling is in InitializeBuild")]
4041
[CmdletBinding(DefaultParameterSetName="SemanticVersion")]
4142
[Alias("build")]
4243
param(

Source/Public/Convert-CodeCoverage.ps1

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,7 @@ function Convert-CodeCoverage {
1717
# The output of `Invoke-Pester -Pasthru`
1818
# Note: Pester doesn't apply a custom type name
1919
[Parameter(ValueFromPipeline)]
20-
[PSObject]$InputObject,
21-
22-
# Output paths as short paths, relative to the SourceRoot
23-
[switch]$Relative
20+
[PSObject]$InputObject
2421
)
2522
process {
2623
Push-Location $SourceRoot

Source/Public/Convert-LineNumber.ps1

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,7 @@ function Convert-LineNumber {
2525
[psobject]$InputObject,
2626

2727
[Parameter(ParameterSetName="FromInvocationInfo")]
28-
[switch]$Passthru,
29-
30-
# Output paths as short paths, relative to the SourceRoot
31-
[switch]$Relative
28+
[switch]$Passthru
3229
)
3330
begin {
3431
$filemap = @{}
@@ -42,14 +39,12 @@ function Convert-LineNumber {
4239
if(!(Test-Path $SourceFile)) {
4340
throw "'$SourceFile' does not exist"
4441
}
45-
$PSScriptRoot = Split-Path $SourceFile
46-
47-
Push-Location $PSScriptRoot
42+
Push-Location (Split-Path $SourceFile)
4843
try {
4944
if (!$filemap.ContainsKey($SourceFile)) {
5045
# Note: the new pattern is #Region but the old one was # BEGIN
51-
$matches = Select-String '^(?:#Region|# BEGIN) (?<SourceFile>.*) (?<LineNumber>\d+)?$' -Path $SourceFile
52-
$filemap[$SourceFile] = @($matches.ForEach{
46+
$regions = Select-String '^(?:#Region|# BEGIN) (?<SourceFile>.*) (?<LineNumber>\d+)?$' -Path $SourceFile
47+
$filemap[$SourceFile] = @($regions.ForEach{
5348
[PSCustomObject]@{
5449
PSTypeName = "BuildSourceMapping"
5550
SourceFile = $_.Matches[0].Groups["SourceFile"].Value.Trim("'")

0 commit comments

Comments
 (0)