Skip to content

Commit 57e12aa

Browse files
committed
Fixing PSAvoidUsingDoubleQuotesForConstantString analyzer violations
1 parent ce45674 commit 57e12aa

File tree

33 files changed

+254
-253
lines changed

33 files changed

+254
-253
lines changed

AddPathToPSModulePath.ps1

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@ Param
1717
$Path = "$PSScriptRoot\"
1818
)
1919

20-
$paths = [Environment]::GetEnvironmentVariable("PSModulePath", "Machine").Split(";", [System.StringSplitOptions]::RemoveEmptyEntries)
20+
$paths = [Environment]::GetEnvironmentVariable('PSModulePath', 'Machine').Split(';', [System.StringSplitOptions]::RemoveEmptyEntries)
2121

2222
if (!$paths.Contains($Path))
2323
{
24-
[System.Environment]::SetEnvironmentVariable("PSModulePath", [string]::Join(";", $paths + $Path), "Machine")
24+
[System.Environment]::SetEnvironmentVariable('PSModulePath', [string]::Join(';', $paths + $Path), 'Machine')
2525
Write-Verbose "The path `"$Path`" was successfully added to the PSModulePath environment variable."
2626
}
2727
else

Azure/Copy-ToAzureDevelopmentStorage/Copy-ToAzureDevelopmentStorage.psm1

+4-4
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,15 @@ function Copy-ToAzureDevelopmentStorage
1818
[OutputType([int])]
1919
Param
2020
(
21-
[Parameter(Mandatory = $true, HelpMessage = "The path to the folder to copy the content from to the Development Storage. The first level of subfolders will be handled as Storage Containers.")]
21+
[Parameter(Mandatory = $true, HelpMessage = 'The path to the folder to copy the content from to the Development Storage. The first level of subfolders will be handled as Storage Containers.')]
2222
[string] $Path
2323
)
2424

2525
Process
2626
{
2727
if (!(Test-Path $Path))
2828
{
29-
throw ("The path specified is not valid!")
29+
throw ('The path specified is not valid!')
3030
}
3131

3232
Start-AzureStorageEmulator | Out-Null
@@ -38,14 +38,14 @@ function Copy-ToAzureDevelopmentStorage
3838

3939
foreach ($folder in Get-ChildItem $Path | Where-Object { $PSItem.PSIsContainer })
4040
{
41-
if ($null -eq $containers -or $containers.Count -eq 0 -or !($containers | Select-Object -ExpandProperty "Name").Contains($folder.Name))
41+
if ($null -eq $containers -or $containers.Count -eq 0 -or !($containers | Select-Object -ExpandProperty 'Name').Contains($folder.Name))
4242
{
4343
New-AzStorageContainer -Context $storageContext -Name $folder.Name -Permission Blob
4444
}
4545

4646
foreach ($subFolder in Get-ChildItem $folder.FullName)
4747
{
48-
Get-AzStorageContainer -Context $storageContext -Name $folder.Name | Get-AzStorageBlob | Where-Object { $PSItem.Name.StartsWith($folder.Name + "\") } | Remove-AzStorageBlob
48+
Get-AzStorageContainer -Context $storageContext -Name $folder.Name | Get-AzStorageBlob | Where-Object { $PSItem.Name.StartsWith($folder.Name + '\') } | Remove-AzStorageBlob
4949
}
5050

5151
foreach ($file in Get-ChildItem $folder.FullName -Recurse -File)

Azure/Start-AzureStorageEmulator/Start-AzureStorageEmulator.psm1

+3-3
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,17 @@
1313
function Start-AzureStorageEmulator
1414
{
1515
[CmdletBinding()]
16-
[Alias("saase")]
16+
[Alias('saase')]
1717
[OutputType([bool])]
1818
Param ()
1919

2020
Process
2121
{
22-
$path = "C:\Program Files (x86)\Microsoft SDKs\Azure\Storage Emulator\AzureStorageEmulator.exe"
22+
$path = 'C:\Program Files (x86)\Microsoft SDKs\Azure\Storage Emulator\AzureStorageEmulator.exe'
2323

2424
if (Get-Process | Where-Object { $PSItem.Path -eq $path })
2525
{
26-
Write-Warning ("The Azure Storage Emulator is already running.")
26+
Write-Warning ('The Azure Storage Emulator is already running.')
2727
}
2828
elseif (!(Test-Path $path))
2929
{

Azure/Start-Azurite/Start-Azurite.psm1

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
function Start-Azurite
1414
{
1515
[CmdletBinding()]
16-
[Alias("saazu")]
16+
[Alias('saazu')]
1717
Param ()
1818

1919
Process

DotNetCLI/Get-VisualStudioProjectNuGetPackage/Get-VisualStudioProjectNuGetPackage.psm1

+4-4
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@ function Get-VisualStudioProjectNuGetPackage
2222
[CmdletBinding()]
2323
param
2424
(
25-
[Parameter(Mandatory = $true, HelpMessage = "The absolute path to a Visual Studio project file.")]
25+
[Parameter(Mandatory = $true, HelpMessage = 'The absolute path to a Visual Studio project file.')]
2626
[string]
2727
$Path,
2828

29-
[Parameter(HelpMessage = "Wildcard-enabled expression to filter package names.")]
29+
[Parameter(HelpMessage = 'Wildcard-enabled expression to filter package names.')]
3030
[string]
3131
$PackageNameFilter
3232
)
@@ -44,9 +44,9 @@ function Get-VisualStudioProjectNuGetPackage
4444
# output in JSON or similar format. If so, this code should be replaced to use that and e.g. ConvertFrom-Json.
4545
$packageList = dotnet list $pathItem.FullName package |
4646
ForEach-Object { $PSItem.Trim() } |
47-
Where-Object { $PSItem.StartsWith(">") } |
47+
Where-Object { $PSItem.StartsWith('>') } |
4848
ForEach-Object {
49-
($Name, $Requested, $Resolved) = $PSItem.TrimStart(">").Split(" ", [System.StringSplitOptions]::RemoveEmptyEntries)
49+
($Name, $Requested, $Resolved) = $PSItem.TrimStart('>').Split(' ', [System.StringSplitOptions]::RemoveEmptyEntries)
5050

5151
New-Object PSObject -Property @{ Name = $Name; Requested = $Requested; Resolved = $Resolved }
5252
}

DotNetCLI/Get-VisualStudioSolutionProjectPath/Get-VisualStudioSolutionProjectPath.psm1

+3-3
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
if ($pathItem -is [System.IO.DirectoryInfo])
2525
{
26-
$solution = Get-ChildItem -Path $Path | Where-Object { $PSItem.Name -like "*.sln" }
26+
$solution = Get-ChildItem -Path $Path | Where-Object { $PSItem.Name -like '*.sln' }
2727

2828
if ($solution -isnot [System.IO.FileInfo])
2929
{
@@ -43,7 +43,7 @@
4343
}
4444
elseif ($pathItem -is [System.IO.FileInfo])
4545
{
46-
if (-not $pathItem.Extension -eq ".sln")
46+
if (-not $pathItem.Extension -eq '.sln')
4747
{
4848
throw "The file found at `"$Path`" is not a Visual Studio solution!"
4949
}
@@ -55,7 +55,7 @@
5555
throw "Unexpected result when trying to examine the `"$Path`" path!"
5656
}
5757

58-
$projectPaths = dotnet sln "$($solution.FullName)" list | Where-Object { $PSItem -like "*.csproj" }
58+
$projectPaths = dotnet sln "$($solution.FullName)" list | Where-Object { $PSItem -like '*.csproj' }
5959
$projects = $projectPaths | ForEach-Object { Get-Item "$($solution.DirectoryName)\$_" }
6060

6161
if (-not [string]::IsNullOrEmpty($ProjectNameFilter))

DotNetCLI/Update-DotNetDevelopmentCertificateHttps/Update-DotNetDevelopmentCertificateHttps.psm1

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
function Update-DotNetDevelopmentCertificateHttps
22
{
3-
[Diagnostics.CodeAnalysis.SuppressMessage("PSUseSingularNouns", Justification = "`"HTTPS`" is not plural.")]
3+
[Diagnostics.CodeAnalysis.SuppressMessage('PSUseSingularNouns', Justification = '"HTTPS" is not plural.')]
44
[CmdletBinding()]
55
param()
66

