| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
|
Ok, I've spent ages trying to debug this but it doesn't make any sense. The new parameter sets aren't present, but the command is loaded from the asset location, and this only happens in WinPS 5.1... |
Sorry, something went wrong.
|
I finally worked this out. We have a bizarre test that overrides Invoke-ScriptAnalyzer and then calls other tests... Naturally now we have to fix all of that. I've never seen anyone actually call into the theoretically exposed API... |
Sorry, something went wrong.
| WriteToOutput(diagnosticsList); | ||
| if (fix) | ||
| { | ||
| ShouldProcess(path, $"Analyzing and fixing path with Recurse={this.recurse}"); |
There was a problem hiding this comment.
Is this a bug with the original code? If I read this correctly we will take the action no matter what, but ShouldProcess is supposed to notify the user and not take the action in the case of -WhatIf. this code will fix the script even with -WhatIf. I get that it's not as big a deal for just the diagnosis part, but the fix part seems wrong.
Sorry, something went wrong.
There was a problem hiding this comment.
Yeah I saw this and had the same thought. Definitely something we should review. If Christoph Bergmeister (@bergmeister) agrees, I can open an issue to track it so we can fix it beyond this PR.
Sorry, something went wrong.
There was a problem hiding this comment.
This goes back to my very first PR in PSSA, where I added the -Fix switch and since this is an action that changes state, I implemented ShouldProcess for it and declared that on the cmdlet. Since the -Fix parameter is only on the -File parameter set, I did not implement it for the -ScriptDefinition parameter set. Original commit is here: bfa1c54
Therefore I still think it's not really important here, very rarely does one run PSSA where the command would take ages and performing a dry-run would save time. Still happy to have a tracking issue
Sorry, something went wrong.
| public SuppressedRecord(DiagnosticRecord record, IReadOnlyList<RuleSuppression> suppressions) | ||
| { | ||
| Suppression = new ReadOnlyCollection<RuleSuppression>(new List<RuleSuppression>(suppressions)); | ||
| IsSuppressed = true; |
There was a problem hiding this comment.
Could this ever be called with a suppression list count of zero? In that case IsSuppressed really true?
Sorry, something went wrong.
There was a problem hiding this comment.
Very good question. I think the mere wrapping in the SuppressedRecord object classes the diagnostic as suppressed, but I agree that this opens up the possibility of an invalid object, which I dislike... I'm not sure I see a way around this without changing a few things around though, and I'm not sure that's worth it.
Sorry, something went wrong.
There was a problem hiding this comment.
Overall looks good but not sure whether doubling the parameter sets is the right way. This can make the experience more confusing for users and makes maintenance more complicated as well. How about an Enum parameter instead that has a default?
Some good improvements to tests that made some assumptions :-)
Sorry, something went wrong.
So I would prefer an enum parameter, but that would be a breaking change; invocations that previously use -SuppressedOnly will no longer work. In order to keep -SuppressedOnly while also including another parameter that affects suppression output, I think we're forced to split things into parameter sets in some way. The two mutually exclusive switches seemed like a simple approach. An alternative might be putting a more future-proof enum in the other parameter set. |
Sorry, something went wrong.
|
Hmm, didn't realize -SuppressedOnly was an already existing parameter. Having said that, this topic is opinionated and I am sure the other side will argue for param sets with its early validation before actually running the command. Therefore I suggest we let a 3rd person like James Truher (@JamesWTruher) decide on this matter. I am happy with the rest of the PR. |
Sorry, something went wrong.
|
Rob Holt (@rjmholt) Christoph Bergmeister (@bergmeister) i'm generally in favor of adding parameter sets where they make sense and don't over complicate things. In this case we're going from 2 to only 4 so i don't believe it's a higher cognitive load. The benefit with parameter sets is that we can determine behavior via inspection rather than runtime, so tools like vscode provide a better experience. |
Sorry, something went wrong.
|
Christoph Bergmeister (@bergmeister) James Truher (@JamesWTruher) need an approval to merge 🙂 |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
PR Summary
Implements the -IncludeSuppressions parameter, allowing a single Invoke-ScriptAnalyzer invocation to emit all diagnostics including suppressed ones, decorating the suppressed ones accordingly.
Also adds an IsSuppressed property on diagnostics.
/cc t-lipingma
PR Checklist