Skip to content

Set the powerShell.scriptAnalysis.settingsFilePath setting to a default for auto-discoverability #2190

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
TylerLeonhardt opened this issue Sep 19, 2019 · 9 comments · Fixed by #2484
Assignees
Labels
Area-Script Analysis Issue-Enhancement A feature request (enhancement).

Comments

@TylerLeonhardt
Copy link
Member

Summary of the new feature

Most linter tools automatically pick up the config file from the root of your workspace. We should do the same.

I'd like to set the default value for powerShell.scriptAnalysis.settingsFilePath to PSScriptAnalyzerSettings.psd1 which means that if there is a PSScriptAnalyzerSettings.psd1 in the root of the workspace, we will automatically use it.

If a user doesn't want this, they can opt out via:

"powerShell.scriptAnalysis.settingsFilePath":""

but PSSA integration is one of our flagship features so we should streamline the experience.

Also, the user can still set it to something else if they so choose.

Proposed technical implementation details (optional)

Setting the default value for powerShell.scriptAnalysis.settingsFilePath to PSScriptAnalyzerSettings.psd1. Making sure our code is resilient if the file doesn't exist.

I need to hear what @bergmeister has to say about this. Among anyone else :)

@rjmholt
Copy link
Contributor

rjmholt commented Sep 19, 2019

This also aligns with Invoke-ScriptAnalyzer's behaviour, which is to search for the same file in a project root by default.

@bergmeister
Copy link
Contributor

Good idea, never thought of it but totally makes sense. You already said that we'll have to check for existence of the file first, I don't anticipate any issues with the rest.

What would be nice as well is to tell the user if there was an error because starting with PSSA 1.18.3 error messages due to invalid syntax in the setting files are actually useful/actionable.

@rjmholt
Copy link
Contributor

rjmholt commented Nov 12, 2019

Implementing this will fix #2287.

@bergmeister
Copy link
Contributor

bergmeister commented Nov 13, 2019

I've looked into trying to auto-discover the default PSSA settings file a few weeks ago but the straightforward implementation somehow did not work end to end as I expected so it seems to be more complex than I originally thought it would be, therefore I've parked it for the moment

@ghost ghost added the Needs: Maintainer Attention Maintainer attention needed! label Nov 13, 2019
@TylerLeonhardt
Copy link
Member Author

It might be worth waiting for PowerShell/PowerShellEditorServices#1078 as that's deleting a ton of code.

@TylerLeonhardt TylerLeonhardt removed the Needs: Maintainer Attention Maintainer attention needed! label Nov 13, 2019
@bgelens
Copy link

bgelens commented Jan 29, 2020

I have an issue with relative path with version 2020.1.0 preview extension on mac with PSv7rc2

I can only use the full path. Relative won't work. I tried both ./PSScriptAnalyzerSettings.psd1 and PSScriptAnalyzerSettings.psd1. The file is in the root of the folder I opened.

From pses output:

[Error - 8:20:05 PM] Cannot find the path '/Users/bengelens/OneDrive/Documenten/Projecten/demo/file:/Users/bengelens/OneDrive/Documenten/Projecten/demo/PSScriptAnalyzerSettings.psd1'.

Note file: in the middle

When specifying the full path, it works correctly.

@ghost ghost added the Needs: Maintainer Attention Maintainer attention needed! label Jan 29, 2020
@bergmeister
Copy link
Contributor

@bgelens Your scenario should definitely work (at least I know that it does on Windows). I vaguely remember there was a temporary issue with it at the end of the year 2019 but that should've been fixed now. Is it working for you at least with the 'stable' extension or a previous version of the preview extension? Also, can you try to do this on a normal folder and not OneDrive, maybe that's the cullprit.

@bgelens
Copy link

bgelens commented Jan 30, 2020

@bergmeister

Normal folder preview extension:

 Cannot find the path '/Users/bengelens/Desktop/demo/file:/Users/bengelens/Desktop/demo/PSScriptAnalyzerSettings.psd1'.

When switching to the stable extension, it works fine. So the issue is with preview only

@SydneyhSmith SydneyhSmith removed the Needs: Maintainer Attention Maintainer attention needed! label Jan 30, 2020
@TylerLeonhardt
Copy link
Member Author

@bgelens your issue was fixed in PowerShell/PowerShellEditorServices#1161 - a fix I made a few days after the last release... so it's pending a release. Sorry about that. [System.Uri] is a nightmare in a cross-plat world lol

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).
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants