Skip to content

Fake warning : $PSNativeCommandUseErrorActionPreference is assigned but never used #4910

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

Closed
1 of 6 tasks
CyberSinh opened this issue Feb 4, 2024 · 7 comments
Closed
1 of 6 tasks
Assignees
Labels
Area-Script Analysis Issue-Bug A bug to squash. Needs: Fix Verification Please verify the fix for us! Resolution-Fixed Will close automatically.

Comments

@CyberSinh
Copy link

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

If I have $PSNativeCommandUseErrorActionPreference = $true in a script, I get the following warning in the Visual Studio Code issue pane: $PSNativeCommandUseErrorActionPreference is assigned but never used.

It is correct to assigned PowerShell preference variables, without explicitly using them in script.

PowerShell Version

Name                           Value
----                           -----
PSVersion                      7.4.1
PSEdition                      Core
GitCommitId                    7.4.1
OS                             Microsoft Windows 10.0.22631
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

1.86.0
05047486b6df5eb8d44b2ecd70ea3bdf775fd937
x64

Extension Version

Steps to Reproduce

Add $PSNativeCommandUseErrorActionPreference = $true in a script to get the fake warning.

Visuals

No response

Logs

No response

@CyberSinh CyberSinh added Issue-Bug A bug to squash. Needs: Triage Maintainer attention needed! labels Feb 4, 2024
@JustinGrote
Copy link
Collaborator

These alerts come from ScriptAnalyzer, so the issue's root would be there, could you reopen the issue there? There's nothing we can do about it here. Thanks!
https://github.com/PowerShell/PSScriptAnalyzer/issues/new?assignees=&labels=&projects=&template=Bug_report.md

https://github.com/PowerShell/PSScriptAnalyzer/blob/5c32f5559d4096ae2dc0ffc0f9d59fcbfbd02ccb/Engine/SpecialVars.cs#L95

@JustinGrote JustinGrote closed this as not planned Won't fix, can't repro, duplicate, stale Feb 4, 2024
@JustinGrote JustinGrote added Area-Script Analysis Resolution-External Will close automatically. and removed Needs: Triage Maintainer attention needed! labels Feb 4, 2024
@CyberSinh
Copy link
Author

Thanks @JustinGrote !
The issue should be fixed in the next PSScriptAnalyzer version:
PowerShell/PSScriptAnalyzer#1954

@JustinGrote
Copy link
Collaborator

Thanks @CyberSinh! I'll reopen this and it will be closed when that version gets integrated into the extension.

CC @andyleejordan

@JustinGrote JustinGrote reopened this Feb 4, 2024
@JustinGrote JustinGrote added the Needs: Maintainer Attention Maintainer attention needed! label Feb 4, 2024
Copy link
Contributor

github-actions bot commented Feb 4, 2024

This issue has been labeled as resolved, please verify the provided fix (or other reason).

@github-actions github-actions bot added Needs: Fix Verification Please verify the fix for us! and removed Needs: Maintainer Attention Maintainer attention needed! labels Feb 4, 2024
@JustinGrote JustinGrote removed Needs: Fix Verification Please verify the fix for us! Resolution-External Will close automatically. labels Feb 5, 2024
@andyleejordan
Copy link
Member

andyleejordan commented Apr 4, 2024

@CyberSinh can you confirm this is fixed in the latest pre-release, v2024.3.2-preview, which as PSScriptAnalyzer 1.22.0 (which is supposed to have that fix)? (Seems to be for me!)

@andyleejordan andyleejordan added the Resolution-Fixed Will close automatically. label Apr 4, 2024
@andyleejordan andyleejordan moved this to In Progress in Flying Fox Apr 4, 2024
Copy link
Contributor

github-actions bot commented Apr 4, 2024

This issue has been labeled as resolved, please verify the provided fix (or other reason).

@github-actions github-actions bot added the Needs: Fix Verification Please verify the fix for us! label Apr 4, 2024
@CyberSinh
Copy link
Author

@andyleejordan I can confirm the fix works great. Thanks!

@github-project-automation github-project-automation bot moved this from In Progress to Done in Flying Fox Apr 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Script Analysis Issue-Bug A bug to squash. Needs: Fix Verification Please verify the fix for us! Resolution-Fixed Will close automatically.
Projects
Status: Done
Development

No branches or pull requests

3 participants