Skip to content

Use a customized rule (PowerShell script) with PSScriptAnalyzer ? #267

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

Closed
LaurentDardenne opened this issue Aug 27, 2016 · 9 comments
Closed
Labels
Issue-Enhancement A feature request (enhancement).

Comments

@LaurentDardenne
Copy link

Is it possible to use a customized rule (PowerShell script) with PSScriptAnalyzer and VsCode ?
Or is it preferable to use rules written in C# ?

@rkeithhill
Copy link
Contributor

rkeithhill commented Aug 28, 2016

At this point in time, the extension doesn't allow you to specify a path for -CustomRulePath which is how you'd supply your custom rules to Invoke-ScriptAnalyzer. Ditto for -RecurseCustomRulePath. It would be nice if this could be specified in the settings file but right now that only accepts the keys: ExcludeRules, IncludeRules and Severity.

@rkeithhill rkeithhill added the Issue-Enhancement A feature request (enhancement). label Aug 28, 2016
@rkeithhill rkeithhill added this to the Backlog milestone Aug 28, 2016
@daviwil
Copy link
Contributor

daviwil commented Sep 4, 2016

@kapilmb is working on a new way for PSScriptAnalyzer to load settings which should support all of the parameters Invoke-ScriptAnalyzer can take. Hopefully we'll have that in for 0.8.0!

@daviwil daviwil modified the milestones: 0.8.0, Backlog Sep 4, 2016
@daviwil
Copy link
Contributor

daviwil commented Nov 30, 2016

Hey @kapilmb, is it possible to include a custom script-based rule using the new settings file work you did? Do you have an example of that somewhere?

@kapilmb
Copy link

kapilmb commented Dec 2, 2016

As of now, PSSA settings file does not support have the CustomRulePath field. However, after its inclusion in PSSA settings file, VSCode should be able to run custom rules. I will create a issuse PSSA repo to track this issue.

@kapilmb
Copy link

kapilmb commented Dec 2, 2016

here is the issue PowerShell/PSScriptAnalyzer#675

@daviwil daviwil modified the milestones: 0.9.0, 0.8.0 Dec 7, 2016
@daviwil daviwil modified the milestones: 0.11.0, 0.10.0 Mar 14, 2017
@daviwil daviwil modified the milestones: 0.11.0, 0.12.0 Mar 22, 2017
@daviwil daviwil modified the milestones: 0.12.0, Next Feature Update Apr 4, 2017
@daviwil daviwil modified the milestones: April 2017, May 2017 May 8, 2017
@daviwil daviwil modified the milestones: May 2017, July 2017 Jun 1, 2017
@daviwil daviwil removed this from the July 2017 milestone Oct 26, 2017
@daviwil daviwil added this to the Future milestone Oct 26, 2017
@bergmeister
Copy link
Contributor

bergmeister commented Mar 30, 2018

@LaurentDardenne You can specify CustomRules in the settings file and in my comment here I explain how it integrates with other parameters. Currently everything seems to be working, it just isn't very intuitive or well documented.

@LaurentDardenne
Copy link
Author

@bergmeister Thank you :-)
I try this with VSCode.

@LaurentDardenne
Copy link
Author

It works with this prototype :
image
In the file ''C:\Users\Laurent\AppData\Roaming\Code\User\settings.json'' I changed the entry "powershell.scriptAnalysis.settingsPath":".//ScriptAnalyzerSettings.psd1"
I still have a doubt about the location of this parameter file with regard to the files opened in VSCode.

I test again before closing.

@LaurentDardenne
Copy link
Author

We can use the global or local configuration file (settings.json) of the project (Workspace) but once declared the global file, the local file is not taken into account.
This seems exclusive.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Issue-Enhancement A feature request (enhancement).
Projects
None yet
Development

No branches or pull requests

5 participants