Skip to content

Fix table to refer to existing md files, add col for Configurable #988

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

Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
15 commits
Select commit Hold shift + click to select a range
8a5bebb
Fix table to refer to existing md files, add col for Configurable
rkeithhill May 6, 2018
dbc5157
Remove deprecated rules, rename to match actual rule sans PS prefix
rkeithhill May 14, 2018
d6310ac
Add Pester tests for rule doc files, add back UseSingularNouns.md file
rkeithhill May 16, 2018
7c05763
Add Pester tests for verifying rule doc README.md file
rkeithhill May 16, 2018
df2fb11
Merge branch 'development' of https://github.com/PowerShell/PSScriptA…
bergmeister May 16, 2018
968bea7
fix typo in documentation folder, remove redundant ipmo call new test…
bergmeister May 17, 2018
9172766
Add rules that will be present in 1.17 and fix typo in md file name
bergmeister May 17, 2018
cf6d321
Merge branch 'development' of https://github.com/PowerShell/PSScriptA…
bergmeister May 17, 2018
0f51b79
remove redundant import of PSScriptAnalyzerTestHelper test helper mod…
bergmeister May 17, 2018
cfbd659
Fix doc tests for PS v4 and PS Core
rkeithhill May 19, 2018
5753492
Remove leftovers from deprecated rules AvoidUsingFilePath, AvoidUnini…
bergmeister May 19, 2018
34f7b53
Merge branch 'development' of https://github.com/PowerShell/PSScriptA…
bergmeister May 19, 2018
58a8aee
added remarks about rules not being available in certain powershell v…
bergmeister May 19, 2018
48f6be3
Add superscript/footnote on rules not available everywhere
rkeithhill May 19, 2018
7968653
Update test to strip off the optional superscript markdown
rkeithhill May 19, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 0 additions & 48 deletions RuleDocumentation/AvoidTrapStatement.md

This file was deleted.

34 changes: 0 additions & 34 deletions RuleDocumentation/AvoidUninitializedVariable.md

This file was deleted.

47 changes: 0 additions & 47 deletions RuleDocumentation/AvoidUsingFilePath.md

This file was deleted.

57 changes: 57 additions & 0 deletions RuleDocumentation/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# PSScriptAnalyzer Rules

## Table of Contents

| Rule | Severity | Configurable |
|------|----------------------------------|--------------|
|[AlignAssignmentStatement](./AlignAssignmentStatement.md) | Warning | |
|[AvoidDefaultValueForMandatoryParameter](./AvoidDefaultValueForMandatoryParameter.md) | Warning | |
|[AvoidDefaultValueSwitchParameter](./AvoidDefaultValueSwitchParameter.md) | Warning | |
|[AvoidGlobalAliases](./AvoidGlobalAliases.md) | Warning | |
|[AvoidGlobalFunctions](./AvoidGlobalFunctions.md) | Warning | |
|[AvoidGlobalVars](./AvoidGlobalVars.md) | Warning | |
|[AvoidInvokingEmptyMembers](./AvoidInvokingEmptyMembers.md) | Warning | |
|[AvoidNullOrEmptyHelpMessageAttribute](./AvoidNullOrEmptyHelpMessageAttribute.md) | Warning | |
|[AvoidShouldContinueWithoutForce](./AvoidShouldContinueWithoutForce.md) | Warning | |
|[AvoidUsingCmdletAliases](./AvoidUsingCmdletAliases.md) | Warning | Yes |
|[AvoidUsingComputerNameHardcoded](./AvoidUsingComputerNameHardcoded.md) | Error | |
|[AvoidUsingConvertToSecureStringWithPlainText](./AvoidUsingConvertToSecureStringWithPlainText.md) | Error | |
|[AvoidUsingDeprecatedManifestFields](./AvoidUsingDeprecatedManifestFields.md) | Warning | |
|[AvoidUsingEmptyCatchBlock](./AvoidUsingEmptyCatchBlock.md) | Warning | |
|[AvoidUsingInvokeExpression](./AvoidUsingInvokeExpression.md) | Warning | |
|[AvoidUsingPlainTextForPassword](./AvoidUsingPlainTextForPassword.md) | Warning | |
|[AvoidUsingPositionalParameters](./AvoidUsingPositionalParameters.md) | Warning | |
|[AvoidUsingUsernameAndPasswordParams](./AvoidUsingUsernameAndPasswordParams.md) | Error | |
|[AvoidUsingWMICmdlet](./AvoidUsingWMICmdlet.md) | Warning | |
|[AvoidUsingWriteHost](./AvoidUsingWriteHost.md) | Warning | |
|[DSCDscExamplesPresent](./DSCDscExamplesPresent.md) | Information | |
|[DSCDscTestsPresent](./DSCDscTestsPresent.md) | Information | |
|[DSCReturnCorrectTypesForDSCFunctions](./DSCReturnCorrectTypesForDSCFunctions.md) | Information | |
|[DSCStandardDSCFunctionsInResource](./DSCStandardDSCFunctionsInResource.md) | Error | |
|[DSCUseIdenticalMandatoryParametersForDSC](./DSCUseIdenticalMandatoryParametersForDSC.md) | Error | |
|[DSCUseIdenticalParametersForDSC](./DSCUseIdenticalParametersForDSC.md) | Error | |
|[DSCUseVerboseMessageInDSCResource](./DSCUseVerboseMessageInDSCResource.md) | Error | |
|[MisleadingBacktick](./MisleadingBacktick.md) | Warning | |
|[MissingModuleManifestField](./MissingModuleManifestField.md) | Warning | |
|[PossibleIncorrectComparisonWithNull](./PossibleIncorrectComparisonWithNull.md) | Warning | |
|[ProvideCommentHelp](./ProvideCommentHelp.md) | Information | Yes |
|[ReservedCmdletChar](./ReservedCmdletChar.md) | Error | |
|[ReservedParams](./ReservedParams.md) | Error | |
|[ShouldProcess](./ShouldProcess.md) | Error | |
|[UseApprovedVerbs](./UseApprovedVerbs.md) | Warning | |
|[UseBOMForUnicodeEncodedFile](./UseBOMForUnicodeEncodedFile.md) | Warning | |
|[UseCmdletCorrectly](./UseCmdletCorrectly.md) | Warning | |
|[UseDeclaredVarsMoreThanAssignments](./UseDeclaredVarsMoreThanAssignments.md) | Warning | |
|[UseLiteralInitializerForHashtable](./UseLiteralInitializerForHashtable.md) | Warning | |
|[UseOutputTypeCorrectly](./UseOutputTypeCorrectly.md) | Information | |
|[UsePSCredentialType](./UsePSCredentialType.md) | Warning | |
|[UseShouldProcessForStateChangingFunctions](./UseShouldProcessForStateChangingFunctions.md) | Warning | |
|[UseSingularNouns](./UseSingularNouns.md) | Warning | |
|[UseSupportsShouldProcess](./UseSupportsShouldProcess.md) | Warning | |
|[UseToExportFieldsInManifest](./UseToExportFieldsInManifest.md) | Warning | |
|[UseCompatibleCmdlets](./UseCompatibleCmdlets.md) | Warning | Yes |
|[PlaceOpenBrace](./PlaceOpenBrace.md) | Warning | Yes |
|[PlaceCloseBrace](./PlaceCloseBrace.md) | Warning | Yes |
|[UseConsistentIndentation](./UseConsistentIndentation.md) | Warning | Yes |
|[UseConsistentWhitespace](./UseConsistentWhitespace.md) | Warning | Yes |
|[UseUTF8EncodingForHelpFile](./UseUTF8EncodingForHelpFile.md) | Warning | |
4 changes: 2 additions & 2 deletions RuleDocumentation/UseSingularNouns.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Change plurals to singular.
``` PowerShell
function Get-Files
{
...
...
}
```

