vscode-powershell: PSAvoidUsingDoubleQuotesForConstantString doesn't work

System Details

System Details Output

### VSCode version: 1.53.2 622cb03f7e070a9670c94bae1a45d78d7181fbd4 x64

### VSCode extensions:
bradlc.vscode-tailwindcss@0.5.9
dbaeumer.vscode-eslint@2.1.14
ecmel.vscode-html-css@1.10.2
esbenp.prettier-vscode@5.9.2
ms-azuretools.vscode-docker@1.10.0
ms-vscode-remote.remote-containers@0.158.0
ms-vscode.cpptools@1.2.1
ms-vscode.powershell@2020.6.0
ms-vscode.vscode-typescript-tslint-plugin@1.3.3
ms-vsliveshare.vsliveshare@1.0.3784
octref.vetur@0.32.0
platformio.platformio-ide@2.2.1


### PSES version: 2.2.0.0

### PowerShell version:

Name                           Value
----                           -----
PSVersion                      7.1.2
PSEdition                      Core
GitCommitId                    7.1.2
OS                             Darwin 20.3.0 Darwin Kernel Version 20.3.0: Thu Jan 21 00:07:06 PST 2021; root:xnu-7195.81.3~1/RELEASE_X86_64
Platform                       Unix
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Issue Description

I am experiencing a problem with PSAvoidUsingDoubleQuotesForConstantString not working.

Expected Behaviour

It should print

RuleName                            Severity     ScriptName Line  Message
--------                            --------     ---------- ----  -------
PSAvoidUsingDoubleQuotesForConstant Information  Test.ps1   1     Use single quotes when a string is constant.
String

Actual Behaviour

No problem is reported.

Also, running:

Invoke-ScriptAnalyzer -Path Test.ps1 -Settings PSScriptAnalyzerSettings.psd1

or

Invoke-ScriptAnalyzer -Path Test.ps1 -Settings PSScriptAnalyzerSettings.psd1 -Severity Information

doesn’t print anything.

Attached Logs

Here are the files: 1614203961.zip.

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 17

Most upvoted comments

But I completely restarted Visual Studio Code before. Shouldn’t that have been enough?

After you installed the new module in iTerm, a reload of the Integrated Console will pick that up. That’s the difference.

Also, running gmo PSScriptAnalyzer doesn’t print anything now. Do you know why?

The module won’t be loaded until you import it or autoload it by running a command from it. Running Invoke-ScriptAnalyzer autoloaded it, so then gmo succeeded.

I ran the Invoke-ScriptAnalyzer and then gmo PSScriptAnalyzer again and now it does print

ModuleType Version    PreRelease Name                                ExportedCommands
---------- -------    ---------- ----                                ----------------
Script     1.19.1                PSScriptAnalyzer                    {Get-ScriptAnalyzerRule, Invoke-Formatter, Invoke-ScriptAnalyzer}

And yes, the problem is now reported, thanks for the help!

This newer version of PSScriptAnalyzer will also be shipped by default in the next release of the extension too (it shipped in the new preview yesterday)