Skip to content

Commit

Permalink
PSScriptAnalyzer 1.22.0 changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Christoph Bergmeister committed Feb 13, 2024
1 parent e71b302 commit 9d428ae
Show file tree
Hide file tree
Showing 70 changed files with 149 additions and 74 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
description: Align assignment statement
ms.custom: PSSA v1.21.0
ms.custom: PSSA v1.22.0
ms.date: 06/28/2023
ms.topic: reference
title: AlignAssignmentStatement
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
description: Changing automatic variables might have undesired side effects
ms.custom: PSSA v1.21.0
ms.custom: PSSA v1.22.0
ms.date: 06/28/2023
ms.topic: reference
title: AvoidAssignmentToAutomaticVariable
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
description: Avoid Default Value For Mandatory Parameter
ms.custom: PSSA v1.21.0
ms.custom: PSSA v1.22.0
ms.date: 06/28/2023
ms.topic: reference
title: AvoidDefaultValueForMandatoryParameter
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
description: Switch Parameters Should Not Default To True
ms.custom: PSSA v1.21.0
ms.custom: PSSA v1.22.0
ms.date: 06/28/2023
ms.topic: reference
title: AvoidDefaultValueSwitchParameter
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
---
description: Avoid exclaim operator
ms.custom: PSSA v1.22.0
ms.date: 06/14/2023
ms.topic: reference
title: AvoidExclaimOperator
---
# AvoidExclaimOperator
**Severity Level: Warning**

## Description

The negation operator `!` should not be used for readability purposes. Use `-not` instead.

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

## How to Fix

## Example
### Wrong:
```PowerShell
$MyVar = !$true
```

### Correct:
```PowerShell
$MyVar = -not $true
```

## Configuration

```powershell
Rules = @{
PSAvoidExclaimOperator = @{
Enable = $true
}
}
```

### Parameters

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

