Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
Prev Previous commit
more edits for docs compliance
  • Loading branch information
sdwheeler committed Oct 18, 2021
commit 534c9cc0fd5baaaf14cb19acfa1ed412c4ce8c33
1 change: 1 addition & 0 deletions docs/Rules/AvoidMultipleTypeAttributes.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
---
description: Avoid multiple type specifiers on parameters.
ms.custom: PSSA v1.20.0
ms.date: 10/18/2021
ms.topic: reference
Expand Down
4 changes: 2 additions & 2 deletions docs/Rules/AvoidUsingComputerNameHardcoded.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ The names of computers should never be hard coded as this will expose sensitive

Remove hard coded computer names.

## Example
## Example 1

### Wrong

Expand All @@ -38,7 +38,7 @@ Function Invoke-MyCommand ($ComputerName)
}
```

## Example
## Example 2

### Wrong

Expand Down
4 changes: 2 additions & 2 deletions docs/Rules/DSCReturnCorrectTypesForDSCFunctions.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ For class based resources:

Ensure that each function returns the correct type.

## Example
## Example 1

### Wrong

Expand Down Expand Up @@ -107,7 +107,7 @@ function Test-TargetResource
}
```

## Example
## Example 2

### Wrong

Expand Down
5 changes: 3 additions & 2 deletions docs/Rules/DSCStandardDSCFunctionsInResource.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ For class based resources:

Add the missing functions to the resource.

## Example
## Example 1

### Wrong

