Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OSOE-482: Enforce parameter splatting instead of backtick in Lombiq.Analyzers.PowerShell #28

Merged
merged 10 commits into from
Dec 20, 2022
22 changes: 11 additions & 11 deletions Ftp/Get-FtpDirectory/Get-FtpDirectory.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,23 @@ function Get-FtpDirectory
[CmdletBinding()]
Param
(
[Parameter(Mandatory=$true,
ValueFromPipelineByPropertyName=$true,
HelpMessage = "Specify a valid FTP server path to a folder.")]
[Parameter(Mandatory = $true,
ValueFromPipelineByPropertyName = $true,
HelpMessage = "Specify a valid FTP server path to a folder.")]
[string] $Url,

[Parameter(Mandatory=$true,
ValueFromPipelineByPropertyName=$true,
HelpMessage = "Provide username.")]
[Parameter(Mandatory = $true,
ValueFromPipelineByPropertyName = $true,
HelpMessage = "Provide username.")]
[string] $User,

[Parameter(Mandatory=$true,
ValueFromPipelineByPropertyName=$true,
HelpMessage = "Provide password in SecureString format.")]
[Parameter(Mandatory = $true,
ValueFromPipelineByPropertyName = $true,
HelpMessage = "Provide password in SecureString format.")]
[securestring] $Password,

[Parameter(Mandatory=$true,
HelpMessage = "Specify path to local folder to download.")]
[Parameter(Mandatory = $true,
HelpMessage = "Specify path to local folder to download.")]
[string] $LocalPath
)

Expand Down
24 changes: 12 additions & 12 deletions Ftp/New-FtpDirectory/New-FtpDirectory.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,23 @@ function New-FtpDirectory
[CmdletBinding()]
Param
(
[Parameter(Mandatory=$true,
ValueFromPipelineByPropertyName=$true,
HelpMessage = "Specify a valid FTP server path to a folder.")]
[Parameter(Mandatory = $true,
ValueFromPipelineByPropertyName = $true,
HelpMessage = "Specify a valid FTP server path to a folder.")]
[string] $Url,

[Parameter(Mandatory=$true,
ValueFromPipelineByPropertyName=$true,
HelpMessage = "Provide username.")]
[Parameter(Mandatory = $true,
ValueFromPipelineByPropertyName = $true,
HelpMessage = "Provide username.")]
[string] $User,

[Parameter(Mandatory=$true,
ValueFromPipelineByPropertyName=$true,
HelpMessage = "Provide password in SecureString format.")]
[Parameter(Mandatory = $true,
ValueFromPipelineByPropertyName = $true,
HelpMessage = "Provide password in SecureString format.")]
[securestring] $Password,

[Parameter(Mandatory=$true,
HelpMessage = "Specify path to local folder to upload.")]
[Parameter(Mandatory = $true,
HelpMessage = "Specify path to local folder to upload.")]
[string] $LocalFolderPath
)

