Skip to content

'Select PSScriptAnalyzer rules' command broke starting with preview extension 2019.11.0 #2422

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
bergmeister opened this issue Jan 16, 2020 · 7 comments
Labels
Area-Script Analysis Issue-Enhancement A feature request (enhancement). Up for Grabs Will shepherd PRs.

Comments

@bergmeister
Copy link
Contributor

bergmeister commented Jan 16, 2020

Using 2020.1.0 but I have seen it before the recent update. Going back to previous release, I found that 2019.9.0 was the last version where it still worked therefore it something in between 2019.9.0 and 2019.11.0 ,which is likely going to be the omnisharp refactoring @TylerLeonhardt

System Details Output

### VSCode version: 1.42.0-insider 33c79d5ad447956814a2a3658029dffb9e28bae6 x64

### VSCode extensions:
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]


### PSES version:

### PowerShell version:

Name                           Value
----                           -----
PSVersion                      7.0.0-rc.1
PSEdition                      Core
GitCommitId                    7.0.0-rc.1
OS                             Microsoft Windows 10.0.18362
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Issue Description

Open a PowerShell file to start the extension.
When selecting the 'Select PSScriptAnalyzer rules' nothing happens

Expected Behaviour

A dropdown menu of PSSA rules should come up.

Actual Behaviour

Nothing happens

@ghost ghost added the Needs: Triage Maintainer attention needed! label Jan 16, 2020
@TylerLeonhardt
Copy link
Member

I kinda removed it on purpose. Or rather, I didn't add it back in when doing the Omnisharp work.

My reasoning was:

  • It felt like an incomplete feature - it's only active during your current session which is a silly limitation and should be backed by a PSScriptAnalyzer settings file somewhere
  • I doubted it was being used...

I really want this kind of integration but I want to do it better. Also, since PSScriptAnalyzer's 2.0 release is in planning and the settings structure could change as a result, I didn't want to jump into this feature before that.

I'd be ok bringing back the experience we already had, but it's not going to be a priority for us right at the moment.

@TylerLeonhardt TylerLeonhardt added Area-Script Analysis Issue-Enhancement A feature request (enhancement). Up for Grabs Will shepherd PRs. and removed Needs: Triage Maintainer attention needed! labels Jan 16, 2020
@bergmeister
Copy link
Contributor Author

Yes, the feature is very incomplete and it's probably going to take a long time until it will be implemented. It also has confused user's at time due to the setting not persisting after vs-code closes. I myself use it only to show the default set of PSSA rules at talks and how to enable all rules.
In this case I'd rather remove the entry in package.json because having a command that does not do anything is even more confusing IMHO

@ghost ghost added the Needs: Maintainer Attention Maintainer attention needed! label Jan 17, 2020
@SydneyhSmith SydneyhSmith removed the Needs: Maintainer Attention Maintainer attention needed! label Jan 17, 2020
@jngibert
Copy link

Looking forward to having 'Select PSScriptAnalyzer Rules' removed from the command palette since it doesn't do anything. Thanks bergmeister for putting a in a pull request!

@ghost ghost added the Needs: Maintainer Attention Maintainer attention needed! label Apr 24, 2020
@TylerLeonhardt TylerLeonhardt removed the Needs: Maintainer Attention Maintainer attention needed! label Apr 26, 2020
@zaphod4254
Copy link

As a brand new user to VS Code and using it for PowerShell (and took me hours of searching to find this item after I discovered it didn't work), what ARE the default rules then? Or where can I find the default config file for them?

I found the information about creating my own PSScriptAnalyzerSettings.psd1 file and I did get that to work, but having a heck of a time getting the rule set I want.

Mainly I want to disable the PSUseDeclaredVarsMoreThanAssignments rule from the default set. so I have this in my .psd1 file:
ExcludeRules = @('PSUseDeclaredVarsMoreThanAssignments')

That seems to work as far as disabling that rule, but then I apparently now have a ton of rules enabled that must not be part of the default set. (I see bunches of new warnings that I didn't see before putting this custom settings file in place.)

I also see this in the example .psd1 file:
IncludeRules = @('PSAvoidDefaultValueSwitchParameter',
'PSMisleadingBacktick',
'PSMissingModuleManifestField',
'PSReservedCmdletChar',
'PSReservedParams',
'PSShouldProcess',
'PSUseApprovedVerbs',
'PSAvoidUsingCmdletAliases',
'PSUseDeclaredVarsMoreThanAssignments')

but I commented it out because I thought it was only an example and I didn't explicitly want to limit to that rule set if the default is more than that. Or IS that the default rule set?

@ghost ghost added the Needs: Maintainer Attention Maintainer attention needed! label Jun 7, 2020
@bergmeister
Copy link
Contributor Author

bergmeister commented Jun 7, 2020

@zaphod4254 The default rules enabled in the extension are defined here, which as you noticed are only a small subset of all rules and your approach using a settings file is correct.
https://github.com/PowerShell/PowerShellEditorServices/blob/512df9ea3968aaf3aa0639d84f1f9b7ef781a454/src/PowerShellEditorServices/Services/Analysis/AnalysisService.cs#L65-L81

@zaphod4254
Copy link

Thank you. The flip question is, how do I know what all of the available rules are, in case I might want to add any of them?

@bergmeister
Copy link
Contributor Author

You can run Get-ScriptAnalyzerRule in the integrated terminal to see all rules. Extensive details about each rules is in the rule documentation here: https://github.com/PowerShell/PSScriptAnalyzer/tree/master/RuleDocumentation

@SydneyhSmith SydneyhSmith removed the Needs: Maintainer Attention Maintainer attention needed! label Jun 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Script Analysis Issue-Enhancement A feature request (enhancement). Up for Grabs Will shepherd PRs.
Projects
None yet
Development

No branches or pull requests

5 participants