intellij-powershell
intellij-powershell copied to clipboard
How to run PSScriptAnalyzer
I do not seem to get the code inspection using PSScriptAnalyzer to work. PSSA is installed on my machine, but e g when choosing a file in IntelliJ and selecting the "Analyze -> Inspect Code" menu option, I don't get the same result as when running PSSA from the command line (in an example file, I get no errors in IntelliJ, but in PSSA, I get several remarks).
I have likely missed something obvious?
Hi, maintainer of PSScriptanalyzer here 👋🏻
The intellij extension seems to use PowerShellEditorServices, which has a default set of hard-coded rules here.
Therefore, when you run Invoke-ScriptAnalyzer, it runs all the available rules.
You can use a PSScriptAnalyzer settings file if you want to control which rules to run or just run all of them (in this case just put @{} as the content of the file). PowerShellEditorServices supports settings files as well, but I am not sure if the intellij extension provides a way to exposes this API to the user. cc @ant-druha
Yep, IntelliJ has the ability to fetch and run particular inspections by name. We should implement that.
Currently, you only can run all the PSScriptAnalyzer inspections at once: find action Run Inspection by Name and type PSScriptAnalyzer into the name box.
Interestingly, for me it seems to work properly: the Inspect Code runs the same set of inspections, including the PSScriptAnalyzer.
For now, I consider this as working, and will open a new issue on running a particular inspection.