DotNetCLI/Update-VisualStudioSolutionNuGetPackages/Update-VisualStudioSolutionNuGetPackages.psm1

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
function Update-VisualStudioSolutionNuGetPackages
22
{
3-
[Diagnostics.CodeAnalysis.SuppressMessage("PSUseSingularNouns", Justification = "Not applicable here.")]
3+
[Diagnostics.CodeAnalysis.SuppressMessage('PSUseSingularNouns', Justification = 'Not applicable here.')]
44
[CmdletBinding()]
55
param
66
(

Ftp/Get-FtpDirectory/Get-FtpDirectory.psm1

+8-8
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,21 @@ function Get-FtpDirectory
1414
(
1515
[Parameter(Mandatory = $true,
1616
ValueFromPipelineByPropertyName = $true,
17-
HelpMessage = "Specify a valid FTP server path to a folder.")]
17+
HelpMessage = 'Specify a valid FTP server path to a folder.')]
1818
[string] $Url,
1919

2020
[Parameter(Mandatory = $true,
2121
ValueFromPipelineByPropertyName = $true,
22-
HelpMessage = "Provide username.")]
22+
HelpMessage = 'Provide username.')]
2323
[string] $User,
2424

2525
[Parameter(Mandatory = $true,
2626
ValueFromPipelineByPropertyName = $true,
27-
HelpMessage = "Provide password in SecureString format.")]
27+
HelpMessage = 'Provide password in SecureString format.')]
2828
[securestring] $Password,
2929