Enable or disable the rule during ScriptAnalyzer invocation.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
description: Avoid global aliases.
ms.custom: PSSA v1.21.0
ms.custom: PSSA v1.22.0
ms.date: 06/28/2023
ms.topic: reference
title: AvoidGlobalAliases
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
description: Avoid global functions and aliases
ms.custom: PSSA v1.21.0
ms.custom: PSSA v1.22.0
ms.date: 06/28/2023
ms.topic: reference
title: AvoidGlobalFunctions
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
description: No Global Variables
ms.custom: PSSA v1.21.0
ms.custom: PSSA v1.22.0
ms.date: 06/28/2023
ms.topic: reference
title: AvoidGlobalVars
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
description: Avoid Invoking Empty Members
ms.custom: PSSA v1.21.0
ms.custom: PSSA v1.22.0
ms.date: 06/28/2023
ms.topic: reference
title: AvoidInvokingEmptyMembers
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
description: Avoid long lines
ms.custom: PSSA v1.21.0
ms.custom: PSSA v1.22.0
ms.date: 06/28/2023
ms.topic: reference
title: AvoidLongLines
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
description: Avoid multiple type specifiers on parameters.
ms.custom: PSSA v1.21.0
ms.custom: PSSA v1.22.0
ms.date: 06/28/2023
ms.topic: reference
title: AvoidMultipleTypeAttributes
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
description: Avoid using null or empty HelpMessage parameter attribute.
ms.custom: PSSA v1.21.0
ms.custom: PSSA v1.22.0
ms.date: 06/28/2023
ms.topic: reference
title: AvoidNullOrEmptyHelpMessageAttribute
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
description: Avoid overwriting built in cmdlets
ms.custom: PSSA v1.21.0
ms.custom: PSSA v1.22.0
ms.date: 06/28/2023
ms.topic: reference
title: AvoidOverwritingBuiltInCmdlets
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
description: Avoid semicolons as line terminators
ms.custom: PSSA v1.21.0
ms.custom: PSSA v1.22.0
ms.date: 06/28/2023
ms.topic: reference
title: AvoidSemicolonsAsLineTerminators
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
description: Avoid Using ShouldContinue Without Boolean Force Parameter
ms.custom: PSSA v1.21.0
ms.custom: PSSA v1.22.0
ms.date: 06/28/2023
ms.topic: reference
title: AvoidShouldContinueWithoutForce
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
description: Avoid trailing whitespace
ms.custom: PSSA v1.21.0
ms.custom: PSSA v1.22.0
ms.date: 06/28/2023
ms.topic: reference
title: AvoidTrailingWhitespace
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
description: Avoid using broken hash algorithms
ms.custom: PSSA v1.21.0
ms.custom: PSSA v1.22.0
ms.date: 06/28/2023
ms.topic: reference
title: AvoidUsingBrokenHashAlgorithms
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
description: Avoid Using Cmdlet Aliases or omitting the 'Get-' prefix.
ms.custom: PSSA v1.21.0
ms.custom: PSSA v1.22.0
ms.date: 06/28/2023
ms.topic: reference
title: AvoidUsingCmdletAliases
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
description: Avoid Using ComputerName Hardcoded
ms.custom: PSSA v1.21.0
ms.custom: PSSA v1.22.0
ms.date: 06/28/2023
ms.topic: reference
title: AvoidUsingComputerNameHardcoded
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
description: Avoid Using SecureString With Plain Text
ms.custom: PSSA v1.21.0
ms.custom: PSSA v1.22.0
ms.date: 06/28/2023
ms.topic: reference
title: AvoidUsingConvertToSecureStringWithPlainText
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
description: Avoid Using Deprecated Manifest Fields
ms.custom: PSSA v1.21.0
ms.custom: PSSA v1.22.0
ms.date: 06/28/2023
ms.topic: reference
title: AvoidUsingDeprecatedManifestFields
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
description: Avoid using double quotes if the string is constant.
ms.custom: PSSA v1.21.0
ms.custom: PSSA v1.22.0
ms.date: 06/28/2023
ms.topic: reference
title: AvoidUsingDoubleQuotesForConstantString
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
description: Avoid Using Empty Catch Block
ms.custom: PSSA v1.21.0
ms.custom: PSSA v1.22.0
ms.date: 06/28/2023
ms.topic: reference
title: AvoidUsingEmptyCatchBlock
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
description: Avoid Using Invoke-Expression
ms.custom: PSSA v1.21.0
ms.custom: PSSA v1.22.0
ms.date: 06/28/2023
ms.topic: reference
title: AvoidUsingInvokeExpression
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
description: Avoid Using Plain Text For Password Parameter
ms.custom: PSSA v1.21.0
ms.custom: PSSA v1.22.0
ms.date: 06/28/2023
ms.topic: reference
title: AvoidUsingPlainTextForPassword
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
description: Avoid Using Positional Parameters
ms.custom: PSSA v1.21.0
ms.custom: PSSA v1.22.0
ms.date: 06/28/2023
ms.topic: reference
title: AvoidUsingPositionalParameters
Expand All @@ -24,7 +24,7 @@ supplied. A simple example where the risk of using positional parameters is negl

