-
Notifications
You must be signed in to change notification settings - Fork 395
Fix table to refer to existing md files, add col for Configurable #988
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Fix table to refer to existing md files, add col for Configurable #988
Conversation
The reason why this file got removed in PR #918 because the table of rules was completely out of-date of date and not offering more information than |
By that logic, we wouldn't have this site - https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/enter-pssession?view=powershell-6 I think there is a lot of value in having the documentation be on a website that is linkable (put in blog post, tweets, etc). BTW totally understandable that there is burden to keeping documentation correct & up-to-date. We could write a script that verifies that A) every link is valid and B) spit out a list of undocumented rules. |
If you feel strong about this one, then I have no objections to re-add it but then it needs to be fixed with rules (that were missing), severities being checked and link fixes as per original issue #887 |
I'd like to see it stay. Would you prefer that I add the missing md files in this same PR? Also, looks like you have a build script, I could attempt to implement checking of the rule doc md files in the build script. This is similar to the markdown checking that we do for the PowerShell build. |
There are other missing md files? I thought it was just the table of contents being out of date. |
Yup:
Some of this is just a slightly different named md file (from the rule). I can fix that. But I see no Trap related rules nor any rules on FilePath. Is it just me or does |
OK, I see. I guess the trap rule got deprecated (but not put into the DeprecatedRules folder?), you might need to dig a bit in the history... |
@bergmeister Can you resolve the merge conflict? It won't let me. I think the conflict arises from the deletion of rule doc README.md file that I've modified. |
…nalyzer into rkeithhill/add-list-configurable-rules # Conflicts: # RuleDocumentation/README.md
@rkeithhill I pulled upstreamed changes to your branch and just kept the state of your modified file. I use TortoiseGit btw, which was clever enough to offer me the option of either keeping or deleting the file on the conflict. |
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.
Overall, the changes to the markdown files are OK but they are missing the references to the new rules PSAvoidTrailingWhitespace
, PossibleIncorrectUsageOfRedirectionOperator
, PossibleIncorrectUsageOfAssignmentOperator
and AvoidAssignmentToAutomaticVariable
. I raised the separate issue #1001 to clean up other places where I still see other places referencing the deprecated rules AvoidTrapStatement
, AvoidUninitializedVariable
and AvoidUsingFilePath
in order to keep this PR small and not grow scope.
I took care to adapt our CI scripts to also call your new Documentation
test folder and adapt docs, you don't have to worry about it. When I ran them locally, they did not all pass due to the missing links to the new rules. I can take a look at it and it might be a good exercise anyway.
invoke-pester -Script .\Tests\Documentation\
Executing all tests in '.\Tests\Documentation\'
Executing script C:\Users\cberg\git\rkeithhill_pssa\Tests\Docmentation\RuleDocumentation.tests.ps1
Describing Validate rule documentation files
[-] Every rule must have a rule documentation file 311ms
Expected $null or empty, but got PSPossibleIncorrectUsageOfAssignmentOperator.
28: $rulesDocsDiff | Where-Object SideIndicator -eq "<=" | Foreach-Object InputObject | Should -BeNullOrEmpty
at <ScriptBlock>, C:\Users\cberg\git\rkeithhill_pssa\Tests\Docmentation\RuleDocumentation.tests.ps1: line 28
[-] Every rule documentation file must have a corresponding rule 101ms
Expected $null or empty, but got PSPossibleIncorrectUsageOAssignmentOperator.
31: $rulesDocsDiff | Where-Object SideIndicator -eq "=>" | Foreach-Object InputObject | Should -BeNullOrEmpty
at <ScriptBlock>, C:\Users\cberg\git\rkeithhill_pssa\Tests\Docmentation\RuleDocumentation.tests.ps1: line 31
[-] Every rule must have an entry in the rule documentation README.md file 55ms
Expected $null or empty, but got @('PSAvoidAssignmentToAutomaticVariable', 'PSAvoidTrailingWhitespace', 'PSPossibleIncorrectUsageOfAssignmentOperator', 'PSPossibleIncorrectUsageOfRedirectionOperator').
35: $rulesReadmeDiff | Where-Object SideIndicator -eq "<=" | Foreach-Object InputObject | Should -BeNullOrEmpty
at <ScriptBlock>, C:\Users\cberg\git\rkeithhill_pssa\Tests\Docmentation\RuleDocumentation.tests.ps1: line 35
[+] Every entry in the rule documentation README.md file must correspond to a rule 17ms
[+] Every entry in the rule documentation README.md file must have a valid link to the documentation file 139ms
[+] Every rule name in the rule documentation README.md file must match the documentation file's basename 113ms
Tests completed in 739ms
Tests Passed: 3, Failed: 3, Skipped: 0, Pending: 0, Inconclusive: 0
…s in CI and add to docs
Thanks for fixing the typo! If there's anything you need me to do on this PR, let me know. Looking through your previous comments I didn't see any specific asks. |
What is left is fixing the tests with the new rules (that you previously did not see because the checkout was not up to date) now that the tests fail as expected. |
…nalyzer into rkeithhill/add-list-configurable-rules
…ule in documentation test
@rkeithhill I fixed the table with the new rules now but it seems the tests only pass on PowerShell 5.1, but not PowerShell 4 and 6. |
Maybe we have something like the .NET Core runtime identifiers for these "special" rules. Perhaps BTW I'm just spit-ballin' some ideas here but I would be willing to help implement this. |
|
This commit removes rules that aren't available on these versions
OK, just pushed a commit so that all the doc tests now pass. |
…tializedVariable and AvoidTrapStatement in code and documentation. Fix markdown in PowerShellBestPractices.md and tidy up
…nalyzer into rkeithhill/add-list-configurable-rules
Thanks Keith, I added a note in the 2 rules about their PowerShell version support. If you feel like it, you could add this note to the table but having it at least in the documentation of the rule should be fine. |
Done. I didn't duplicate the text I just added a superscript/footnote to indicate the rule isn't supported everywhere and to see the doc for details. |
That's fine but it seems that adding it broke your tests |
Yeah, just fixed it according to my local tests. :-) |
PR Summary
As per title and cleanup leftovers in code from deprecated rules
AvoidUsingFilePath
,AvoidUninitializedVariable
andAvoidTrapStatement
andPSAvoidUninitializedVariable
Closes #1001
PR Checklist
Note: Tick the boxes below that apply to this pull request by putting an
x
between the square brackets. Please mark anything not applicable to this PRNA
.WIP:
to the beginning of the title and remove the prefix when the PR is readyFix #887