Skip to content

Commit df7e33d

Browse files
Strict mode needs the variables initialized (Azure#19196)
Co-authored-by: Wes Haggard <Wes.Haggard@microsoft.com>
1 parent 564e4c0 commit df7e33d

File tree

3 files changed

+14
-10
lines changed

3 files changed

+14
-10
lines changed

eng/common/scripts/ChangeLog-Operations.ps1

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,14 @@ function Get-ChangeLogEntriesFromContent {
3737
return $null
3838
}
3939

40+
$changelogEntry = $null
41+
$sectionName = $null
4042
$changeLogEntries = [Ordered]@{}
4143
try {
4244
# walk the document, finding where the version specifiers are and creating lists
4345
foreach ($line in $changeLogContent) {
4446
if ($line -match $RELEASE_TITLE_REGEX) {
45-
$changeLogEntry = [pscustomobject]@{
47+
$changeLogEntry = [pscustomobject]@{
4648
ReleaseVersion = $matches["version"]
4749
ReleaseStatus = $matches["releaseStatus"]
4850
ReleaseTitle = "## {0} {1}" -f $matches["version"], $matches["releaseStatus"]
@@ -72,8 +74,8 @@ function Get-ChangeLogEntriesFromContent {
7274
}
7375
}
7476
catch {
75-
Write-Host "Error parsing Changelog."
76-
Write-Host $_.Exception.Message
77+
Write-Error "Error parsing Changelog."
78+
Write-Error $_
7779
}
7880
return $changeLogEntries
7981
}
@@ -208,7 +210,7 @@ function New-ChangeLogEntry {
208210
return $null
209211
}
210212

211-
if (!$Content) {
213+
if (!$Content) {
212214
$Content = @()
213215
$Content += ""
214216
$Content += "### Features Added"
@@ -222,7 +224,7 @@ function New-ChangeLogEntry {
222224
$Content += ""
223225
}
224226

225-
$newChangeLogEntry = [pscustomobject]@{
227+
$newChangeLogEntry = [pscustomobject]@{
226228
ReleaseVersion = $Version
227229
ReleaseStatus = $Status
228230
ReleaseTitle = "## $Version $Status"

eng/common/scripts/Update-ChangeLog.ps1

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ param (
1515
[String]$ChangelogPath,
1616
[String]$ReleaseDate
1717
)
18+
Set-StrictMode -Version 3
1819

1920
. (Join-Path $PSScriptRoot common.ps1)
2021

@@ -39,11 +40,11 @@ if ($ReleaseDate)
3940
exit 1
4041
}
4142
}
42-
elseif ($Unreleased)
43+
elseif ($Unreleased)
4344
{
4445
$ReleaseStatus = $CHANGELOG_UNRELEASED_STATUS
4546
}
46-
else
47+
else
4748
{
4849
$ReleaseStatus = "$(Get-Date -Format $CHANGELOG_DATE_FORMAT)"
4950
$ReleaseStatus = "($ReleaseStatus)"
@@ -61,7 +62,7 @@ if ([string]::IsNullOrEmpty($ChangelogPath))
6162
$ChangelogPath = $pkgProperties.ChangeLogPath
6263
}
6364

64-
if (!(Test-Path $ChangelogPath))
65+
if (!(Test-Path $ChangelogPath))
6566
{
6667
LogError "Changelog path [$ChangelogPath] is invalid."
6768
exit 1
@@ -103,7 +104,7 @@ if ($LatestsSorted[0] -ne $Version) {
103104
LogWarning "Version [$Version] is older than the latestversion [$LatestVersion] in the changelog. Consider using a more recent version."
104105
}
105106

106-
if ($ReplaceLatestEntryTitle)
107+
if ($ReplaceLatestEntryTitle)
107108
{
108109
$newChangeLogEntry = New-ChangeLogEntry -Version $Version -Status $ReleaseStatus -Content $ChangeLogEntries[$LatestVersion].ReleaseContent
109110
LogDebug "Resetting latest entry title to [$($newChangeLogEntry.ReleaseTitle)]"

eng/common/scripts/Verify-ChangeLog.ps1

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,12 @@ param (
66
[string]$ServiceDirectory,
77
[boolean]$ForRelease = $False
88
)
9+
Set-StrictMode -Version 3
910

1011
. (Join-Path $PSScriptRoot common.ps1)
1112

1213
$validChangeLog = $false
13-
if ($ChangeLogLocation -and $VersionString)
14+
if ($ChangeLogLocation -and $VersionString)
1415
{
1516
$validChangeLog = Confirm-ChangeLogEntry -ChangeLogLocation $ChangeLogLocation -VersionString $VersionString -ForRelease $ForRelease
1617
}

0 commit comments

Comments
 (0)