diff --git a/reference/docs-conceptual/PSScriptAnalyzer/Rules/AvoidLongLines.md b/reference/docs-conceptual/PSScriptAnalyzer/Rules/AvoidLongLines.md index cc2603c..4a0d98d 100644 --- a/reference/docs-conceptual/PSScriptAnalyzer/Rules/AvoidLongLines.md +++ b/reference/docs-conceptual/PSScriptAnalyzer/Rules/AvoidLongLines.md @@ -1,6 +1,6 @@ --- description: Avoid long lines -ms.date: 06/28/2023 +ms.date: 04/29/2025 ms.topic: reference title: AvoidLongLines --- @@ -10,10 +10,11 @@ title: AvoidLongLines ## Description -Lines should be no longer than a configured number of characters (default: 120), including leading -whitespace (indentation). +The length of lines, including leading spaces (indentation), should less than the configured number +of characters. The default length is 120 characters. -**Note**: This rule is not enabled by default. The user needs to enable it through settings. +> [!NOTE] +> This rule isn't enabled by default. The user needs to enable it through settings. ## Configuration @@ -26,12 +27,12 @@ Rules = @{ } ``` -### Parameters +## Parameters -#### Enable: bool (Default value is `$false`) +### `Enable`: bool (Default value is `$false`) Enable or disable the rule during ScriptAnalyzer invocation. -#### MaximumLineLength: int (Default value is 120) +### `MaximumLineLength`: int (Default value is 120) Optional parameter to override the default maximum line length. diff --git a/reference/docs-conceptual/PSScriptAnalyzer/Rules/AvoidUsingConvertToSecureStringWithPlainText.md b/reference/docs-conceptual/PSScriptAnalyzer/Rules/AvoidUsingConvertToSecureStringWithPlainText.md index f3dfc76..d25fce1 100644 --- a/reference/docs-conceptual/PSScriptAnalyzer/Rules/AvoidUsingConvertToSecureStringWithPlainText.md +++ b/reference/docs-conceptual/PSScriptAnalyzer/Rules/AvoidUsingConvertToSecureStringWithPlainText.md @@ -1,6 +1,6 @@ --- description: Avoid Using SecureString With Plain Text -ms.date: 06/28/2023 +ms.date: 01/28/2025 ms.topic: reference title: AvoidUsingConvertToSecureStringWithPlainText --- diff --git a/reference/docs-conceptual/PSScriptAnalyzer/Rules/UseCorrectCasing.md b/reference/docs-conceptual/PSScriptAnalyzer/Rules/UseCorrectCasing.md index f64a788..1874a7a 100644 --- a/reference/docs-conceptual/PSScriptAnalyzer/Rules/UseCorrectCasing.md +++ b/reference/docs-conceptual/PSScriptAnalyzer/Rules/UseCorrectCasing.md @@ -1,6 +1,6 @@ --- description: Use exact casing of cmdlet/function/parameter name. -ms.date: 06/28/2023 +ms.date: 03/19/2025 ms.topic: reference title: UseCorrectCasing --- @@ -10,26 +10,66 @@ title: UseCorrectCasing ## Description -This is a style/formatting rule. PowerShell is case insensitive where applicable. The casing of -cmdlet names or parameters does not matter but this rule ensures that the casing matches for -consistency and also because most cmdlets/parameters start with an upper case and using that -improves readability to the human eye. +This is a style/formatting rule. PowerShell is case insensitive wherever possible, so the casing of +cmdlet names, parameters, keywords and operators does not matter. This rule nonetheless ensures +consistent casing for clarity and readability. Using lowercase keywords helps distinguish them from +commands. Using lowercase operators helps distinguish them from parameters. ## How -Use exact casing of the cmdlet and its parameters, e.g. -`Invoke-Command { 'foo' } -RunAsAdministrator`. +- Use exact casing for type names. +- Use exact casing of the cmdlet and its parameters. +- Use lowercase for language keywords and operators. -## Example +## Configuration -### Wrong +```powershell +Rules = @{ + PS UseCorrectCasing = @{ + Enable = $true + CheckCommands = $true + CheckKeyword = $true + CheckOperator = $true + } +} +``` + +### Parameters + +#### Enable: bool (Default value is `$false`) + +Enable or disable the rule during ScriptAnalyzer invocation. + +#### CheckCommands: bool (Default value is `$true`) + +If true, require the case of all operators to be lowercase. + +#### CheckKeyword: bool (Default value is `$true`) + +If true, require the case of all keywords to be lowercase. + +#### CheckOperator: bool (Default value is `$true`) + +If true, require the case of all commands to match their actual casing. + +## Examples + +### Wrong way ```powershell +ForEach ($file in Get-childitem -Recurse) { + $file.Extension -eq '.txt' +} + invoke-command { 'foo' } -runasadministrator ``` -### Correct +### Correct way ```powershell +foreach ($file in Get-ChildItem -Recurse) { + $file.Extension -eq '.txt' +} + Invoke-Command { 'foo' } -RunAsAdministrator ``` diff --git a/reference/docs-conceptual/PSScriptAnalyzer/whats-new-in-pssa.md b/reference/docs-conceptual/PSScriptAnalyzer/whats-new-in-pssa.md index 94ef767..8af44e0 100644 --- a/reference/docs-conceptual/PSScriptAnalyzer/whats-new-in-pssa.md +++ b/reference/docs-conceptual/PSScriptAnalyzer/whats-new-in-pssa.md @@ -1,6 +1,6 @@ --- description: This article lists the updates to the PSScriptAnalyzer module. -ms.date: 10/10/2024 +ms.date: 04/29/2025 title: What's new in PSScriptAnalyzer --- # What's new in PSScriptAnalyzer @@ -9,6 +9,29 @@ PSScriptAnalyzer is a static code checker for PowerShell modules and scripts. Th the important changes in PSScriptAnalyzer. For a full list of changes, see the PSScriptAnalyzer [CHANGELOG][01]. +## PSScriptAnalyzer 1.24.0 - 2025-03-18 + +Breaking changes + +- Minimum required PowerShell version raised from 3 to 5.1 + +New features and updates + +- Add new options (enabled by default) to formatting rule `UseCorrectCasing` to also correct + operators, keywords and commands +- `PSAlignAssignmentStatement`: Ignore hashtables with a single key-value pair +- Use `RequiredResource` hashtable to specify PowerShell module versions +- `PSAvoidAssignmentToAutomaticVariable`: Ignore when a Parameter has an Attribute that contains a + Variable expression +- Trim unnecessary trailing spaces from string resources in Strings.resx +- Make Settings type detection more robust +- Add foreach Assignment to `AvoidAssignmentToAutomaticVariable` +- Do not print summary repeatedly for each logger +- Set exit code of `Invoke-ScriptAnalyzer -EnableExit` to total number of diagnostics +- `Invoke-ScriptAnalyzer`: Stream diagnostics instead of batching +- `Invoke-ScriptAnalyzer`: Print summary only once per invocation +- `Invoke-ScriptAnalyzer`: Include parse errors in reported error count + ## PSScriptAnalyzer 1.23.0 - 2024-10-09 Small maintenance release to update the build pipeline and fix two issues: diff --git a/reference/docs-conceptual/toc.yml b/reference/docs-conceptual/toc.yml index 115ee6e..965814b 100644 --- a/reference/docs-conceptual/toc.yml +++ b/reference/docs-conceptual/toc.yml @@ -37,7 +37,7 @@ items: href: PlatyPS/overview.md - name: Create help using PlatyPS href: PlatyPS/create-help-using-platyps.md - - name: PSScriptAnalyzer v1.23 + - name: PSScriptAnalyzer v1.24 items: - name: Overview href: PSScriptAnalyzer/overview.md