Skip to content

Commit

Permalink
Fix formatting and sync changes from source (#211)
Browse files Browse the repository at this point in the history
* Fix formatting and sync changes from source

* fix typo

* remove duplicate content
  • Loading branch information
sdwheeler authored Mar 26, 2024
1 parent fce70c7 commit 2b8021a
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 45 deletions.
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
---
description: Avoid exclaim operator
ms.custom: PSSA v1.22.0
ms.date: 02/13/2024
ms.date: 03/26/2024
ms.topic: reference
title: AvoidExclaimOperator
---
# AvoidExclaimOperator

**Severity Level: Warning**

## Description
Expand All @@ -19,13 +20,14 @@ Avoid using the negation operator (`!`). Use `-not` for improved readability.

## Example

### Wrong
### Wrong

```powershell
$MyVar = !$true
```

### Correct:
### Correct

```powershell
$MyVar = -not $true
```
Expand All @@ -42,6 +44,6 @@ Rules = @{

### Parameters

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

Enable or disable the rule during ScriptAnalyzer invocation.
Enable or disable the rule during ScriptAnalyzer invocation.
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](/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](../../platyps/create-help-using-platyps.md)
- [Writing Comment-based Help][01]
- [Writing Help for PowerShell Cmdlets][02]
- [Create XML-based help using PlatyPS][03]

## Configuration

Expand All @@ -37,34 +37,35 @@ Rules = @{

### Parameters

#### Enable: bool (Default valus is `$true`)
- `Enable`: **bool** (Default valus is `$true`)

Enable or disable the rule during ScriptAnalyzer invocation.
Enable or disable the rule during ScriptAnalyzer invocation.

#### ExportedOnly: bool (Default value is `$true`)
- `ExportedOnly`: **bool** (Default value is `$true`)

If enabled, throw violation only on functions/cmdlets that are exported using the
`Export-ModuleMember` cmdlet.
If enabled, throw violation only on functions/cmdlets that are exported using the
`Export-ModuleMember` cmdlet.

#### BlockComment: bool (Default value is `$true`)
- `BlockComment`: **bool** (Default value is `$true`)

If enabled, returns comment help in block comment style, i.e., `<#...#>`. Otherwise returns comment
help in line comment style, i.e., each comment line starts with `#`.
If enabled, returns comment help in block comment style (`<#...#>`). Otherwise returns
comment help in line comment style where each comment line starts with `#`.

#### VSCodeSnippetCorrection: bool (Default value is `$false`)
- `VSCodeSnippetCorrection`: **bool** (Default value is `$false`)

If enabled, returns comment help in vscode snippet format.
If enabled, returns comment help in vscode snippet format.

#### Placement: string (Default value is `before`)
- `Placement`: **string** (Default value is `before`)

Represents the position of comment help with respect to the function definition.
Represents the position of comment help with respect to the function definition.

Possible values are: `before`, `begin` and `end`. If any invalid value is given, the property
defaults to `before`.
Possible values are:

`before` means the help is placed before the function definition. `begin` means the help is placed
at the beginning of the function definition body. `end` means the help is places the end of the
function definition body.
- `before`: means the help is placed before the function definition
- `begin` means the help is placed at the beginning of the function definition body
- `end` means the help is places the end of the function definition body

If any invalid value is given, the property defaults to `before`.

## Example

Expand Down Expand Up @@ -118,3 +119,7 @@ function Get-File
}
```
<!-- link references -->
[01]: /powershell/scripting/developer/help/writing-comment-based-help-topics
[02]: /powershell/scripting/developer/help/writing-help-for-windows-powershell-cmdlets
[03]: /powershell/utility-modules/platyps/create-help-using-platyps
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
description: ReviewUnusedParameter
ms.custom: PSSA v1.22.0
ms.date: 06/28/2023
ms.date: 03/26/2024
ms.topic: reference
title: ReviewUnusedParameter
---
Expand All @@ -16,9 +16,9 @@ been used in that scope.

## Configuration settings

|Configuration key|Meaning|Accepted values|Mandatory|Example|
|---|---|---|---|---|
|CommandsToTraverse|By default, this command will not consider child scopes other than scriptblocks provided to Where-Object or ForEach-Object. This setting allows you to add additional commands that accept scriptblocks that this rule should traverse into.|string[]: list of commands whose scriptblock to traverse.|`@('Invoke-PSFProtectedCommand')`|
By default, this rule doesn't consider child scopes other than scriptblocks provided to
`Where-Object` or `ForEach-Object`. The `CommandsToTraverse` setting is an string array allows you
to add additional commands that accept scriptblocks that this rule should examine.

```powershell
@{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ but makes no calls to `ShouldProcess` or it calls `ShouldProcess` but does not d

For more information, see the following articles:

- [about_Functions_Advanced_Methods](/powershell/module/microsoft.powershell.core/about/about_functions_advanced_methods)
- [about_Functions_CmdletBindingAttribute](/powershell/module/microsoft.powershell.core/about/about_Functions_CmdletBindingAttribute)
- [Everything you wanted to know about ShouldProcess](/powershell/scripting/learn/deep-dives/everything-about-shouldprocess)
- [about_Functions_Advanced_Methods][01]
- [about_Functions_CmdletBindingAttribute][02]
- [Everything you wanted to know about ShouldProcess][03]

## How

Expand Down Expand Up @@ -73,3 +73,7 @@ function Set-File
}
}
```
<!-- link references -->
[01]: /powershell/module/microsoft.powershell.core/about/about_functions_advanced_methods
[02]: /powershell/module/microsoft.powershell.core/about/about_Functions_CmdletBindingAttribute
[03]: /powershell/scripting/learn/deep-dives/everything-about-shouldprocess
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
description: Cmdlet Verbs
ms.custom: PSSA v1.22.0
ms.date: 06/28/2023
ms.date: 03/26/2024
ms.topic: reference
title: UseApprovedVerbs
---
Expand All @@ -15,10 +15,9 @@ 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 at
[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`,
For a more information about approved verbs, see [Approved Verbs for PowerShell Commands][01]. 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`.

## How
Expand All @@ -44,3 +43,6 @@ function Update-Item
...
}
```

<!-- link references -->
[01]: /powershell/scripting/developer/cmdlet/approved-verbs-for-windows-powershell-commands
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
description: Cmdlet Singular Noun
ms.custom: PSSA v1.22.0
ms.date: 02/13/2024
ms.date: 03/26/2024
ms.topic: reference
title: UseSingularNouns
---
Expand All @@ -11,9 +11,8 @@ title: UseSingularNouns

## Description

PowerShell team best practices state cmdlets should use singular nouns and not plurals.

Suppression allows to suppress just specific function names, for example
PowerShell team best practices state cmdlets should use singular nouns and not plurals. Suppression
allows you to suppress the rule for specific function names. For example:

```
function Get-Elements {
Expand All @@ -35,13 +34,14 @@ Rules = @{

### Parameters

#### `UseSingularNouns: string[]` (Default value is `{'Data', 'Windows'}`)
- `UseSingularNouns`: `string[]` (Default value is `{'Data', 'Windows'}`)

Commands to be excluded from this rule. `Data` and `Windows` are common false positives and are excluded by default
Commands to be excluded from this rule. `Data` and `Windows` are common false positives and are
excluded by default.

#### Enable: `bool` (Default value is `$true`)
- `Enable`: `bool` (Default value is `$true`)

Enable or disable the rule during ScriptAnalyzer invocation.
Enable or disable the rule during ScriptAnalyzer invocation.

## How

Expand Down

0 comments on commit 2b8021a

Please sign in to comment.