PowerShell / PowerShell/PSScriptAnalyzer
Incorrectly formats an array passed to a parameter when backtick is used to separate parameters
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 2.2k
- Forks
- 414
- Avg merge
- 13h 1m
- Merged PRs (30d)
- 2
Description
Not sure what rule is responsible for this error, so this might have been reported before. 🤔 If so please close.
Steps to reproduce
$scriptDefinition = @'
$testTargetResourceReturnValue = Test-DscParameterState -CurrentValues $getTargetResourceResult `
-DesiredValues $desiredValues `
-ValuesToCheck @(
'LoginName'
'AsymmetricKeyName'
'CertificateName'
'UserType'
) `
-TurnOffTypeChecking
'@
Invoke-Formatter -ScriptDefinition $scriptDefinition
Expected behavior
No formatting change.
$testTargetResourceReturnValue = Test-DscParameterState -CurrentValues $getTargetResourceResult `
-DesiredValues $desiredValues `
-ValuesToCheck @(
'LoginName'
'AsymmetricKeyName'
'CertificateName'
'UserType'
) `
-TurnOffTypeChecking
Actual behavior
Array is wrongly indented.
$testTargetResourceReturnValue = Test-DscParameterState -CurrentValues $getTargetResourceResult `
-DesiredValues $desiredValues `
-ValuesToCheck @(
'LoginName'
'AsymmetricKeyName'
'CertificateName'
'UserType'
) `
-TurnOffTypeChecking
Environment data
$PSVersionTable
Name Value
---- -----
PSVersion 5.1.19041.1
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.19041.1
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
and
Name Value
---- -----
PSVersion 7.0.3
PSEdition Core
GitCommitId 7.0.3
OS Microsoft Windows 10.0.19042
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
(Get-Module -ListAvailable PSScriptAnalyzer).Version | ForEach-Object { $_.ToString() }
1.19.1
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the formatting issue with Invoke-Formatter using the PowerShell script definition shown in the report. Trace how the formatter handles the backtick-separated parameters and the -ValuesToCheck array, then verify that the array indentation matches the expected output without changing other formatting.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- powershell
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 42/100