-
Notifications
You must be signed in to change notification settings - Fork 384
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
Add rule for missing process block when command supports the pipeline #1373
Conversation
Awesome, let me know if you need help with writing the test. Is the code for the rule already working and ready for review? In case you encounter issues with the build we are there for you as well, the first goal would be to have at least 1 of the 4 build environments green, I'm happy to help getting the edge cases for other environments right as I've got a bit of experience in it already. |
@bergmeister yes the code appears to be working as-is - I just didn’t get a chance to write tests yet. I’ll take a look later today to see if there are any compatibility quirks that trip me up, but I think this one is pretty straight-forward. Thanks! |
…nglyTypedCsFileForResx.ps1 Rules'
Because you added strings to the |
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 about the code style that we could improve a bit more but the code looks otherwise quite solid already :-)
Have a look at some existing tests and it should not be too hard to write one, otherwise let me know and I can help
@bergmeister thanks for all your input on this! I'm refactoring based on your style suggestions, but after your change in 1ad72e7 I'm getting the error:
I'm sure I'm missing somethings, but don't see exactly what it is. |
Ok, sorry for that, I pushed another commit where I used Visual Studio for the auto-generation, maybe the script doesn't work any more. In the long term view we plan to move to .Net Core 3, which would handle that for us. |
I also noticed you had a big diff on the whole resx file, so I reverted the change and re-added your entries for a clean diff in that file. Out of interest, which editor are you using? |
using visual studio 2019 - think that was a line endings or encoding issue? |
I think this is ready to merge now. Let me know what you think about the refactor, tests and the help doc. Again, thanks for your help with this - I'm new to the project so getting started was a bit of a hurdle. EDIT: No it's not - I forgot a test case and it broke some other tests. I'll fix it up straight away. |
Ok, I think that’s all set now. My test are passing, but I’m still seeing several test failures. One test appears to be counting rules, so naturally that failed. 12 others seem to have returned a null reference exception. Not sure about that yet. I’ll leave this be for today and look at it again tomorrow. |
@bergmeister Well I think I got most of the tests working, but now there is one failing in the Helper tests:
I'm not sure I can troubleshoot that one, otherwise I think this is ready. Thanks! |
That sounds great. You can ignore that one test about runspaces, it is a known, new flaky test, for which we already have a fix in another PR. Thanks so far, I'll try to review the recent changes in the next days |
@bergmeister Should I be worried that the rule doesn't highlight the parameter in VSCode: I removed any installations I had of the module and copied the built module into my module path. It appears to be highlighting the existing variable rule, but not mine. The rule does trip on |
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 am happy, just a few ideas for tweaking the user facing messages. I assigned 2 members of the PS team for the final sign off
Yeah, not sure what's going on there, but it must be git because it looked fine until I pushed! I'm ok with the suggestions, so I am using Github's code review commit to apply these. |
Co-Authored-By: Christoph Bergmeister [MVP] <[email protected]>
Co-Authored-By: Christoph Bergmeister [MVP] <[email protected]>
Co-Authored-By: Christoph Bergmeister [MVP] <[email protected]>
Co-Authored-By: Robert Holt <[email protected]>
Co-Authored-By: Robert Holt <[email protected]>
@rjmholt @bergmeister just checking in to see if there is anything else you need from me on this PR? Thanks! |
From my side it is a yes. If Rob is happy as well with the recent changes that he requested, then I'd merge it. |
LGTM! |
* avoidoverwritingbuiltincmdlets first draft * rough draft avoidoverwritingcmdlets working * Added tests, fixed typos, changed default PowerShellVersion behavior * updates a/p rjmholt * remove unneeded else * avoidoverwritingbuiltincmdlets first draft * rough draft avoidoverwritingcmdlets working * Added tests, fixed typos, changed default PowerShellVersion behavior * updates a/p rjmholt * remove unneeded else * updated readme - want tests to run in CI again * prevent adding duplicate keys * return an empty list instead of null * update rule count * fixing pwsh not present issue in test * fixing a ps 4 test broke a linux test * better PS core detection * Add reference to UseCompatibleCmdlets doc * changes a/p Chris * Update RuleDocumentation/AvoidOverwritingBuiltInCmdlets.md Co-Authored-By: Christoph Bergmeister [MVP] <[email protected]> * trimmed doc and changed functiondefinitions detection to be more performant * retrigger-ci after fix was made in master * retrigger-ci due to sporadic test failure * Update number of expected rules due to recent merge of PR #1373
PR Summary
This PR adds a rule to warn when a function has at least one parameter that supports the pipeline but doesn't implement a process block. This feature is detailed in issue #1368.
I still need to add tests and docs, but wanted to get this out there to take any feedback on overall approach or general details such as rule naming, messages, etc.
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.