```powershell
Rules = @{
AvoidUsingPositionalParameters = @{
PSAvoidUsingPositionalParameters = @{
CommandAllowList = 'az', 'Join-Path'
Enable = $true
}
Expand All @@ -33,7 +33,7 @@ Rules = @{

### Parameters

#### AvoidUsingPositionalParameters: string[] (Default value is 'az')
#### CommandAllowList: string[] (Default value is 'az')

Commands to be excluded from this rule. `az` is excluded by default because starting with version 2.40.0 the entrypoint of the AZ CLI became an `az.ps1` script but this script does not have any named parameters and just passes them on using `$args` as is to the Python process that it starts, therefore it is still a CLI and not a PowerShell command.

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
description: Avoid Using Username and Password Parameters
ms.custom: PSSA v1.21.0
ms.custom: PSSA v1.22.0
ms.date: 06/28/2023
ms.topic: reference
title: AvoidUsingUsernameAndPasswordParams
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
description: Avoid Using Get-WMIObject, Remove-WMIObject, Invoke-WmiMethod, Register-WmiEvent, Set-WmiInstance
ms.custom: PSSA v1.21.0
ms.custom: PSSA v1.22.0
ms.date: 06/28/2023
ms.topic: reference
title: AvoidUsingWMICmdlet
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
description: Avoid Using Write-Host
ms.custom: PSSA v1.21.0
ms.custom: PSSA v1.22.0
ms.date: 06/28/2023
ms.topic: reference
title: AvoidUsingWriteHost
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
description: DSC examples are present
ms.custom: PSSA v1.21.0
ms.custom: PSSA v1.22.0
ms.date: 06/28/2023
ms.topic: reference
title: DSCDscExamplesPresent
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
description: Dsc tests are present
ms.custom: PSSA v1.21.0
ms.custom: PSSA v1.22.0
ms.date: 06/28/2023
ms.topic: reference
title: DSCDscTestsPresent
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
description: Return Correct Types For DSC Functions
ms.custom: PSSA v1.21.0
ms.custom: PSSA v1.22.0
ms.date: 06/28/2023
ms.topic: reference
title: DSCReturnCorrectTypesForDSCFunctions
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
description: Use Standard Get/Set/Test TargetResource functions in DSC Resource
ms.custom: PSSA v1.21.0
ms.custom: PSSA v1.22.0
ms.date: 06/28/2023
ms.topic: reference
title: DSCStandardDSCFunctionsInResource
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
description: Use identical mandatory parameters for DSC Get/Test/Set TargetResource functions
ms.custom: PSSA v1.21.0
ms.custom: PSSA v1.22.0
ms.date: 06/28/2023
ms.topic: reference
title: DSCUseIdenticalMandatoryParametersForDSC
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
description: Use Identical Parameters For DSC Test and Set Functions
ms.custom: PSSA v1.21.0
ms.custom: PSSA v1.22.0
ms.date: 06/28/2023
ms.topic: reference
title: DSCUseIdenticalParametersForDSC
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
description: Use verbose message in DSC resource
ms.custom: PSSA v1.21.0
ms.custom: PSSA v1.22.0
ms.date: 06/28/2023
ms.topic: reference
title: DSCUseVerboseMessageInDSCResource
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
description: Misleading Backtick
ms.custom: PSSA v1.21.0
ms.custom: PSSA v1.22.0
ms.date: 06/28/2023
ms.topic: reference
title: MisleadingBacktick
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
description: Module Manifest Fields
ms.custom: PSSA v1.21.0
ms.custom: PSSA v1.22.0
ms.date: 06/28/2023
ms.topic: reference
title: MissingModuleManifestField
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
description: Place close braces
ms.custom: PSSA v1.21.0
ms.custom: PSSA v1.22.0
ms.date: 06/28/2023
ms.topic: reference
title: PlaceCloseBrace
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
description: Place open braces consistently
ms.custom: PSSA v1.21.0
ms.custom: PSSA v1.22.0
ms.date: 06/28/2023
ms.topic: reference
title: PlaceOpenBrace
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
description: Null Comparison
ms.custom: PSSA v1.21.0
ms.custom: PSSA v1.22.0
ms.date: 06/28/2023
ms.topic: reference
title: PossibleIncorrectComparisonWithNull
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
description: Equal sign is not an assignment operator. Did you mean the equality operator \'-eq\'?
ms.custom: PSSA v1.21.0
ms.custom: PSSA v1.22.0
ms.date: 06/28/2023
ms.topic: reference
title: PossibleIncorrectUsageOfAssignmentOperator
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
description: \'>\' is not a comparison operator. Use \'-gt\' (greater than) or \'-ge\' (greater or equal).
ms.custom: PSSA v1.21.0
ms.custom: PSSA v1.22.0
ms.date: 06/28/2023
ms.topic: reference
title: PossibleIncorrectUsageOfRedirectionOperator
Expand Down
Loading

0 comments on commit 9d428ae

Please sign in to comment.