Expand Down Expand Up @@ -57,6 +57,7 @@ function Set-TargetResource
...
}
```

### Correct

```powershell
Expand Down Expand Up @@ -96,7 +97,7 @@ function Test-TargetResource
}
```

## Example
## Example 2

### Wrong

Expand Down
2 changes: 1 addition & 1 deletion docs/Rules/PossibleIncorrectUsageOfAssignmentOperator.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
description: '=' is not an assignment operator. Did you mean the equality operator '-eq'?
description: Equal sign is not an assignment operator. Did you mean the equality operator \'-eq\'?
ms.custom: PSSA v1.20.0
ms.date: 10/18/2021
ms.topic: reference
Expand Down
2 changes: 1 addition & 1 deletion docs/Rules/PossibleIncorrectUsageOfRedirectionOperator.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
description: '>' is not a comparison operator. Use '-gt' (greater than) or '-ge' (greater or equal).
description: \'>\' is not a comparison operator. Use \'-gt\' (greater than) or \'-ge\' (greater or equal).
ms.custom: PSSA v1.20.0
ms.date: 10/18/2021
ms.topic: reference
Expand Down
6 changes: 3 additions & 3 deletions docs/Rules/ProvideCommentHelp.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ presence of comment based help and not on the validity or format.
For assistance on comment based help, use the command `Get-Help about_comment_based_help` or the
following articles:

- [Writing Comment-based Help](https://docs.microsoft.com/powershell/scripting/developer/help/writing-comment-based-help-topics)
- [Writing Help for PowerShell Cmdlets](https://docs.microsoft.com/powershell/scripting/developer/help/writing-help-for-windows-powershell-cmdlets)
- [Create XML-based help using PlatyPS](https://docs.microsoft.com/powershell/scripting/dev-cross-plat/create-help-using-platyps)
- [Writing Comment-based Help](/powershell/scripting/developer/help/writing-comment-based-help-topics)
- [Writing Help for PowerShell Cmdlets](/powershell/scripting/developer/help/writing-help-for-windows-powershell-cmdlets)
- [Create XML-based help using PlatyPS](/powershell/scripting/dev-cross-plat/create-help-using-platyps)

## Configuration

Expand Down
2 changes: 1 addition & 1 deletion docs/Rules/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ The PSScriptAnalyzer contains the following rule definitions.
| [UseProcessBlockForPipelineCommand](./UseProcessBlockForPipelineCommand.md) | Warning | Yes | |
| [UsePSCredentialType](./UsePSCredentialType.md) | Warning | Yes | |
| [UseShouldProcessForStateChangingFunctions](./UseShouldProcessForStateChangingFunctions.md) | Warning | Yes | |
| [UseSingularNouns<sup>1</sup>](./UseSingularNouns.md) | Warning | Yes | |
| [UseSingularNouns](./UseSingularNouns.md) | Warning | Yes | |
| [UseSupportsShouldProcess](./UseSupportsShouldProcess.md) | Warning | Yes | |
| [UseToExportFieldsInManifest](./UseToExportFieldsInManifest.md) | Warning | Yes | |
| [UseUsingScopeModifierInNewRunspaces](./UseUsingScopeModifierInNewRunspaces.md) | Warning | Yes | |
Expand Down
2 changes: 1 addition & 1 deletion docs/Rules/UseApprovedVerbs.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ All cmdlets must used approved verbs.
Approved verbs can be found by running the command `Get-Verb`.

Additional documentation on approved verbs can be found in the microsoft docs page
[Approved Verbs for PowerShell Commands](https://docs.microsoft.com/powershell/scripting/developer/cmdlet/approved-verbs-for-windows-powershell-commands).
[Approved Verbs for PowerShell Commands](/powershell/scripting/developer/cmdlet/approved-verbs-for-windows-powershell-commands).
Some unapproved verbs are documented on the approved verbs page and point to approved alternatives.
Try searching for the verb you used to find its approved form. For example, searching for `Read`,
`Open`, or `Search` leads you to `Get`.
Expand Down
56 changes: 26 additions & 30 deletions docs/Rules/UseConsistentWhitespace.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,80 +11,76 @@ title: UseConsistentWhitespace

## Description

# Parameters

**Note**: This rule is not enabled by default. The user needs to enable it through settings.
This rule is not enabled by default. The user needs to enable it through settings.

## Configuration

```powershell
Rules = @{
PSUseConsistentWhitespace = @{
Enable = $true
CheckInnerBrace = $true
CheckOpenBrace = $true
CheckOpenParen = $true
CheckOperator = $true
CheckPipe = $true
CheckPipeForRedundantWhitespace = $false
CheckSeparator = $true
CheckParameter = $false
IgnoreAssignmentOperatorInsideHashTable = $false
}
Rules = @{
PSUseConsistentWhitespace = @{
Enable = $true
CheckInnerBrace = $true
CheckOpenBrace = $true
CheckOpenParen = $true
CheckOperator = $true
CheckPipe = $true
CheckPipeForRedundantWhitespace = $false
CheckSeparator = $true
CheckParameter = $false
IgnoreAssignmentOperatorInsideHashTable = $false
}
}
```

### Parameters

#### Enable: bool (Default value is `$false`)
### Enable: bool (Default value is `$false`)

Enable or disable the rule during ScriptAnalyzer invocation.

#### CheckInnerBrace: bool (Default value is `$true`)
### CheckInnerBrace: bool (Default value is `$true`)

Checks if there is a space after the opening brace and a space before the closing brace. E.g.
`if ($true) { foo }` instead of `if ($true) {bar}`.

#### CheckOpenBrace: bool (Default value is `$true`)
### CheckOpenBrace: bool (Default value is `$true`)

Checks if there is a space between a keyword and its corresponding open brace. E.g. `foo { }`
instead of `foo{ }`. If an open brace is preceded by an open parenthesis, then no space is required.

#### CheckOpenParen: bool (Default value is `$true`)
### CheckOpenParen: bool (Default value is `$true`)

Checks if there is space between a keyword and its corresponding open parenthesis. E.g. `if (true)`
instead of `if(true)`.

#### CheckOperator: bool (Default value is `$true`)
### CheckOperator: bool (Default value is `$true`)

Checks if a binary or unary operator is surrounded on both sides by a space. E.g. `$x = 1` instead
of `$x=1`.

#### CheckSeparator: bool (Default value is `$true`)
### CheckSeparator: bool (Default value is `$true`)

Checks if a comma or a semicolon is followed by a space. E.g. `@(1, 2, 3)` or `@{a = 1; b = 2}`
instead of `@(1,2,3)` or `@{a = 1;b = 2}`.

#### CheckPipe: bool (Default value is `$true`)
### CheckPipe: bool (Default value is `$true`)

Checks if a pipe is surrounded on both sides by a space but ignores redundant whitespace. E.g.
`foo | bar` instead of `foo|bar`.

#### CheckPipeForRedundantWhitespace : bool (Default value is `$false`)
### CheckPipeForRedundantWhitespace : bool (Default value is `$false`)

Checks if a pipe is surrounded by redundant whitespace (i.e. more than 1 whitespace). E.g.
`foo | bar` instead of `foo | bar`.

#### CheckParameter: bool (Default value is `$false` at the moment due to the setting being new)
### CheckParameter: bool (Default value is `$false` at the moment due to the setting being new)

Checks if there is more than one space between parameters and values. E.g. `foo -bar $baz -bat`
instead of `foo -bar $baz -bat`. This eliminates redundant whitespace that was probably added
unintentionally. The rule does not check for whitespace between parameter and value when the colon
syntax `-ParameterName:$ParameterValue` is used as some users prefer either 0 or 1 whitespace in
this case.

#### IgnoreAssignmentOperatorInsideHashTable: bool (Default value is `$false`)
### IgnoreAssignmentOperatorInsideHashTable: bool (Default value is `$false`)

When `CheckOperator` is set, ignore whitespace around assignment operators within multi-line hash
tables. Set this option in order to use the `AlignAssignmentStatement` rule but still check
whitespace around operators everywhere else.
tables. Set this option to use the `AlignAssignmentStatement` rule and still check whitespace around
operators everywhere else.