-
Notifications
You must be signed in to change notification settings - Fork 382
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
New rule: AvoidOverwritingBuiltInCmdlets #1348
New rule: AvoidOverwritingBuiltInCmdlets #1348
Conversation
It appears that a whole bunch of tests are busted but I'm not sure it's a result of the changes in this PR, however, I haven't dug that deep into them on the assumption that this is already known. |
Please look into the test failures, they are definitely caused by your code as I see a lot of exceptions of type |
If it's just builtin commands, I would imagine the old profiles have the same information (a list of those commands). Depending on the full compatibility profiles would be a resource drain. In a case like this, since you only need a list, either using those old profiles or just storing a list in the rule's code will probably suffice for now. |
Ah but I just saw it's a configuration thing... Hmmm, not sure what the right answer is there, since it's public, so we don't want to break it in future. Those old profiles aren't about to get any updates as far as I know, so it's not ideal to depend on them publicly. It might be that it's time to solve the question of how to specify a PowerShell platform nicely... |
The reason why those old command data files contain less cmdlets is because of the way they are generated here: https://github.com/PowerShell/PSScriptAnalyzer/blob/master/Utils/New-CommandDataFile.ps1 |
1d46ca4
to
aeea36c
Compare
07825ce
to
6fb31b6
Compare
Obviously I've got more to do here, like dig into those test failures, but I wanted to get some of these changes back to you folks to discuss. |
I took a shot at fixing the test errors that were definitely my fault 😂, contrary to my original thought. The four remaining tests that fail are for the |
@thomasrayner Thanks, I will look at the PR this weekend. You are right, the 4 failing Ubuntu tests are a new integration failure on master caused by the last merged PR #1331 (@rjmholt please fix them please). The sporadically failing test around runspace disposal, you can ignore as well (the maximum number needs increasing). bool runningInPowerShellCore = false;
#if CORECLR
runningInPowerShellCore = true;
#endif |
Well, I'm not sure how I missed that, but I'm looking forward to changing it 😁 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just some minor comments to be discussed but otherwise I'm pretty happy with it and I've done a quick performance test and can say that this does not seem to have an impact on PSSA performance despite it being enabled by default
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some more minor comments but after that I'm happy to sign it off. What do you think @rjmholt
Co-Authored-By: Christoph Bergmeister [MVP] <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm happy, what about you @rjmholt ?
I'm happy, what about you @rjmholt ? I'd merge it if you're happy. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Still looks good to me, I resolved the merge conflict. The test failures on Ubuntu are new in master as well @rjmholt ... |
PR Summary
Addresses #1023 .
This rule (PSAvoidOverwritingBuiltInCmdlets) looks for
FunctionDefinitionAst
s that have the same name as a cmdlet that comes with PowerShell. This rule leverages the JSON files which contain information on all the cmdlets for PS 3, 4, 5, and 6 (and presumably 7 later) that already ship with PSScriptAnalzyer.I've edited GetScriptAnalyzerRule.tests.ps1 to reflect the addition of this new rule, but suspect that if the other rule I recently created a PR for is merged before this one, that I'll need to edit that test again.
PR Checklist
.cs
,.ps1
and.psm1
files have the correct copyright headerWIP:
to the beginning of the title and remove the prefix when the PR is ready.