Expand All @@ -26,6 +26,6 @@ function Get-Files
``` PowerShell
function Get-File
{
...
...
}
```
56 changes: 56 additions & 0 deletions Tests/Docmentation/RuleDocumentation.tests.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
$directory = Split-Path -Parent $MyInvocation.MyCommand.Path
$testRootDirectory = Split-Path -Parent $directory
$repoRootDirectory = Split-Path -Parent $testRootDirectory
$ruleDocDirectory = Join-Path $repoRootDirectory RuleDocumentation

Import-Module PSScriptAnalyzer
Import-Module (Join-Path $testRootDirectory "PSScriptAnalyzerTestHelper.psm1")

Describe "Validate rule documentation files" {
BeforeAll {
$docs = Get-ChildItem $ruleDocDirectory/*.md -Exclude README.md |
ForEach-Object { "PS" + $_.BaseName} | Sort-Object
$rules = Get-ScriptAnalyzerRule | ForEach-Object RuleName | Sort-Object
$rulesDocsDiff = Compare-Object -ReferenceObject $rules -DifferenceObject $docs -SyncWindow 25

$readmeLinks = @{}
$readmeRules = Get-Content -LiteralPath $ruleDocDirectory/README.md |
Foreach-Object { if ($_ -match '^\s*\|\s*\[([^]]+)\]\(([^)]+)\)\s*\|') {
$ruleName = $matches[1]
$readmeLinks["$ruleName"] = $matches[2]
"PS${ruleName}"
}} |
Sort-Object
$rulesReadmeDiff = Compare-Object -ReferenceObject $rules -DifferenceObject $readmeRules -SyncWindow 25
}

It "Every rule must have a rule documentation file" {
$rulesDocsDiff | Where-Object SideIndicator -eq "<=" | Foreach-Object InputObject | Should -BeNullOrEmpty
}
It "Every rule documentation file must have a corresponding rule" {
$rulesDocsDiff | Where-Object SideIndicator -eq "=>" | Foreach-Object InputObject | Should -BeNullOrEmpty
}

It "Every rule must have an entry in the rule documentation README.md file" {
$rulesReadmeDiff | Where-Object SideIndicator -eq "<=" | Foreach-Object InputObject | Should -BeNullOrEmpty
}
It "Every entry in the rule documentation README.md file must correspond to a rule" {
$rulesReadmeDiff | Where-Object SideIndicator -eq "=>" | Foreach-Object InputObject | Should -BeNullOrEmpty
}

It "Every entry in the rule documentation README.md file must have a valid link to the documentation file" {
foreach ($key in $readmeLinks.Keys) {
$link = $readmeLinks[$key]
$filePath = Join-Path $ruleDocDirectory $link
$filePath | Should -Exist
}
}
It "Every rule name in the rule documentation README.md file must match the documentation file's basename" {
foreach ($key in $readmeLinks.Keys) {
$link = $readmeLinks[$key]
$filePath = Join-Path $ruleDocDirectory $link
$fileName = Split-Path $filePath -Leaf
$fileName | Should -BeExactly "${key}.md"
}
}
}