Expand All @@ -44,7 +44,7 @@ function New-FtpDirectory
try
{
$makeDirectory = [System.Net.WebRequest]::Create($Url)
$makeDirectory.Credentials = $credentials
$makeDirectory.Credentials = $credentials
$makeDirectory.Method = [System.Net.WebRequestMethods+FTP]::MakeDirectory
$makeDirectory.EnableSsl = $true
$makeDirectory.GetResponse()
Expand Down
18 changes: 9 additions & 9 deletions Ftp/Remove-FtpDirectory/Remove-FtpDirectory.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,19 @@ function Remove-FtpDirectory
[CmdletBinding()]
Param
(
[Parameter(Mandatory=$true,
ValueFromPipelineByPropertyName=$true,
HelpMessage = "Specify a valid FTP server path to a folder.")]
[Parameter(Mandatory = $true,
ValueFromPipelineByPropertyName = $true,
HelpMessage = "Specify a valid FTP server path to a folder.")]
[string] $Url,

[Parameter(Mandatory=$true,
ValueFromPipelineByPropertyName=$true,
HelpMessage = "Provide username.")]
[Parameter(Mandatory = $true,
ValueFromPipelineByPropertyName = $true,
HelpMessage = "Provide username.")]
[string] $User,

[Parameter(Mandatory=$true,
ValueFromPipelineByPropertyName=$true,
HelpMessage = "Provide password in SecureString format.")]
[Parameter(Mandatory = $true,
ValueFromPipelineByPropertyName = $true,
HelpMessage = "Provide password in SecureString format.")]
[securestring] $Password
)

Expand Down
26 changes: 13 additions & 13 deletions Ftp/Rename-FtpDirectory/Rename-FtpDirectory.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -12,28 +12,28 @@ function Rename-FtpDirectory
[CmdletBinding()]
Param
(
[Parameter(Mandatory=$true,
ValueFromPipelineByPropertyName=$true,
HelpMessage = "Specify a valid FTP server path to a folder that contains the directory which
[Parameter(Mandatory = $true,
ValueFromPipelineByPropertyName = $true,
HelpMessage = "Specify a valid FTP server path to a folder that contains the directory which
needs to be renamed.")]
[string] $Url,

[Parameter(Mandatory=$true,
ValueFromPipelineByPropertyName=$true,
HelpMessage = "Provide username.")]
[Parameter(Mandatory = $true,
ValueFromPipelineByPropertyName = $true,
HelpMessage = "Provide username.")]
[string] $User,

[Parameter(Mandatory=$true,
ValueFromPipelineByPropertyName=$true,
HelpMessage = "Provide password in SecureString format.")]
[Parameter(Mandatory = $true,
ValueFromPipelineByPropertyName = $true,
HelpMessage = "Provide password in SecureString format.")]
[securestring] $Password,

[Parameter(Mandatory=$true,
HelpMessage = "Specify folder to rename.")]
[Parameter(Mandatory = $true,
HelpMessage = "Specify folder to rename.")]
[string] $SourceFolder,

[Parameter(Mandatory=$true,
HelpMessage = "Specify new folder name.")]
[Parameter(Mandatory = $true,
HelpMessage = "Specify new folder name.")]
[string] $DestinationFolder
)

Expand Down
2 changes: 1 addition & 1 deletion GitHub/Get-GitHubPullRequest/Get-GitHubPullRequest.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@

$credentialsBase64 = [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes($apiCredentials))
$webRequestParameters = @{
Uri = "https://api.github.com/repos/$repositoryPath/pulls/$pullRequestId"
Uri = "https://api.github.com/repos/$repositoryPath/pulls/$pullRequestId"
Piedone marked this conversation as resolved.
Show resolved Hide resolved
Headers = @{Authorization = "Basic $credentialsBase64" }
}
$pullRequest = Invoke-WebRequest @webRequestParameters -UseBasicParsing | ConvertFrom-Json
Expand Down
30 changes: 15 additions & 15 deletions Orchard1/Restart-Site/Restart-Site.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -43,27 +43,27 @@ function Restart-Site
$whiteListFolders = @("\src\Orchard.Azure\Orchard.Azure.CloudService\Orchard.Azure.WebContent\Bin")

Get-ChildItem -Path ($Path + "\src\") -Recurse |
Where-Object { $PSItem.PSIsContainer -and ( $PSItem.Name -eq "bin" -or $PSItem.Name -eq "obj") } |
ForEach-Object {
if($whiteListFolders.Contains($PSItem.FullName.Substring($Path.Length)))
{
Get-ChildItem -Path $PSItem.FullName -Recurse -File |
ForEach-Object {
if(!$whiteList.Contains($PSItem.FullName.Substring($Path.Length)))
Where-Object { $PSItem.PSIsContainer -and ( $PSItem.Name -eq "bin" -or $PSItem.Name -eq "obj") } |
Piedone marked this conversation as resolved.
Show resolved Hide resolved
ForEach-Object {
if ($whiteListFolders.Contains($PSItem.FullName.Substring($Path.Length)))
{
Get-ChildItem -Path $PSItem.FullName -Recurse -File |
ForEach-Object {
if (!$whiteList.Contains($PSItem.FullName.Substring($Path.Length)))
{
Remove-Item $PSItem.FullName -Force
}
}
}
else
{
Remove-Item $PSItem.FullName -Force
Remove-Item $PSItem.FullName -Recurse -Force
}
}
}
else
{
Remove-Item $PSItem.FullName -Recurse -Force
}
}

# Deleting App_Data
$appDataPath = $Path + "\src\Orchard.Web\App_Data\"
if(Test-Path ($appDataPath))
if (Test-Path ($appDataPath))
{
Remove-Item -Path ($appDataPath) -Recurse -Force
}
Expand Down
10 changes: 8 additions & 2 deletions OrchardCore/Initialize-OrchardCore/Initialize-OrchardCore.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ function Initialize-OrchardCore
(
[string] $Path = (Get-Location).Path,

[Parameter(Mandatory=$true)]
[Parameter(Mandatory = $true)]
[string] $Name,

[string] $ModuleName,
Expand All @@ -22,6 +22,12 @@ function Initialize-OrchardCore

Process
{
Initialize-OrchardCoreSolution -Name $Name -Path $Path -ModuleName $ModuleName -ThemeName $ThemeName -NuGetSource $NuGetSource
Initialize-OrchardCoreSolution @{
Name = $Name
Path = $Path
ModuleName = $ModuleName
ThemeName = $ThemeName
NuGetSource = $NuGetSource
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ function Initialize-OrchardCoreSolution
(
[string] $Path = (Get-Location).Path,

[Parameter(Mandatory=$true)]
[Parameter(Mandatory = $true)]
[string] $Name,

[string] $ModuleName,
Expand Down
30 changes: 15 additions & 15 deletions OrchardCore/Reset-OrchardCoreApp/Reset-OrchardCoreApp.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ function Reset-OrchardCoreApp

if ($LASTEXITCODE -ne 0)
{
pause
Pause

exit $LASTEXITCODE
}
Expand Down Expand Up @@ -187,10 +187,10 @@ function Reset-OrchardCoreApp

$newSqlServerDatabaseParameters = @{
SqlServerName = $SetupDatabaseServerName
DatabaseName = $SetupDatabaseName
ErrorAction = "Stop"
UserName = $SetupDatabaseSqlUser
Password = (ConvertTo-SecureString $SetupDatabaseSqlPassword -AsPlainText -Force)
DatabaseName = $SetupDatabaseName
ErrorAction = "Stop"
UserName = $SetupDatabaseSqlUser
Password = (ConvertTo-SecureString $SetupDatabaseSqlPassword -AsPlainText -Force)
}
if (New-SqlServerDatabase -Force:$Force.IsPresent @newSqlServerDatabaseParameters)
{
Expand Down Expand Up @@ -272,8 +272,8 @@ function Reset-OrchardCoreApp

$processParameters = @{
WorkingDirectory = $WebProjectPath
FilePath = "dotnet"
ArgumentList = @(
FilePath = "dotnet"
ArgumentList = @(
"$($webProjectDllFile.FullName)"
"--urls $applicationUrl"
"--environment $environmentSetting"
Expand Down Expand Up @@ -317,15 +317,15 @@ function Reset-OrchardCoreApp
Write-Verbose "Application started, attempting to run setup!"

$tenantSetupSettings = @{
SiteName = $SetupSiteName
SiteName = $SetupSiteName
DatabaseProvider = $SetupDatabaseProvider
TablePrefix = $SetupDatabaseTablePrefix
TablePrefix = $SetupDatabaseTablePrefix
ConnectionString = $SetupDatabaseConnectionString
RecipeName = $SetupRecipeName
UserName = $SetupUserName
Password = $SetupPassword
Email = $SetupEmail
Name = $SetupTenantName
RecipeName = $SetupRecipeName
UserName = $SetupUserName
Password = $SetupPassword
Email = $SetupEmail
Name = $SetupTenantName
}

$setupRequest = Invoke-WebRequest -Method Post -Uri "$applicationUrl/api/tenants/setup" -Body (ConvertTo-Json($tenantSetupSettings)) -ContentType "application/json" -UseBasicParsing
Expand Down Expand Up @@ -354,7 +354,7 @@ function Reset-OrchardCoreApp

if ($Pause.IsPresent)
{
pause
Pause
}

exit 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ function Import-BacpacToSqlServer
Sort-Object -Descending |
Select-Object -First 1

if ([string]::IsNullOrWhiteSpace($locatedPath)) {
if ([string]::IsNullOrWhiteSpace($locatedPath))
{
$sqlPackageExecutablePath = $defaultSqlPackageExecutablePath
Write-Verbose "SQL Package executable for importing the database found at `"$sqlPackageExecutablePath`"!"
}
Expand Down
18 changes: 9 additions & 9 deletions Utilities/Get-ProcessId/Get-ProcessId.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ function Get-ProcessId
[CmdletBinding()]
Param
(
[Parameter(Mandatory=$true)]
[Parameter(Mandatory = $true)]
[string] $Name,

[string] $CommandLine
Expand All @@ -32,14 +32,14 @@ function Get-ProcessId
if (-not $CommandLine) { return $processes | ForEach-Object { $PSItem.Id } }

[hashtable[]] $processes = $(if ($host.Version.Major -ge 7)
{
$processes | ForEach-Object { @{ Id = $PSItem.Id; CommandLine = $PSItem.CommandLine } }
}
else
{
Get-CimInstance Win32_Process -Filter "name = '${Name}.exe'" |
ForEach-Object { @{ Id = $PSItem.Handle; CommandLine = $PSItem.CommandLine } }
})
{
$processes | ForEach-Object { @{ Id = $PSItem.Id; CommandLine = $PSItem.CommandLine } }
}
else
{
Get-CimInstance Win32_Process -Filter "name = '${Name}.exe'" |
ForEach-Object { @{ Id = $PSItem.Handle; CommandLine = $PSItem.CommandLine } }
})

if (-not [string]::IsNullOrEmpty($CommandLine))
{
Expand Down
6 changes: 3 additions & 3 deletions Utilities/Get-Rekt/Get-Rekt.psm1
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<#
.Synopsis
Throws an exception.
Throws an exception.

.DESCRIPTION
Reks the script execution by throwing a fatal exception.
Reks the script execution by throwing a fatal exception.

.EXAMPLE
Get-Rekt
Get-Rekt
#>


Expand Down
4 changes: 2 additions & 2 deletions Utilities/Reload-Module/Reload-Module.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ function Reload-Module
(
# The path to a folder where PowerShell modules should be reloaded.
[Parameter(ValueFromPipelineByPropertyName = $true,
Position = 0)]
Position = 0)]
$Path = $PSScriptRoot
)
Process
Expand All @@ -39,7 +39,7 @@ function Reload-Module
foreach ($module in $modules)
{
Import-Module $module.FullName -Force
$loadedModules += ,"* $($module.FullName)"
$loadedModules += , "* $($module.FullName)"
}

$header = "Reloading PowerShell modules:";
Expand Down
8 changes: 4 additions & 4 deletions Utilities/Test-Url/Test-Url.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ function Test-Url
[OutputType([bool])]
Param
(
[Parameter(Mandatory=$true,
ValueFromPipelineByPropertyName=$true,
Position=0,
HelpMessage = "Please specify a full URL (including protocol) to ping.")]
[Parameter(Mandatory = $true,
ValueFromPipelineByPropertyName = $true,
Position = 0,
HelpMessage = "Please specify a full URL (including protocol) to ping.")]
[string] $Url,

[Parameter(HelpMessage = "Request timeout in seconds. The default value is 100.")]
Expand Down
Loading