3030
[Parameter(Mandatory = $true,
31-
HelpMessage = "Specify path to local folder to download.")]
31+
HelpMessage = 'Specify path to local folder to download.')]
3232
[string] $LocalPath
3333
)
3434

@@ -64,12 +64,12 @@ function Get-FtpDirectory
6464

6565
foreach ($line in $lines)
6666
{
67-
$tokens = $line.Split(" ", 9, [StringSplitOptions]::RemoveEmptyEntries)
67+
$tokens = $line.Split(' ', 9, [StringSplitOptions]::RemoveEmptyEntries)
6868
$name = $tokens[3]
69-
$isDirectory = $tokens[2] -eq "<DIR>"
69+
$isDirectory = $tokens[2] -eq '<DIR>'
7070

7171
$localFilePath = Join-Path $LocalPath $name
72-
$fileUrl = ($Url + "/" + $name)
72+
$fileUrl = ($Url + '/' + $name)
7373

7474
if ($isDirectory)
7575
{
@@ -79,7 +79,7 @@ function Get-FtpDirectory
7979
New-Item $localFilePath -Type directory | Out-Null
8080
}
8181

82-
Get-FtpDirectory -Url ($fileUrl + "/") -User $User -Password $Password -LocalPath $localFilePath
82+
Get-FtpDirectory -Url ($fileUrl + '/') -User $User -Password $Password -LocalPath $localFilePath
8383
}
8484
else
8585
{

Ftp/Get-FtpFiles/Get-FtpFiles.psm1

+3-3
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ function FileTransferProgress
3636
function Get-FtpFile
3737
{
3838
[CmdletBinding()]
39-
[Alias("gff")]
39+
[Alias('gff')]
4040
Param
4141
(
4242
# The path of a folder that contains "WinSCPnet.dll" and "WinSCPnet.exe".
@@ -65,8 +65,8 @@ function Get-FtpFile
6565
{
6666
[Reflection.Assembly]::LoadFrom("\\$WinSCPPath\WinSCPnet.dll") | Out-Null
6767

68-
$script:lastFileName = ""
69-
$script:lastFileProgress = ""
68+
$script:lastFileName = ''
69+
$script:lastFileProgress = ''
7070
}
7171
Process
7272
{

Ftp/New-FtpDirectory/New-FtpDirectory.psm1

+16-16
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,21 @@ function New-FtpDirectory
1414
(
1515
[Parameter(Mandatory = $true,
1616
ValueFromPipelineByPropertyName = $true,
17-
HelpMessage = "Specify a valid FTP server path to a folder.")]
17+
HelpMessage = 'Specify a valid FTP server path to a folder.')]
1818
[string] $Url,
1919

2020
[Parameter(Mandatory = $true,
2121
ValueFromPipelineByPropertyName = $true,
22-
HelpMessage = "Provide username.")]
22+
HelpMessage = 'Provide username.')]
2323
[string] $User,
2424

2525
[Parameter(Mandatory = $true,
2626
ValueFromPipelineByPropertyName = $true,
27-
HelpMessage = "Provide password in SecureString format.")]
27+
HelpMessage = 'Provide password in SecureString format.')]
2828
[securestring] $Password,
2929

