Skip to content

ScriptAnalyzer is missing a lot of warnings #2280

@grolongo

Description

@grolongo

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.0

Editor 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

  1. create a ps1 file and write a simple function with a plural noun like Install-Programs
  2. run PSScriptAnalyzer: Invoke-ScriptAnalyzer .\foo.ps1 -> PSUseSingularNouns warning reported
  3. open the same file in your editor with LSP on -> no warning reported

Visuals

No response

Logs

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Issue-BugA bug to squash.Needs: TriageMaintainer attention needed!

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions