fix lint issues
continuous-integration/drone/push Build is passing Details
continuous-integration/drone/pr Build is passing Details

This commit is contained in:
OCram85 2022-07-15 10:47:21 +02:00
parent 12f84144eb
commit fc6c35a4c4
8 changed files with 66 additions and 18 deletions

View File

@ -1,9 +1,4 @@
function New-CSCertAttribute {
[Diagnostics.CodeAnalysis.SuppressMessageAttribute(
'PSUseShouldProcessForStateChangingFunctions',
'',
Justification = 'Returns a new object and does not change data'
)]
<#
.SYNOPSIS
Creates required data for a certificate signing request.
@ -51,6 +46,11 @@ function New-CSCertAttribute {
#>
[CmdletBinding()]
[Diagnostics.CodeAnalysis.SuppressMessageAttribute(
'PSUseShouldProcessForStateChangingFunctions',
'',
Justification = 'Returns a new object and does not change data'
)]
[OutputType('PSCredentialStore.Certificate.Attribute')]
param (
[Parameter(Mandatory = $true)]

View File

@ -61,6 +61,11 @@ function Connect-To {
#>
[CmdletBinding(DefaultParameterSetName = 'Private')]
[Diagnostics.CodeAnalysis.SuppressMessageAttribute(
'PSAvoidGlobalVars',
'',
Justification = 'Wrapping existing var from WinSCP module.'
)]
param (
[Parameter(Mandatory = $true, ParameterSetName = 'Shared')]
[Parameter(Mandatory = $true, ParameterSetName = 'Private')]
@ -114,7 +119,9 @@ function Connect-To {
# First check the optional modules
if (-not (Resolve-Dependency -Name $Type)) {
Write-Error -Message ("Could not resolve the optional dependencies defined for {0}" -f $Type) -ErrorAction 'Stop'
Write-Error -Message (
"Could not resolve the optional dependencies defined for {0}" -f $Type
) -ErrorAction 'Stop'
}
switch ($Type) {
"VMware" {
@ -146,7 +153,10 @@ function Connect-To {
catch {
$MessageParams = @{
Message = "Unable to look up credential store item for RemoteHost {0}/Identifier {1}!" -f $RemoteHost, $Identifier
Message = (
"Unable to look up credential store item for RemoteHost " +
("{0}/Identifier {1}!" -f $RemoteHost, $Identifier)
)
ErrorAction = 'Stop'
}
Write-Error @MessageParams
@ -198,7 +208,10 @@ function Connect-To {
if (!($WinSCPSession.Opened)) {
# Check the connection state and find out if the session is still open.
$MessageParams = @{
Message = "Connection to {0} using Type {1} was established. But now it seems to be lost!" -f $RemoteHost, $Type
Message = (
("Connection to {0} using Type {1} " -f $RemoteHost, $Type) +
"was established. But now it seems to be lost!"
)
ErrorAction = 'Stop'
}
Write-Error @MessageParams
@ -261,6 +274,8 @@ function Connect-To {
ErrorAction = 'Stop'
}
$Global:PSExchangeRemote = New-PSSession @ConnectionParams
# ScriptAnalyzer issue (unused var) workaround.
$null = $Global:PSExchangeRemote
}
catch {
# Write a error message to the log.
@ -300,7 +315,9 @@ function Connect-To {
try {
$SessionOption = New-WinSCPSessionOption @WinSCPSessionParams
$Global:WinSCPSession = New-WinSCPSession -SessionOption $SessionOption
Write-Verbose -Message ("SCP Connection established with {0}" -f $Global:WinSCPSession.Hostname)
Write-Verbose -Message (
"SCP Connection established with {0}" -f $Global:WinSCPSession.Hostname
)
}
catch {
# Write a error message to the log.
@ -314,7 +331,10 @@ function Connect-To {
if (!($WinSCPSession.Opened)) {
# Check the connection state and find out if the session is still open.
$MessageParams = @{
Message = "Connection to {0} using Type {1} was established. But now it seems to be lost!" -f $RemoteHost, $Type
Message = (
("Connection to {0} using Type {1} was established. " -f $RemoteHost, $Type) +
"But now it seems to be lost!"
)
ErrorAction = 'Stop'
}
Write-Error @MessageParams

View File

@ -52,6 +52,11 @@ function Disconnect-From {
#>
[CmdletBinding()]
[Diagnostics.CodeAnalysis.SuppressMessageAttribute(
'PSAvoidGlobalVars',
'',
Justification = 'Wrapping existing global vars from external modules'
)]
param (
[Parameter(Mandatory = $true)]
[string]$RemoteHost,
@ -133,7 +138,9 @@ function Disconnect-From {
"NetAppFAS" {
try {
$MessageParams = @{
Message = "Setting {0} to `$null, which will disconnect NetAppFAS" -f $Global:CurrentNcController
Message = (
"Setting {0} to `$null, which will disconnect NetAppFAS" -f $Global:CurrentNcController
)
ErrorAction = 'Continue'
}
Write-Verbose @MessageParams

View File

@ -40,6 +40,11 @@ function Remove-CredentialStoreItem {
#>
[CmdletBinding(DefaultParameterSetName = 'Private')]
[Diagnostics.CodeAnalysis.SuppressMessageAttribute(
'PSUseShouldProcessForStateChangingFunctions',
'',
Justification = 'Removes data from existing store.'
)]
param (
[Parameter(Mandatory = $true, ParameterSetName = 'Private')]
[Parameter(Mandatory = $true, ParameterSetName = 'Shared')]
@ -90,7 +95,7 @@ function Remove-CredentialStoreItem {
$CredentialName = $RemoteHost
}
if (Get-Member -InputObject $CSContent -Name $CredentialName -Membertype NoteProperty) {
if (Get-Member -InputObject $CSContent -Name $CredentialName -MemberType NoteProperty) {
# We need to use the .NET Method because there is no easier way in PowerShell.
$CSContent.PSObject.Properties.Remove($CredentialName)
ConvertTo-Json -InputObject $CSContent -Depth 5 | Out-File -FilePath $Path -Encoding utf8

View File

@ -33,7 +33,11 @@ function Get-DefaultCredentialStorePath {
if ($IsMacOS) {
return Join-Path -Path '/var/opt' -ChildPath 'PSCredentialStore/CredentialStore.json'
}
elseif (($isWindows) -or ($PSVersionTable.PSVersion.Major -lt 6) -or ($PSVersionTable.PSEdition -eq 'Desktop')) {
elseif (
($isWindows) -or
($PSVersionTable.PSVersion.Major -lt 6) -or
($PSVersionTable.PSEdition -eq 'Desktop')
) {
return Join-Path -Path $env:ProgramData -ChildPath 'PSCredentialStore/CredentialStore.json'
}
}
@ -44,7 +48,11 @@ function Get-DefaultCredentialStorePath {
if ($IsMacOS) {
return Join-Path -Path $Env:HOME -ChildPath 'CredentialStore.json'
}
elseif (($isWindows) -or ($PSVersionTable.PSVersion.Major -lt 6) -or ($PSVersionTable.PSEdition -eq 'Desktop')) {
elseif (
($isWindows) -or
($PSVersionTable.PSVersion.Major -lt 6) -or
($PSVersionTable.PSEdition -eq 'Desktop')
) {
return Join-Path -Path $env:AppData -ChildPath 'CredentialStore.json'
}
}

View File

@ -5,8 +5,8 @@ function Import-CSPfxCertificate {
.DESCRIPTION
This function is used to import existing pfx certificate files. The Import-PFXCertificate cmdlet from the
PKI module imports the certificate into a deprecated store. Thus you can't read the private key afterwards or
using it for decrypting data.
PKI module imports the certificate into a deprecated store. Thus you can't read the private key afterwards
or using it for decrypting data.
.PARAMETER Path
Path to an existing *.pfx certificate file.
@ -83,7 +83,9 @@ function Import-CSPfxCertificate {
)
if (Test-CSPfxCertificate -Thumbprint $cert.Thumbprint) {
Write-Warning -Message ('The certificate with thumbprint {0} is already present!' -f $cert.Thumbprint)
Write-Warning -Message (
'The certificate with thumbprint {0} is already present!' -f $cert.Thumbprint
)
}
else {
$Store.Add($cert)

View File

@ -36,7 +36,9 @@ function Resolve-Dependency {
.EXAMPLE
If (-not (Resolve-Dependency -Name 'VMware')) {
Write-Error -Message ("Could not resolve the optional dependencies defined for {0}" -f 'VMware') -ErrorAction 'Stop'
Write-Error -Message (
"Could not resolve the optional dependencies defined for {0}" -f 'VMware'
) -ErrorAction 'Stop'
}
#>
@ -60,6 +62,8 @@ function Resolve-Dependency {
}
process {
# ScriptAnalyzer issue workaround (unused var)
$null = $Name
$SelectedDependency = $Dependency.Optional | Where-Object { $_.Name -match $Name }
# return true if there is no dependency defined
if ($null -eq $SelectedDependency) {

View File

@ -64,6 +64,8 @@ function Test-CSPfxCertificate {
}
process {
# Script analyzer issue (unused var) workaround
$null = $Thumbprint
$Cert = $Store.Certificates | Where-Object { $_.Thumbprint -eq $Thumbprint }
if ($null -eq $Cert) {