PowerShell / vscode-powershell

Provides PowerShell language and debugging support for Visual Studio Code

Home Page:https://marketplace.visualstudio.com/items/ms-vscode.PowerShell

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

PssaCmdletAnalysisEngine fails with "Errors found while formatting file" and no additional data

cythrault opened this issue · comments

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

Document formatting fails on seemingly random pieces of code. Even if diagnostics enabled, there no meaningful errors aside from the extension logging these:

[Warn  - 2:02:18 PM] Microsoft.PowerShell.EditorServices.Services.Analysis.PssaCmdletAnalysisEngine: Errors found while formatting file: 
     | 

PowerShell Version

[13:45:31] C:\PSWorkspace> $PSVersionTable; $Host

Name                           Value
----                           -----
PSVersion                      7.4.1
PSEdition                      Core
GitCommitId                    7.4.1
OS                             Microsoft Windows 10.0.19045
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Name             : ConsoleHost
Version          : 7.4.1
InstanceId       : 5a656068-bb14-4483-9d6a-3245151ecaa0
UI               : System.Management.Automation.Internal.Host.InternalHostUserInterface
CurrentCulture   : en-GB
CurrentUICulture : en-GB
PrivateData      : Microsoft.PowerShell.ConsoleHost+ConsoleColorProxy
DebuggerEnabled  : True
IsRunspacePushed : False
Runspace         : System.Management.Automation.Runspaces.LocalRunspace

Visual Studio Code Version

[14:08:06] C:\PSWorkspace>  code --version 
1.87.0
019f4d1419fbc8219a181fab7892ebccf7ee29a2
x64

Extension Version

[14:08:29] C:\PSWorkspace> code --list-extensions --show-versions | Select-String powershell

ms-vscode.powershell@2024.0.0

Steps to Reproduce

The psm1 file failing to be formatted contains >4000 lines of code which execute without a problem. However, I'm unable to locate the appropriate code that might trigger this issue.

Visuals

No response

Logs

u

@andyleejordan there was a new PSScriptAnalyzer release, there may be a regression with that. @cythrault do you have the newer psscriptanalyzer installed separate from the extension?

@andyleejordan there was a new PSScriptAnalyzer release, there may be a regression with that. @cythrault do you have the newer psscriptanalyzer installed separate from the extension?

@JustinGrote Negative:
PS D:\PSWorkspace> Get-InstalledModule PSScriptAnalyzer
Get-Package: No match was found for the specified search criteria and module names 'PSScriptAnalyzer'.

And the only PSScriptAnalyzer module folder I see on that system is v1.21.0 which is under $env:USERPROFILE\.vscode\extensions\ms-vscode.powershell-2024.0.0\modules\PSScriptAnalyzer

@cythrault if you run Invoke-Scriptanalyzer on your script separately does it work fine? As you said it's a 4k+ line module so you may be running into an edge case with ScriptAnalyzer. VSCode is mostly a passthrough to that functionality so the issue would most likely be fixed there if anywhere instead of this repo.
https://github.com/PowerShell/PSScriptAnalyzer

I cannot reproduce without a copy of your module, I'm not seeing any issues ATM.

This issue has been labeled as needing feedback and has not had any activity a week. It has been closed for housekeeping purposes.