GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||
GeezerVison is showing github.com — Actionabilize errors from incorrect settings files by travisclagrone · Pull Request #1263 · PowerShell/PSScriptAnalyzer Conversation
|
|
The first commit adds only research comments, and the last commit reverts them. However, I have chosen to leave the commits in for documentary purposes in the history. In particular, I imagine that further work either refactoring or extending this code region might benefit from them. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
First of all thanks for making the effort and improvement. I agree that throwing a terminating error here is the right decision. One minor comment but hold off from addressing it at the moment, I will add more reviewers so that they can decide as well. But otherwise, it looks good to me. In the future we might enhance it to emit DiagnosticRecords of type ParserError in lower levels so that people get highlighting in VS Code but your change to improve the command line experience is good as a first improvement.
The red Ubuntu build can be ignored for the moment, this is a problem with the recent image update in AppVeyor that is also affecting the main development branch.
With the recently merged PR #1250, which improves the exceptions that are reported, this gives us now nice messages like this James Truher (@JamesWTruher) :-)
Invoke-ScriptAnalyzer -ScriptDefinition gci -Settings @{foo='bar'}
Invoke-ScriptAnalyzer : foo is not a valid key in the settings hashtable. Valid keys are ExcludeRules, IncludeRules and Severity.
At line:1 char:2
+ Invoke-ScriptAnalyzer -ScriptDefinition gci -Settings @{foo='bar'}
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidData: (System.Collections.Hashtable:Hashtable) [Invoke-ScriptAnalyzer], InvalidDataException
+ FullyQualifiedErrorId : InvalidSettingsData,Microsoft.Windows.PowerShell.ScriptAnalyzer.Commands.InvokeScriptAnalyzerCommand
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I think James Truher (@JamesWTruher) was working on something in this space as well.
Ideally this should actually throw an AggregateException and tell you all of the configuration problems (that's the general pattern for a parser, so you can fix as much as possible).
But I think this is a step in the right direction.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Christoph Bergmeister (@bergmeister) agreed re integration for other contexts; ideally rather than a parse error the error should be something PSES can catch and then display as a notification. We should discuss what the best design is there, especially in terms of revising the hosting model (James Truher (@JamesWTruher)) |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Thanks, looks good to me, just one minor cleanup nit
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| using System.Collections.ObjectModel; | ||
| using System.Diagnostics.CodeAnalysis; | ||
| using System.Globalization; | ||
| using System.IO; |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Nit: With the last commit, this using statement is not needed any more.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
using System.IO; does appear to be required for pre-existing unqualified references to the type System.IO.InvalidDataException.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Not any more after the last commit that removed this type. I pushed a last commit to fix this and do some minor cleanup and make the format consistent to the solution and merge then after this.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
… settings file load invocation
…nvoke-ScriptAnalyzer -Settings' results in an exception
…ScriptAnalyzer -Settings` results in an exception
…rounding settings file load invocation" This reverts commit 3bfd45b.
…processing the argument of `Invoke-ScriptAnalyzer -Settings` results in an exception
1fc5c77 to
88ab1ec
Compare
This reverts commit 88ab1ec. `using System.IO` is required in Engine\Settings.cs after all. The main use is for pre-existing unqualified references to the type InvalidDataException.
…name and make error record arguments consistent with usage in other parts of the solution.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
Errors from incorrect settings files are not actionable
There was an error while loading. Please reload this page.