3030
[Parameter(Mandatory = $true,
31-
HelpMessage = "Specify path to local folder to upload.")]
31+
HelpMessage = 'Specify path to local folder to upload.')]
3232
[string] $LocalFolderPath
3333
)
3434

@@ -49,7 +49,7 @@ function New-FtpDirectory
4949
$makeDirectory.EnableSsl = $true
5050
$makeDirectory.GetResponse()
5151

52-
Write-Verbose "Folder created successfully:" $Url
52+
Write-Verbose 'Folder created successfully:' $Url
5353
}
5454
catch [Net.WebException]
5555
{
@@ -61,20 +61,20 @@ function New-FtpDirectory
6161
$checkDirectory.EnableSsl = $true
6262
$checkDirectory.GetResponse()
6363

64-
Write-Warning "Folder already exists:" $Url
64+
Write-Warning 'Folder already exists:' $Url
6565
}
6666
catch [Net.WebException]
6767
{
68-
throw "Other error encountered during folder creation."
68+
throw 'Other error encountered during folder creation.'
6969
}
7070
}
7171

7272
# Create subdirectories.
7373
foreach ($folder in $srcFolders)
7474
{
75-
$srcFolderPath = $LocalFolderPath -replace "\\", "\\" -replace "\:", "\:"
75+
$srcFolderPath = $LocalFolderPath -replace '\\', '\\' -replace '\:', '\:'
7676
$destinationFolder = $folder.Fullname -replace $srcFolderPath, $Url
77-
$destinationFolder = $destinationFolder -replace "\\", "/"
77+
$destinationFolder = $destinationFolder -replace '\\', '/'
7878

7979
try
8080
{
@@ -100,7 +100,7 @@ function New-FtpDirectory
100100
}
101101
catch [Net.WebException]
102102
{
103-
throw "Other error encountered during subfolders creation."
103+
throw 'Other error encountered during subfolders creation.'
104104
}
105105
}
106106
}
@@ -114,9 +114,9 @@ function New-FtpDirectory
114114
foreach ($file in $srcFiles)
115115
{
116116
$srcFullPath = $file.fullname
117-
$srcFilePath = $LocalFolderPath -replace "\\", "\\" -replace "\:", "\:"
117+
$srcFilePath = $LocalFolderPath -replace '\\', '\\' -replace '\:', '\:'
118118
$destinationFile = $srcFullPath -replace $srcFilePath, $Url
119-
$destinationFile = $destinationFile -replace "\\", "/"
119+
$destinationFile = $destinationFile -replace '\\', '/'
120120

121121
$uri = New-Object System.Uri($destinationFile)
122122

@@ -129,18 +129,18 @@ function New-FtpDirectory
129129
try
130130
{
131131
$webclient.UploadFile($uri, $srcFullPath)
132-
Write-Verbose "Upload successful."
132+
Write-Verbose 'Upload successful.'
133133

134134
break
135135
}
136136
catch
137137
{
138138
try
139139
{
140-
Write-Warning "Error caught, trying initializing new webclient object."
140+
Write-Warning 'Error caught, trying initializing new webclient object.'
141141

142142
$errorCount++
143-
Write-Debug "ERROR COUNT:" $errorCount
143+
Write-Debug 'ERROR COUNT:' $errorCount
144144
}
145145
finally
146146
{
@@ -155,7 +155,7 @@ function New-FtpDirectory
155155

156156
if ($errorCount -eq 10)
157157
{
158-
throw "Maximum error count exceeded."
158+
throw 'Maximum error count exceeded.'
159159
}
160160
}
161161
}

Ftp/Remove-FtpDirectory/Remove-FtpDirectory.psm1

+10-10
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,17 @@ function Remove-FtpDirectory
1414
(
1515
[Parameter(Mandatory = $true,
1616
ValueFromPipelineByPropertyName = $true,
17-
HelpMessage = "Specify a valid FTP server path to a folder.")]
17+
HelpMessage = 'Specify a valid FTP server path to a folder.')]
1818
[string] $Url,
1919

2020
[Parameter(Mandatory = $true,
2121
ValueFromPipelineByPropertyName = $true,
22-
HelpMessage = "Provide username.")]
22+
HelpMessage = 'Provide username.')]
2323
[string] $User,
2424

2525
[Parameter(Mandatory = $true,
2626
ValueFromPipelineByPropertyName = $true,
27-
HelpMessage = "Provide password in SecureString format.")]
27+
HelpMessage = 'Provide password in SecureString format.')]
2828
[securestring] $Password
2929
)
3030

@@ -60,15 +60,15 @@ function Remove-FtpDirectory
6060

6161
foreach ($line in $lines)
6262
{
63-
$tokens = $line.Split(" ", 9, [StringSplitOptions]::RemoveEmptyEntries)
63+
$tokens = $line.Split(' ', 9, [StringSplitOptions]::RemoveEmptyEntries)
6464
$name = $tokens[3]
65-
$isDirectory = $tokens[2] -eq "<DIR>"
65+
$isDirectory = $tokens[2] -eq '<DIR>'
6666

67-
$fileUrl = ($Url + "/" + $name)
67+
$fileUrl = ($Url + '/' + $name)
6868

6969
if ($isDirectory)
7070
{
71-
Remove-FtpDirectory -Url ($fileUrl + "/") -User $User -Password $Password
71+
Remove-FtpDirectory -Url ($fileUrl + '/') -User $User -Password $Password
7272
}
7373
else
7474
{
@@ -86,15 +86,15 @@ function Remove-FtpDirectory
8686
if ($deleteResponse)
8787
{
8888
$deleteResponse.Dispose()
89-
Write-Verbose "Delete response disposed."
89+
Write-Verbose 'Delete response disposed.'
9090
}
9191
}
9292
}
9393
}
9494

9595
try
9696
{
97-
Write-Verbose "Deleting folder."
97+
Write-Verbose 'Deleting folder.'
9898

9999
$deleteRequest = [Net.WebRequest]::Create($Url)
100100
$deleteRequest.Credentials = $credentials
@@ -106,7 +106,7 @@ function Remove-FtpDirectory
106106
{
107107
if ($deleteResponse)
108108
{
109-
Write-Verbose "Delete response disposed."
109+
Write-Verbose 'Delete response disposed.'
110110
$deleteResponse.Dispose()
111111
}
112112
}

0 commit comments

Comments
 (0)