Repository navigation
ScriptAnalyzer is missing a lot of warnings #2280
Copy link
Copy link
Closed
Labels
Issue-BugA bug to squash.A bug to squash.Needs: TriageMaintainer attention needed!Maintainer attention needed!
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 PowerShell Editor Services itself and does not reproduce in a standalone PowerShell instance, and is not an issue with my editor.
- I have verified that I am using the latest version of PowerShell Editor Services.
- If this is a security issue, I have read the security issue reporting guidance.
Summary
I've been using PSScriptAnalyzer (1.25.0) from the PowerShell command line on an individual file like:
Invoke-ScriptAnalyzer .\foo.ps1
I'm getting warnings for rules: PSAvoidShouldContinueWithoutForce, PSAvoidUsingInvokeExpression, PSReviewUnusedParameter, PSShouldProcess and PSUseSingularNouns
Now, I've been running PowerShellEditorServices LSP (latest version) in my editor on that same file but I'm not getting any of these warnings reported. And yes the LSP is working because it reported other types of errors/warnings normally.
My question is, is it possible to modify the default settings or rules included? Or is it a bug somewhere?
PowerShell Version
C:\Users\grolongo> $PSVersionTable
Name Value
---- -----
PSVersion 7.5.5
PSEdition Core
GitCommitId 7.5.5
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.0Editor Version
Emacs version: 30.2 (latest stable)
LSP client setup is really simple:
(use-package powershell :ensure t :demand t)
then to install the LSP server:
M-x powershell-install-langserver
Eglot connects successfully.PowerShell Editor Services Version
ModuleVersion = '4.5.0'Steps to Reproduce
- create a ps1 file and write a simple function with a plural noun like
Install-Programs - run PSScriptAnalyzer:
Invoke-ScriptAnalyzer .\foo.ps1->PSUseSingularNounswarning reported - open the same file in your editor with LSP on -> no warning reported
Visuals
No response
Logs
No response
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
Issue-BugA bug to squash.A bug to squash.Needs: TriageMaintainer attention needed!Maintainer attention needed!
Activity
andyleejordan commentedon Apr 21, 2026
Yes it is possible and to my recollection, the default config in PSES is not the same as the default config running PSSA by itself. Why it was designed that way, I don't know. How to configure it over LSP in Emacs...I'd have to dig but I think you can find it in another issue.
andyleejordan commentedon Apr 21, 2026
I dug and couldn't find it. It's a matter of setting the server's PSSA config options via Eglot.
grolongo commentedon Apr 22, 2026
Thank you Andy,
I tried to change the rules tweaking the configuration files in
c:/Users/grolongo/AppData/Roaming/.emacs.d/.cache/powershell/PSScriptAnalyzer/1.25.0/but that didn't work.
If I can manage to do that from Eglot that would be even better. I'll reply back if I can find the solution.
grolongo commentedon Apr 22, 2026
Alright, managed to find it with Eglot. So for reference, if someone wants to change what rules to apply or not for any project, do it like this (Emacs only):
Create a ps data file, call it
PSScriptAnalyzerSettings.psd1for example, and inside it add your rules:Then in your
init.el:and voilà!
andyleejordan commentedon Apr 23, 2026
That's it! Good work.