vscode-powershell
vscode-powershell copied to clipboard
Default completer for `SuppressMessageAttribute` sets invalid parameter value for `checkId`
Prerequisites
- [X] I have written a descriptive issue title.
- [X] I have searched all open and closed issues to ensure it has not already been reported.
- [X] I have read the troubleshooting guide.
- [X] I am sure this issue is with the extension itself and does not reproduce in a standalone PowerShell instance.
- [X] I have verified that I am using the latest version of Visual Studio Code and the PowerShell extension.
- [X] 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
[email protected]
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
Assuming this is something that should be fixed I am happy to supply a PR altering: https://github.com/PowerShell/vscode-powershell/blob/0c03eb0fce3a37c3b47bad4f813dee6e47a4ce2e/snippets/PowerShell.json#L253C76-L253C76
I think so, and please do! I love community PRs (and am currently working to fix the CI breakage from a Code Insiders update...).