PowerShell / PowerShell/vscode-powershell
Default completer for `SuppressMessageAttribute` sets invalid parameter value for `checkId`
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 1.9k
- Forks
- 547
- PR merge metrics
- No merged PRs in 30d
Description
Prerequisites
- I have written a descriptive issue title.
- I have searched all open and closed issues to ensure it has not already been reported.
- I have read the troubleshooting guide.
- I am sure this issue is with the extension itself and does not reproduce in a standalone PowerShell instance.
- I have verified that I am using the latest version of Visual Studio Code and the PowerShell extension.
- If this is a security issue, I have read the security issue reporting guidance.
Summary
When adding a SuppressMessageRule using the autosuggest functionality it sets the checkId parameter to $null rather than '' which does not correctly suppress the PSSA rule.
PowerShell Version
┏[MichaelO'Toole][dev]
┖[R:\Development\NinjaGet]> $PSVersionTable
Name Value
---- -----
PSVersion 7.3.5
PSEdition Core
GitCommitId 7.3.5
OS Microsoft Windows 10.0.22621
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
Visual Studio Code Version
┏[MichaelO'Toole][dev]
┖[R:\Development\NinjaGet]> code --version
1.79.2
695af097c7bd098fbf017ce3ac85e09bbc5dda06
x64
Extension Version
┏[MichaelO'Toole][dev]
┖[R:\Development\NinjaGet]> code --list-extensions --show-versions | Select-String powershell
ms-vscode.powershell@2023.6.0
Steps to Reproduce
Create a blank PS function with a verb that can change system state with the PSSUseShouldProcessForStateChangingFunctions rule enabled - add the suppress rule from the auto complete - note that the warning remains.
Alter the second parameter to '' instead of $null and notice suppression works.
Visuals
No response
Logs
No response
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 locating the SuppressMessageAttribute autocomplete definition in the VS Code PowerShell extension and reproduce the completion described in the issue. Trace the generated checkId argument and update the completion so suppression works with the empty-string value rather than $null. Verify the reproduced PSSUseShouldProcessForStateChangingFunctions warning is suppressed afterward.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- powershell, typescript, vscode
- Domain
- developer-experience, tooling
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100