From 7de6fa286a58d0e46eeb525487f3b7bdccabddd0 Mon Sep 17 00:00:00 2001 From: Christoph Bergmeister Date: Fri, 21 Oct 2022 11:30:21 +0100 Subject: [PATCH 01/42] UseApprovedVerbs.md: Backport minor change of PR 104 in PowerShell-Docs-Modules --- docs/Rules/UseApprovedVerbs.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/Rules/UseApprovedVerbs.md b/docs/Rules/UseApprovedVerbs.md index ee7721444..932795f77 100644 --- a/docs/Rules/UseApprovedVerbs.md +++ b/docs/Rules/UseApprovedVerbs.md @@ -15,7 +15,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 +Additional documentation on approved verbs can be found at [Approved Verbs for PowerShell Commands](https://learn.microsoft.com/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`, From ec75b7f3667f755027a51b1dd77c758497df5daf Mon Sep 17 00:00:00 2001 From: Christoph Bergmeister Date: Mon, 31 Oct 2022 09:10:56 +0000 Subject: [PATCH 02/42] Improve Pester bootstrap logic for CI (#1853) --- README.md | 3 +-- tools/appveyor.psm1 | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 8c4063050..f62d1ca69 100644 --- a/README.md +++ b/README.md @@ -163,8 +163,7 @@ built-in rules. Pester-based ScriptAnalyzer Tests are located in `path/to/PSScriptAnalyzer/Tests` folder. -- Ensure [Pester 4.3.1](https://www.powershellgallery.com/packages/Pester/4.3.1) or higher is - installed +- Ensure [Pester](https://www.powershellgallery.com/packages/Pester) of at least version 5.3 is installed - In the root folder of your local repository, run: ```powershell diff --git a/tools/appveyor.psm1 b/tools/appveyor.psm1 index bbad9643d..294e8d096 100644 --- a/tools/appveyor.psm1 +++ b/tools/appveyor.psm1 @@ -4,8 +4,8 @@ $ErrorActionPreference = 'Stop' function Install-Pester { - $requiredPesterVersion = '5.2.2' - $pester = Get-Module Pester -ListAvailable | Where-Object { $_.Version -eq $requiredPesterVersion } + $requiredPesterVersion = '5.3' + $pester = Get-Module Pester -ListAvailable | Where-Object { $_.Version -ge $requiredPesterVersion } if ($null -eq $pester) { if ($null -eq (Get-Module -ListAvailable PowershellGet)) { # WMF 4 image build From e21fe007dd58a9fe8af6aedfe58ba085b83dbe45 Mon Sep 17 00:00:00 2001 From: Christoph Bergmeister Date: Mon, 31 Oct 2022 09:11:18 +0000 Subject: [PATCH 03/42] Bump .NET SDK from 3.1.419 to 3.1.424 (#1852) * Bump .NET SDK from 3.1.102 to 3.1.424 * cleanup diff --- README.md | 2 +- global.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index f62d1ca69..75dd8668b 100644 --- a/README.md +++ b/README.md @@ -72,7 +72,7 @@ To install **PSScriptAnalyzer** from source code: ### Requirements -- [.NET Core 3.1.102 SDK](https://www.microsoft.com/net/download/dotnet-core/3.1#sdk-3.1.102) or +- [.NET Core 3.1.424 SDK](https://www.microsoft.com/net/download/dotnet-core/3.1#sdk-3.1.424) or newer patch release * If building for Windows PowerShell versions, then the .NET Framework 4.6.2 [targeting pack](https://dotnet.microsoft.com/en-us/download/dotnet-framework/net462) (also referred to as developer/targeting pack) need to be installed. This is only possible on Windows. * Optionally but recommended for development: [Visual Studio 2017/2019](https://www.visualstudio.com/downloads) diff --git a/global.json b/global.json index 039caccaa..e758de528 100644 --- a/global.json +++ b/global.json @@ -1,5 +1,5 @@ { "sdk": { - "version": "3.1.419" + "version": "3.1.424" } } From 542b75fdfdb09268a67345633bfaee2281d332c9 Mon Sep 17 00:00:00 2001 From: Christoph Bergmeister Date: Mon, 31 Oct 2022 09:12:12 +0000 Subject: [PATCH 04/42] AvoidLongLines: Make internal function DiagnosticSeverity private (#1851) --- Rules/AvoidLongLines.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Rules/AvoidLongLines.cs b/Rules/AvoidLongLines.cs index e0860a75e..ad527bb37 100644 --- a/Rules/AvoidLongLines.cs +++ b/Rules/AvoidLongLines.cs @@ -132,7 +132,7 @@ public override RuleSeverity GetSeverity() /// Gets the severity of the returned diagnostic record: error, warning, or information. /// /// - public DiagnosticSeverity GetDiagnosticSeverity() + private DiagnosticSeverity GetDiagnosticSeverity() { return DiagnosticSeverity.Warning; } From 77f65007e3e336624b747ace39952f59f5517afa Mon Sep 17 00:00:00 2001 From: Sean Wheeler Date: Tue, 6 Dec 2022 10:00:17 -0600 Subject: [PATCH 05/42] SupportsShouldProcess.md: Fix Typo - MicrosoftDocs backport of PR 121 --- docs/Rules/UseSupportsShouldProcess.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/Rules/UseSupportsShouldProcess.md b/docs/Rules/UseSupportsShouldProcess.md index 20ec0b2ce..1c3426366 100644 --- a/docs/Rules/UseSupportsShouldProcess.md +++ b/docs/Rules/UseSupportsShouldProcess.md @@ -1,7 +1,7 @@ --- description: Use SupportsShouldProcess ms.custom: PSSA v1.21.0 -ms.date: 10/18/2021 +ms.date: 12/06/2022 ms.topic: reference title: UseSupportsShouldProcess --- @@ -13,7 +13,7 @@ title: UseSupportsShouldProcess This rule discourages manual declaration of `WhatIf` and `Confirm` parameters in a function/cmdlet. These parameters are, however, provided automatically when a function declares a `CmdletBinding` -attribute with `SupportsShouldProcess` as its named argument. Using `SupportsShouldProcess` no only +attribute with `SupportsShouldProcess` as its named argument. Using `SupportsShouldProcess` not only provides these parameters but also some generic functionality that allows the function/cmdlet authors to provide the desired interactive experience while using the cmdlet. From f77acdf4cfed22b4b5bd106ac07951991ce824b7 Mon Sep 17 00:00:00 2001 From: Ryan Yates Date: Fri, 27 Jan 2023 23:12:58 +0000 Subject: [PATCH 06/42] Minor test fix (#1885) This test seems to have been wrong, so have corrected it --- Tests/Rules/UseCorrectCasing.tests.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tests/Rules/UseCorrectCasing.tests.ps1 b/Tests/Rules/UseCorrectCasing.tests.ps1 index a5280a6e3..50ce289c3 100644 --- a/Tests/Rules/UseCorrectCasing.tests.ps1 +++ b/Tests/Rules/UseCorrectCasing.tests.ps1 @@ -11,7 +11,7 @@ Describe "UseCorrectCasing" { } It "corrects case of of cmdlet inside interpolated string" { - Invoke-Formatter '"$(get-childitem)"' | Should -Be '"$(get-childitem)"' + Invoke-Formatter '"$(get-childitem)"' | Should -Be '"$(Get-ChildItem)"' } It "Corrects alias correctly" { From 8826d1cab3a39af3e03b413b858bc3a9a22753c0 Mon Sep 17 00:00:00 2001 From: Oleksandr Redko Date: Fri, 10 Feb 2023 11:29:18 +0200 Subject: [PATCH 07/42] Fix Invoke-Formatter correct case test (#1888) Follows #1885. --- Tests/Rules/UseCorrectCasing.tests.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tests/Rules/UseCorrectCasing.tests.ps1 b/Tests/Rules/UseCorrectCasing.tests.ps1 index 50ce289c3..e22f5308f 100644 --- a/Tests/Rules/UseCorrectCasing.tests.ps1 +++ b/Tests/Rules/UseCorrectCasing.tests.ps1 @@ -11,7 +11,7 @@ Describe "UseCorrectCasing" { } It "corrects case of of cmdlet inside interpolated string" { - Invoke-Formatter '"$(get-childitem)"' | Should -Be '"$(Get-ChildItem)"' + Invoke-Formatter '"$(get-childitem)"' | Should -BeExactly '"$(Get-ChildItem)"' } It "Corrects alias correctly" { From 19a6a185d10e16ed1b9db75b397eb058b21023f1 Mon Sep 17 00:00:00 2001 From: "Mikey Lombardi (He/Him)" Date: Wed, 22 Feb 2023 06:20:48 -0600 Subject: [PATCH 08/42] (MAINT) Fix AvoidUsingDoubleQuotesForConstantString in overview README (#1883) As identified[^1] by @BenedekFarkas, the line in the rules overview readme for `AvoidUsingDoubleQuotesForConstantString` incorrectly lists the severity as `Warning` and that the rule is configurable when the severity is `Information`[^2] and there aren't any configurable options. This change copies the fix @BenedekFarkas kindly submitted to the docs site to ensure the documentation stays up-to-date. [^1]: For more information, see: - MicrosoftDocs/PowerShell-Docs-Modules#128 [^2]: Source code: https://github.com/PowerShell/PSScriptAnalyzer/blob/9a6ce978d870909e688d9da0d101d3fc00b504f0/Rules/AvoidUsingDoubleQuotesForConstantString.cs#L142 --- docs/Rules/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/Rules/README.md b/docs/Rules/README.md index aaac74f66..44062d7c3 100644 --- a/docs/Rules/README.md +++ b/docs/Rules/README.md @@ -31,7 +31,7 @@ The PSScriptAnalyzer contains the following rule definitions. | [AvoidUsingComputerNameHardcoded](./AvoidUsingComputerNameHardcoded.md) | Error | Yes | | | [AvoidUsingConvertToSecureStringWithPlainText](./AvoidUsingConvertToSecureStringWithPlainText.md) | Error | Yes | | | [AvoidUsingDeprecatedManifestFields](./AvoidUsingDeprecatedManifestFields.md) | Warning | Yes | | -| [AvoidUsingDoubleQuotesForConstantString](./AvoidUsingDoubleQuotesForConstantString.md) | Warning | No | Yes | +| [AvoidUsingDoubleQuotesForConstantString](./AvoidUsingDoubleQuotesForConstantString.md) | Information | No | | | [AvoidUsingEmptyCatchBlock](./AvoidUsingEmptyCatchBlock.md) | Warning | Yes | | | [AvoidUsingInvokeExpression](./AvoidUsingInvokeExpression.md) | Warning | Yes | | | [AvoidUsingPlainTextForPassword](./AvoidUsingPlainTextForPassword.md) | Warning | Yes | | From 33461f40254838683bd483fb4321279376b32a52 Mon Sep 17 00:00:00 2001 From: Frode Flaten <3436158+fflaten@users.noreply.github.com> Date: Wed, 1 Mar 2023 01:09:34 +0100 Subject: [PATCH 09/42] Remove rjmholt as dependabot reviewer (#1897) Rob no longer works as MSFT. --- .github/dependabot.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/dependabot.yml b/.github/dependabot.yml index cd548b070..f0ba62a3e 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -8,7 +8,6 @@ updates: timezone: America/Los_Angeles open-pull-requests-limit: 10 reviewers: - - "rjmholt" - "JamesWTruher" - "bergmeister" ignore: From 59cecb5579abdc2c5dd14949ae450b3f1885e65f Mon Sep 17 00:00:00 2001 From: "ALi.w" Date: Wed, 22 Mar 2023 14:31:45 +0330 Subject: [PATCH 10/42] Fix typo: 'to' being repeated two times (#1902) --- Rules/Strings.resx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Rules/Strings.resx b/Rules/Strings.resx index 20b04712d..dbba6e570 100644 --- a/Rules/Strings.resx +++ b/Rules/Strings.resx @@ -292,7 +292,7 @@ Password parameters that take in plaintext will expose passwords and compromise the security of your system. - Parameter '{0}' should not use String type but either SecureString or PSCredential, otherwise it increases the chance to to expose this sensitive information. + Parameter '{0}' should not use String type but either SecureString or PSCredential, otherwise it increases the chance to expose this sensitive information. Avoid Using Plain Text For Password Parameter @@ -1191,4 +1191,4 @@ Parameter '{0}' of function/cmdlet '{1}' does not match its exact casing '{2}'. - \ No newline at end of file + From a289e7fa6f15d4a33b7c385a4384e7d026a4b464 Mon Sep 17 00:00:00 2001 From: Christoph Bergmeister Date: Tue, 25 Apr 2023 18:40:28 +0100 Subject: [PATCH 11/42] CI: Use new Ubuntu 22.04 image and remove deprecated Ubuntu 18.04 (#1847) * Use new Ubuntu and mac images * only use latest image for macos --- .azure-pipelines-ci/ci.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.azure-pipelines-ci/ci.yaml b/.azure-pipelines-ci/ci.yaml index 01e893f0c..956139389 100644 --- a/.azure-pipelines-ci/ci.yaml +++ b/.azure-pipelines-ci/ci.yaml @@ -22,10 +22,10 @@ stages: - job: strategy: matrix: - Ubuntu_18_04: - vmImage: ubuntu-18.04 Ubuntu_20_04: vmImage: ubuntu-20.04 + Ubuntu_22_04: + vmImage: ubuntu-22.04 mac_Latest: vmImage: macOS-latest Windows_Server2019_PowerShell_Core: From 76e1bbf27434fabffacc1cec5d5028ffda75544f Mon Sep 17 00:00:00 2001 From: Sean Wheeler Date: Sun, 7 May 2023 09:20:31 -0700 Subject: [PATCH 12/42] Change double quotes to single in docs where possible (#1911) --- docs/Rules/AlignAssignmentStatement.md | 8 ++++---- docs/Rules/AvoidGlobalAliases.md | 2 +- docs/Rules/AvoidInvokingEmptyMembers.md | 4 ++-- docs/Rules/AvoidOverwritingBuiltInCmdlets.md | 6 +++--- docs/Rules/AvoidShouldContinueWithoutForce.md | 4 ++-- docs/Rules/AvoidUsingComputerNameHardcoded.md | 4 ++-- ...oidUsingConvertToSecureStringWithPlainText.md | 4 ++-- docs/Rules/AvoidUsingEmptyCatchBlock.md | 4 ++-- docs/Rules/AvoidUsingInvokeExpression.md | 2 +- docs/Rules/AvoidUsingWMICmdlet.md | 4 ++-- docs/Rules/AvoidUsingWriteHost.md | 8 ++++---- docs/Rules/DSCUseVerboseMessageInDSCResource.md | 2 +- docs/Rules/PlaceCloseBrace.md | 2 +- docs/Rules/PlaceOpenBrace.md | 2 +- docs/Rules/ProvideCommentHelp.md | 2 +- docs/Rules/ShouldProcess.md | 4 ++-- docs/Rules/UseCompatibleCmdlets.md | 2 +- docs/Rules/UseCompatibleCommands.md | 8 ++++---- docs/Rules/UseCompatibleSyntax.md | 6 +++--- docs/Rules/UseCompatibleTypes.md | 14 +++++++------- docs/Rules/UseDeclaredVarsMoreThanAssignments.md | 8 ++++---- docs/Rules/UseOutputTypeCorrectly.md | 2 +- .../Rules/UseUsingScopeModifierInNewRunspaces.md | 16 ++++++++-------- 23 files changed, 59 insertions(+), 59 deletions(-) diff --git a/docs/Rules/AlignAssignmentStatement.md b/docs/Rules/AlignAssignmentStatement.md index 9265e5389..1a3b7426f 100644 --- a/docs/Rules/AlignAssignmentStatement.md +++ b/docs/Rules/AlignAssignmentStatement.md @@ -19,8 +19,8 @@ are aligned or not. Consider the following example in which the key value pairs ```powershell $hashtable = @{ - property1 = "value" - anotherProperty = "another value" + property1 = 'value' + anotherProperty = 'another value' } ``` @@ -28,8 +28,8 @@ Alignment in this case would look like the following. ```powershell $hashtable = @{ - property1 = "value" - anotherProperty = "another value" + property1 = 'value' + anotherProperty = 'another value' } ``` diff --git a/docs/Rules/AvoidGlobalAliases.md b/docs/Rules/AvoidGlobalAliases.md index 84158157c..8ceeeaf45 100644 --- a/docs/Rules/AvoidGlobalAliases.md +++ b/docs/Rules/AvoidGlobalAliases.md @@ -28,7 +28,7 @@ Use other scope modifiers for new aliases. ### Wrong ```powershell -New-Alias -Name Name -Value Value -Scope "Global" +New-Alias -Name Name -Value Value -Scope Global ``` ### Correct diff --git a/docs/Rules/AvoidInvokingEmptyMembers.md b/docs/Rules/AvoidInvokingEmptyMembers.md index 45ad72942..1d5324c0e 100644 --- a/docs/Rules/AvoidInvokingEmptyMembers.md +++ b/docs/Rules/AvoidInvokingEmptyMembers.md @@ -23,13 +23,13 @@ Provide the requested members for a given type or class. ### Wrong ```powershell -$MyString = "abc" +$MyString = 'abc' $MyString.('len'+'gth') ``` ### Correct ```powershell -$MyString = "abc" +$MyString = 'abc' $MyString.('length') ``` diff --git a/docs/Rules/AvoidOverwritingBuiltInCmdlets.md b/docs/Rules/AvoidOverwritingBuiltInCmdlets.md index e25b3b579..e579694b9 100644 --- a/docs/Rules/AvoidOverwritingBuiltInCmdlets.md +++ b/docs/Rules/AvoidOverwritingBuiltInCmdlets.md @@ -26,7 +26,7 @@ following your settings file. @{ 'Rules' = @{ 'PSAvoidOverwritingBuiltInCmdlets' = @{ - 'PowerShellVersion' = @("core-6.1.0-windows") + 'PowerShellVersion' = @('core-6.1.0-windows') } } } @@ -38,8 +38,8 @@ following your settings file. The parameter `PowerShellVersion` is a list of allowlists that ship with PSScriptAnalyzer. -**Note**: The default value for `PowerShellVersion` is `"core-6.1.0-windows"` if PowerShell 6 or -later is installed, and `"desktop-5.1.14393.206-windows"` if it is not. +**Note**: The default value for `PowerShellVersion` is `core-6.1.0-windows` if PowerShell 6 or +later is installed, and `desktop-5.1.14393.206-windows` if it is not. Usually, patched versions of PowerShell have the same cmdlet data, therefore only settings of major and minor versions of PowerShell are supplied. One can also create a custom settings file as well diff --git a/docs/Rules/AvoidShouldContinueWithoutForce.md b/docs/Rules/AvoidShouldContinueWithoutForce.md index e19b370de..36f5d6061 100644 --- a/docs/Rules/AvoidShouldContinueWithoutForce.md +++ b/docs/Rules/AvoidShouldContinueWithoutForce.md @@ -33,7 +33,7 @@ Function Test-ShouldContinue $MyString = 'blah' ) - if ($PsCmdlet.ShouldContinue("ShouldContinue Query", "ShouldContinue Caption")) + if ($PsCmdlet.ShouldContinue('ShouldContinue Query', 'ShouldContinue Caption')) { ... } @@ -52,7 +52,7 @@ Function Test-ShouldContinue [Switch]$Force ) - if ($Force -or $PsCmdlet.ShouldContinue("ShouldContinue Query", "ShouldContinue Caption")) + if ($Force -or $PsCmdlet.ShouldContinue('ShouldContinue Query', 'ShouldContinue Caption')) { ... } diff --git a/docs/Rules/AvoidUsingComputerNameHardcoded.md b/docs/Rules/AvoidUsingComputerNameHardcoded.md index 7cf3c6d8c..7e4120ceb 100644 --- a/docs/Rules/AvoidUsingComputerNameHardcoded.md +++ b/docs/Rules/AvoidUsingComputerNameHardcoded.md @@ -25,7 +25,7 @@ Remove hard coded computer names. ```powershell Function Invoke-MyRemoteCommand () { - Invoke-Command -Port 343 -ComputerName "hardcoderemotehostname" + Invoke-Command -Port 343 -ComputerName hardcoderemotehostname } ``` @@ -45,7 +45,7 @@ Function Invoke-MyCommand ($ComputerName) ```powershell Function Invoke-MyLocalCommand () { - Invoke-Command -Port 343 -ComputerName "hardcodelocalhostname" + Invoke-Command -Port 343 -ComputerName 'hardcodelocalhostname' } ``` diff --git a/docs/Rules/AvoidUsingConvertToSecureStringWithPlainText.md b/docs/Rules/AvoidUsingConvertToSecureStringWithPlainText.md index 02e2033de..7e4088238 100644 --- a/docs/Rules/AvoidUsingConvertToSecureStringWithPlainText.md +++ b/docs/Rules/AvoidUsingConvertToSecureStringWithPlainText.md @@ -30,14 +30,14 @@ module from the PowerShell Gallery. ### Wrong ```powershell -$UserInput = Read-Host "Please enter your secure code" +$UserInput = Read-Host 'Please enter your secure code' $EncryptedInput = ConvertTo-SecureString -String $UserInput -AsPlainText -Force ``` ### Correct ```powershell -$SecureUserInput = Read-Host "Please enter your secure code" -AsSecureString +$SecureUserInput = Read-Host 'Please enter your secure code' -AsSecureString $EncryptedInput = ConvertFrom-SecureString -String $SecureUserInput $SecureString = ConvertTo-SecureString -String $EncryptedInput ``` diff --git a/docs/Rules/AvoidUsingEmptyCatchBlock.md b/docs/Rules/AvoidUsingEmptyCatchBlock.md index 9d675e7ef..16e5ea5d0 100644 --- a/docs/Rules/AvoidUsingEmptyCatchBlock.md +++ b/docs/Rules/AvoidUsingEmptyCatchBlock.md @@ -41,7 +41,7 @@ try } catch [DivideByZeroException] { - Write-Error "DivideByZeroException" + Write-Error 'DivideByZeroException' } try @@ -50,6 +50,6 @@ try } catch [DivideByZeroException] { - throw "DivideByZeroException" + throw 'DivideByZeroException' } ``` diff --git a/docs/Rules/AvoidUsingInvokeExpression.md b/docs/Rules/AvoidUsingInvokeExpression.md index ba37de8c7..eb51e2ee6 100644 --- a/docs/Rules/AvoidUsingInvokeExpression.md +++ b/docs/Rules/AvoidUsingInvokeExpression.md @@ -26,7 +26,7 @@ Remove the use of `Invoke-Expression`. ### Wrong ```powershell -Invoke-Expression "Get-Process" +Invoke-Expression 'Get-Process' ``` ### Correct diff --git a/docs/Rules/AvoidUsingWMICmdlet.md b/docs/Rules/AvoidUsingWMICmdlet.md index 3adb521d4..3e81b6444 100644 --- a/docs/Rules/AvoidUsingWMICmdlet.md +++ b/docs/Rules/AvoidUsingWMICmdlet.md @@ -48,12 +48,12 @@ Change to the equivalent CIM based cmdlet. ```powershell Get-WmiObject -Query 'Select * from Win32_Process where name LIKE "myprocess%"' | Remove-WmiObject -Invoke-WmiMethod -Class Win32_Process -Name "Create" -ArgumentList @{ CommandLine = "notepad.exe" } +Invoke-WmiMethod -Class Win32_Process -Name 'Create' -ArgumentList @{ CommandLine = 'notepad.exe' } ``` ### Correct ```powershell Get-CimInstance -Query 'Select * from Win32_Process where name LIKE "myprocess%"' | Remove-CIMInstance -Invoke-CimMethod -ClassName Win32_Process -MethodName "Create" -Arguments @{ CommandLine = "notepad.exe" } +Invoke-CimMethod -ClassName Win32_Process -MethodName 'Create' -Arguments @{ CommandLine = 'notepad.exe' } ``` diff --git a/docs/Rules/AvoidUsingWriteHost.md b/docs/Rules/AvoidUsingWriteHost.md index 44dc220f7..e04d4f9d0 100644 --- a/docs/Rules/AvoidUsingWriteHost.md +++ b/docs/Rules/AvoidUsingWriteHost.md @@ -12,7 +12,7 @@ title: AvoidUsingWriteHost ## Description The use of `Write-Host` is greatly discouraged unless in the use of commands with the `Show` verb. -The `Show` verb explicitly means "show on the screen, with no other possibilities". +The `Show` verb explicitly means 'show on the screen, with no other possibilities'. Commands with the `Show` verb do not have this check applied. @@ -29,7 +29,7 @@ logging or returning one or more objects. function Get-MeaningOfLife { ... - Write-Host "Computing the answer to the ultimate question of life, the universe and everything" + Write-Host 'Computing the answer to the ultimate question of life, the universe and everything' ... Write-Host 42 } @@ -42,13 +42,13 @@ function Get-MeaningOfLife { [CmdletBinding()]Param() # to make it possible to set the VerbosePreference when calling the function ... - Write-Verbose "Computing the answer to the ultimate question of life, the universe and everything" + Write-Verbose 'Computing the answer to the ultimate question of life, the universe and everything' ... Write-Output 42 } function Show-Something { - Write-Host "show something on screen"; + Write-Host 'show something on screen' } ``` diff --git a/docs/Rules/DSCUseVerboseMessageInDSCResource.md b/docs/Rules/DSCUseVerboseMessageInDSCResource.md index cf58a30b0..e8e4c725b 100644 --- a/docs/Rules/DSCUseVerboseMessageInDSCResource.md +++ b/docs/Rules/DSCUseVerboseMessageInDSCResource.md @@ -38,7 +38,7 @@ Function Test-Function { [CmdletBinding()] Param() - Write-Verbose "Verbose output" + Write-Verbose 'Verbose output' ... } ``` diff --git a/docs/Rules/PlaceCloseBrace.md b/docs/Rules/PlaceCloseBrace.md index 4a55e3ad2..8c3ef3fcd 100644 --- a/docs/Rules/PlaceCloseBrace.md +++ b/docs/Rules/PlaceCloseBrace.md @@ -42,7 +42,7 @@ Create violation if there is an empty line before a close brace. #### IgnoreOneLineBlock: bool (Default value is `$true`) Indicates if closed brace pairs in a one line block should be ignored or not. For example, -`$x = if ($true) { "blah" } else { "blah blah" }`, if the property is set to true then the rule +`$x = if ($true) { 'blah' } else { 'blah blah' }`, if the property is set to true then the rule doesn't fire a violation. #### NewLineAfter: bool (Default value is `$true`) diff --git a/docs/Rules/PlaceOpenBrace.md b/docs/Rules/PlaceOpenBrace.md index 0c873e6a5..876c25131 100644 --- a/docs/Rules/PlaceOpenBrace.md +++ b/docs/Rules/PlaceOpenBrace.md @@ -46,5 +46,5 @@ Enforce a new line character after an open brace. The default value is true. #### IgnoreOneLineBlock: bool (Default value is `$true`) Indicates if open braces in a one line block should be ignored or not. For example, -` $x = if ($true) { "blah" } else { "blah blah" }`, if the property is set to true then the rule +` $x = if ($true) { 'blah' } else { 'blah blah' }`, if the property is set to true then the rule doesn't fire a violation. diff --git a/docs/Rules/ProvideCommentHelp.md b/docs/Rules/ProvideCommentHelp.md index b9305da14..5c1f225b4 100644 --- a/docs/Rules/ProvideCommentHelp.md +++ b/docs/Rules/ProvideCommentHelp.md @@ -30,7 +30,7 @@ Rules = @{ ExportedOnly = $false BlockComment = $true VSCodeSnippetCorrection = $false - Placement = "before" + Placement = 'before' } } ``` diff --git a/docs/Rules/ShouldProcess.md b/docs/Rules/ShouldProcess.md index 2e50e2764..5fb2a3adb 100644 --- a/docs/Rules/ShouldProcess.md +++ b/docs/Rules/ShouldProcess.md @@ -42,7 +42,7 @@ function Set-File [Parameter(Mandatory=$true)] $Path ) - "String" | Out-File -FilePath $Path + 'String' | Out-File -FilePath $Path } ``` @@ -62,7 +62,7 @@ function Set-File [string]$Content ) - if ($PSCmdlet.ShouldProcess($Path, ("Setting content to '{0}'" -f $Content))) + if ($PSCmdlet.ShouldProcess($Path, ('Setting content to '{0}'' -f $Content))) { $Content | Out-File -FilePath $Path } diff --git a/docs/Rules/UseCompatibleCmdlets.md b/docs/Rules/UseCompatibleCmdlets.md index 6a9d62d95..0dcfb22e3 100644 --- a/docs/Rules/UseCompatibleCmdlets.md +++ b/docs/Rules/UseCompatibleCmdlets.md @@ -23,7 +23,7 @@ the following your settings file: @{ 'Rules' = @{ 'PSUseCompatibleCmdlets' = @{ - 'compatibility' = @("core-6.1.0-windows") + 'compatibility' = @('core-6.1.0-windows') } } } diff --git a/docs/Rules/UseCompatibleCommands.md b/docs/Rules/UseCompatibleCommands.md index 3eb650322..779956391 100644 --- a/docs/Rules/UseCompatibleCommands.md +++ b/docs/Rules/UseCompatibleCommands.md @@ -82,7 +82,7 @@ The default profile directory is under the PSScriptAnalzyer module at `$PSScriptRoot/compatibility_profiles` (where `$PSScriptRoot` here refers to the directory containing `PSScriptAnalyzer.psd1`). -The compatibility analysis compares a command used to both a target profile and a "union" profile +The compatibility analysis compares a command used to both a target profile and a 'union' profile (containing all commands available in *any* profile in the profile dir). If a command is not present in the union profile, it is assumed to be locally created and ignored. Otherwise, if a command is present in the union profile but not present in a target, it is deemed to be incompatible with that @@ -126,17 +126,17 @@ Command compatibility diagnostics can be suppressed with an attribute on the `pa scriptblock as with other rules. ```powershell -[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSUseCompatibleCommands", "")] +[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseCompatibleCommands', '')] ``` The rule can also be suppressed only for particular commands: ```powershell -[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSUseCompatibleCommands", "Start-Service")] +[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseCompatibleCommands', 'Start-Service')] ``` And also suppressed only for parameters: ```powershell -[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSUseCompatibleCommands", "Import-Module/FullyQualifiedName")] +[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseCompatibleCommands', 'Import-Module/FullyQualifiedName')] ``` diff --git a/docs/Rules/UseCompatibleSyntax.md b/docs/Rules/UseCompatibleSyntax.md index 5a98ea3ec..ce93d2623 100644 --- a/docs/Rules/UseCompatibleSyntax.md +++ b/docs/Rules/UseCompatibleSyntax.md @@ -22,9 +22,9 @@ PowerShell versions because they aren't able to parse the incompatible syntaxes. PSUseCompatibleSyntax = @{ Enable = $true TargetVersions = @( - "6.0", - "5.1", - "4.0" + '6.0', + '5.1', + '4.0' ) } } diff --git a/docs/Rules/UseCompatibleTypes.md b/docs/Rules/UseCompatibleTypes.md index cd9da007d..836607979 100644 --- a/docs/Rules/UseCompatibleTypes.md +++ b/docs/Rules/UseCompatibleTypes.md @@ -83,8 +83,8 @@ The default profile directory is under the PSScriptAnalzyer module at `$PSScriptRoot/PSCompatibilityCollector/profiles` (where `$PSScriptRoot` here refers to the directory containing `PSScriptAnalyzer.psd1`). -The compatibility analysis compares a type used to both a target profile and a "union" profile -(containing all types available in *any* profile in the profile dir). If a type is not present in +The compatibility analysis compares a type used to both a target profile and a 'union' profile +(containing all types available in _any_ profile in the profile dir). If a type is not present in the union profile, it is assumed to be locally created and ignored. Otherwise, if a type is present in the union profile but not present in a target, it is deemed to be incompatible with that target. @@ -127,11 +127,11 @@ PS> $settings = @{ Rules = @{ PSUseCompatibleTypes = @{ Enable = $true - TargetProfiles = @("win-48_x64_10.0.17763.0_5.1.17763.316_x64_4.0.30319.42000_framework") + TargetProfiles = @('win-48_x64_10.0.17763.0_5.1.17763.316_x64_4.0.30319.42000_framework') } } } -PS> Invoke-ScriptAnalyzer -Settings $settings -ScriptDefinition '[System.Management.Automation.SemanticVersion]"1.18.0-rc1"' +PS> Invoke-ScriptAnalyzer -Settings $settings -ScriptDefinition '[System.Management.Automation.SemanticVersion]'1.18.0-rc1'' RuleName Severity ScriptName Line Message -------- -------- ---------- ---- ------- @@ -146,17 +146,17 @@ Command compatibility diagnostics can be suppressed with an attribute on the `pa scriptblock as with other rules. ```powershell -[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSUseCompatibleTypes", "")] +[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseCompatibleTypes', '')] ``` The rule can also be suppressed only for particular types: ```powershell -[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSUseCompatibleTypes", "System.Management.Automation.Security.SystemPolicy")] +[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseCompatibleTypes', 'System.Management.Automation.Security.SystemPolicy')] ``` And also suppressed only for type members: ```powershell -[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSUseCompatibleCommands", "System.Management.Automation.LanguagePrimitives/ConvertTypeNameToPSTypeName")] +[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseCompatibleCommands', 'System.Management.Automation.LanguagePrimitives/ConvertTypeNameToPSTypeName')] ``` diff --git a/docs/Rules/UseDeclaredVarsMoreThanAssignments.md b/docs/Rules/UseDeclaredVarsMoreThanAssignments.md index 3f66d7b03..2c37e4efc 100644 --- a/docs/Rules/UseDeclaredVarsMoreThanAssignments.md +++ b/docs/Rules/UseDeclaredVarsMoreThanAssignments.md @@ -15,7 +15,7 @@ Variables that are assigned but not used are not needed. > [!NOTE] > For this rule, the variable must be used within the same scriptblock that it was declared or it -> won't be considered to be "used". +> won't be considered to be 'used'. ## How @@ -28,8 +28,8 @@ Remove the variables that are declared but not used. ```powershell function Test { - $declaredVar = "Declared just for fun" - $declaredVar2 = "Not used" + $declaredVar = 'Declared just for fun' + $declaredVar2 = 'Not used' Write-Output $declaredVar } ``` @@ -39,7 +39,7 @@ function Test ```powershell function Test { - $declaredVar = "Declared just for fun" + $declaredVar = 'Declared just for fun' Write-Output $declaredVar } ``` diff --git a/docs/Rules/UseOutputTypeCorrectly.md b/docs/Rules/UseOutputTypeCorrectly.md index ee531d1b7..64482db93 100644 --- a/docs/Rules/UseOutputTypeCorrectly.md +++ b/docs/Rules/UseOutputTypeCorrectly.md @@ -45,6 +45,6 @@ function Get-Foo Param( ) - return "four" + return 'four' } ``` diff --git a/docs/Rules/UseUsingScopeModifierInNewRunspaces.md b/docs/Rules/UseUsingScopeModifierInNewRunspaces.md index b17a471b5..dfab8d1a2 100644 --- a/docs/Rules/UseUsingScopeModifierInNewRunspaces.md +++ b/docs/Rules/UseUsingScopeModifierInNewRunspaces.md @@ -32,40 +32,40 @@ Within the ScriptBlock, instead of just using a variable from the parent scope, ### Wrong ```powershell -$var = "foo" +$var = 'foo' 1..2 | ForEach-Object -Parallel { $var } ``` ### Correct ```powershell -$var = "foo" +$var = 'foo' 1..2 | ForEach-Object -Parallel { $using:var } ``` ## More correct examples ```powershell -$bar = "bar" -Invoke-Command -ComputerName "foo" -ScriptBlock { $using:bar } +$bar = 'bar' +Invoke-Command -ComputerName 'foo' -ScriptBlock { $using:bar } ``` ```powershell -$bar = "bar" -$s = New-PSSession -ComputerName "foo" +$bar = 'bar' +$s = New-PSSession -ComputerName 'foo' Invoke-Command -Session $s -ScriptBlock { $using:bar } ``` ```powershell # Remark: Workflow is supported on Windows PowerShell only Workflow { - $foo = "foo" + $foo = 'foo' InlineScript { $using:foo } } ``` ```powershell -$foo = "foo" +$foo = 'foo' Start-ThreadJob -ScriptBlock { $using:foo } Start-Job -ScriptBlock {$using:foo } ``` From 60c27ac458a8a5a9887ff897c1ef4235a59dd978 Mon Sep 17 00:00:00 2001 From: Sean Wheeler Date: Sun, 7 May 2023 09:22:54 -0700 Subject: [PATCH 13/42] Copy change from docs PR#143 (#1910) --- docs/Rules/PossibleIncorrectComparisonWithNull.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/Rules/PossibleIncorrectComparisonWithNull.md b/docs/Rules/PossibleIncorrectComparisonWithNull.md index 671f4914f..fbeed7318 100644 --- a/docs/Rules/PossibleIncorrectComparisonWithNull.md +++ b/docs/Rules/PossibleIncorrectComparisonWithNull.md @@ -66,7 +66,7 @@ This is how the comparison operator works by-design. But, as demonstrated, this to non-intuitive behavior, especially when the intent is simple test for null. The following example demonstrates the designed behavior of the comparison operator when the -left-hand side is a collection. Each element in the collection is compared the right-hand side +left-hand side is a collection. Each element in the collection is compared to the right-hand side value. When true, that element of the collection is returned. ```powershell From 9f456d05b95421090fa63e1bb7378231291b36b6 Mon Sep 17 00:00:00 2001 From: Sean Wheeler Date: Wed, 24 May 2023 15:01:06 -0500 Subject: [PATCH 14/42] Fix typos in rules (#1913) --- docs/Rules/AvoidUsingComputerNameHardcoded.md | 2 +- docs/Rules/ShouldProcess.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/Rules/AvoidUsingComputerNameHardcoded.md b/docs/Rules/AvoidUsingComputerNameHardcoded.md index 7e4120ceb..f6374a305 100644 --- a/docs/Rules/AvoidUsingComputerNameHardcoded.md +++ b/docs/Rules/AvoidUsingComputerNameHardcoded.md @@ -45,7 +45,7 @@ Function Invoke-MyCommand ($ComputerName) ```powershell Function Invoke-MyLocalCommand () { - Invoke-Command -Port 343 -ComputerName 'hardcodelocalhostname' + Invoke-Command -Port 343 -ComputerName hardcodelocalhostname } ``` diff --git a/docs/Rules/ShouldProcess.md b/docs/Rules/ShouldProcess.md index 5fb2a3adb..86c894553 100644 --- a/docs/Rules/ShouldProcess.md +++ b/docs/Rules/ShouldProcess.md @@ -62,7 +62,7 @@ function Set-File [string]$Content ) - if ($PSCmdlet.ShouldProcess($Path, ('Setting content to '{0}'' -f $Content))) + if ($PSCmdlet.ShouldProcess($Path, ("Setting content to '{0}'" -f $Content))) { $Content | Out-File -FilePath $Path } From 5ba330a65af5fa8ce810158f9271e1524ae2edf8 Mon Sep 17 00:00:00 2001 From: Travis Plunk Date: Wed, 31 May 2023 14:54:41 -0700 Subject: [PATCH 15/42] add demand for compliance job (#1920) --- .ci/releaseBuild.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.ci/releaseBuild.yml b/.ci/releaseBuild.yml index 9878498d9..57042b77c 100644 --- a/.ci/releaseBuild.yml +++ b/.ci/releaseBuild.yml @@ -171,6 +171,9 @@ stages: - job: Compliance_Job pool: name: PowerShell1ES # was Package ES CodeHub Lab E + demands: + - ImageOverride -equals PSMMS2019-Secure + steps: - checkout: self - checkout: ComplianceRepo From fadde3d83c2bac8ade3575fe2eea74a37b69349f Mon Sep 17 00:00:00 2001 From: "microsoft-github-policy-service[bot]" <77245923+microsoft-github-policy-service[bot]@users.noreply.github.com> Date: Tue, 18 Jul 2023 10:57:35 +0100 Subject: [PATCH 16/42] FabricBot: Onboarding to GitOps.ResourceManagement because of FabricBot decommissioning (#1925) * Add prIssueManagement.yml to onboard repo to GitOps.ResourceManagement as FabricBot replacement Owners of the FabricBot configuration should have received email notification. The same information contained in the email is published internally at: https://aka.ms/gim/fabricbot. Details on the replacement service and the syntax of the new yaml configuration file is available publicly at: https://microsoft.github.io/GitOps/policies/resource-management.html Please review and merge this PR to complete the process of onboarding to the new service. * Deleting fabricbot.json --------- Co-authored-by: microsoft-github-policy-service[bot] <77245923+microsoft-github-policy-service[bot]@users.noreply.github.com> --- .github/fabricbot.json | 711 ------------------------ .github/policies/resourceManagement.yml | 92 +++ 2 files changed, 92 insertions(+), 711 deletions(-) delete mode 100644 .github/fabricbot.json create mode 100644 .github/policies/resourceManagement.yml diff --git a/.github/fabricbot.json b/.github/fabricbot.json deleted file mode 100644 index fbe8db42c..000000000 --- a/.github/fabricbot.json +++ /dev/null @@ -1,711 +0,0 @@ -{ - "version": "1.0", - "tasks": [ - { - "taskType": "trigger", - "capabilityId": "IssueResponder", - "subCapability": "IssuesOnlyResponder", - "version": "1.0", - "config": { - "taskName": "Add needs triage label to new issues", - "conditions": { - "operator": "and", - "operands": [ - { - "name": "isAction", - "parameters": { - "action": "opened" - } - }, - { - "operator": "not", - "operands": [ - { - "name": "isPartOfProject", - "parameters": {} - } - ] - }, - { - "operator": "not", - "operands": [ - { - "name": "isAssignedToSomeone", - "parameters": {} - } - ] - } - ] - }, - "actions": [ - { - "name": "addLabel", - "parameters": { - "label": "Needs: Triage :mag:" - } - } - ], - "eventType": "issue", - "eventNames": [ - "issues", - "project_card" - ] - }, - "id": "gEuS61IET", - "disabled": false - }, - { - "taskType": "scheduled", - "capabilityId": "ScheduledSearch", - "subCapability": "ScheduledSearch", - "version": "1.1", - "config": { - "taskName": "Close duplicate issues", - "frequency": [ - { - "weekDay": 0, - "hours": [ - 2, - 5, - 8, - 11, - 14, - 17, - 20, - 23 - ], - "timezoneOffset": -8 - }, - { - "weekDay": 1, - "hours": [ - 2, - 5, - 8, - 11, - 14, - 17, - 20, - 23 - ], - "timezoneOffset": -8 - }, - { - "weekDay": 2, - "hours": [ - 2, - 5, - 8, - 11, - 14, - 17, - 20, - 23 - ], - "timezoneOffset": -8 - }, - { - "weekDay": 3, - "hours": [ - 2, - 5, - 8, - 11, - 14, - 17, - 20, - 23 - ], - "timezoneOffset": -8 - }, - { - "weekDay": 4, - "hours": [ - 2, - 5, - 8, - 11, - 14, - 17, - 20, - 23 - ], - "timezoneOffset": -8 - }, - { - "weekDay": 5, - "hours": [ - 2, - 5, - 8, - 11, - 14, - 17, - 20, - 23 - ], - "timezoneOffset": -8 - }, - { - "weekDay": 6, - "hours": [ - 2, - 5, - 8, - 11, - 14, - 17, - 20, - 23 - ], - "timezoneOffset": -8 - } - ], - "searchTerms": [ - { - "name": "isIssue", - "parameters": {} - }, - { - "name": "isOpen", - "parameters": {} - }, - { - "name": "hasLabel", - "parameters": { - "label": "Resolution - Duplicate" - } - }, - { - "name": "noActivitySince", - "parameters": { - "days": 1 - } - } - ], - "actions": [ - { - "name": "addReply", - "parameters": { - "comment": "This issue has been marked as duplicate and has not had any activity for **1 day**. It will be closed for housekeeping purposes." - } - }, - { - "name": "closeIssue", - "parameters": {} - } - ] - }, - "id": "exOradLcY", - "disabled": false - }, - { - "taskType": "scheduled", - "capabilityId": "ScheduledSearch", - "subCapability": "ScheduledSearch", - "version": "1.1", - "id": "Mx1BeKlyM", - "config": { - "frequency": [ - { - "weekDay": 0, - "hours": [ - 0, - 6, - 12, - 18 - ] - }, - { - "weekDay": 1, - "hours": [ - 0, - 6, - 12, - 18 - ] - }, - { - "weekDay": 2, - "hours": [ - 0, - 6, - 12, - 18 - ] - }, - { - "weekDay": 3, - "hours": [ - 0, - 6, - 12, - 18 - ] - }, - { - "weekDay": 4, - "hours": [ - 0, - 6, - 12, - 18 - ] - }, - { - "weekDay": 5, - "hours": [ - 0, - 6, - 12, - 18 - ] - }, - { - "weekDay": 6, - "hours": [ - 0, - 6, - 12, - 18 - ] - } - ], - "searchTerms": [ - { - "name": "isOpen", - "parameters": {} - }, - { - "name": "hasLabel", - "parameters": { - "label": "Resolution - Answered" - } - }, - { - "name": "noActivitySince", - "parameters": { - "days": 7 - } - } - ], - "actions": [ - { - "name": "closeIssue", - "parameters": {} - } - ], - "taskName": "Close Answered Issues" - } - }, - { - "taskType": "scheduled", - "capabilityId": "ScheduledSearch", - "subCapability": "ScheduledSearch", - "version": "1.1", - "id": "-3BK34t2l", - "config": { - "frequency": [ - { - "weekDay": 0, - "hours": [ - 0, - 6, - 12, - 18 - ] - }, - { - "weekDay": 1, - "hours": [ - 0, - 6, - 12, - 18 - ] - }, - { - "weekDay": 2, - "hours": [ - 0, - 6, - 12, - 18 - ] - }, - { - "weekDay": 3, - "hours": [ - 0, - 6, - 12, - 18 - ] - }, - { - "weekDay": 4, - "hours": [ - 0, - 6, - 12, - 18 - ] - }, - { - "weekDay": 5, - "hours": [ - 0, - 6, - 12, - 18 - ] - }, - { - "weekDay": 6, - "hours": [ - 0, - 6, - 12, - 18 - ] - } - ], - "searchTerms": [ - { - "name": "isOpen", - "parameters": {} - }, - { - "name": "hasLabel", - "parameters": { - "label": "Resolution - External" - } - }, - { - "name": "noActivitySince", - "parameters": { - "days": 7 - } - } - ], - "taskName": "Close External Issues", - "actions": [ - { - "name": "closeIssue", - "parameters": {} - } - ] - } - }, - { - "taskType": "scheduled", - "capabilityId": "ScheduledSearch", - "subCapability": "ScheduledSearch", - "version": "1.1", - "id": "HJ_mnzjns", - "config": { - "frequency": [ - { - "weekDay": 0, - "hours": [ - 0, - 6, - 12, - 18 - ] - }, - { - "weekDay": 1, - "hours": [ - 0, - 6, - 12, - 18 - ] - }, - { - "weekDay": 2, - "hours": [ - 0, - 6, - 12, - 18 - ] - }, - { - "weekDay": 3, - "hours": [ - 0, - 6, - 12, - 18 - ] - }, - { - "weekDay": 4, - "hours": [ - 0, - 6, - 12, - 18 - ] - }, - { - "weekDay": 5, - "hours": [ - 0, - 6, - 12, - 18 - ] - }, - { - "weekDay": 6, - "hours": [ - 0, - 6, - 12, - 18 - ] - } - ], - "searchTerms": [ - { - "name": "isOpen", - "parameters": {} - }, - { - "name": "hasLabel", - "parameters": { - "label": "Resolution - Fixed" - } - }, - { - "name": "noActivitySince", - "parameters": { - "days": 7 - } - } - ], - "taskName": "Close Fixed Issues", - "actions": [ - { - "name": "closeIssue", - "parameters": {} - } - ] - } - }, - { - "taskType": "scheduled", - "capabilityId": "ScheduledSearch", - "subCapability": "ScheduledSearch", - "version": "1.1", - "id": "UXVP56PHc", - "config": { - "frequency": [ - { - "weekDay": 0, - "hours": [ - 0, - 6, - 12, - 18 - ] - }, - { - "weekDay": 1, - "hours": [ - 0, - 6, - 12, - 18 - ] - }, - { - "weekDay": 2, - "hours": [ - 0, - 6, - 12, - 18 - ] - }, - { - "weekDay": 3, - "hours": [ - 0, - 6, - 12, - 18 - ] - }, - { - "weekDay": 4, - "hours": [ - 0, - 6, - 12, - 18 - ] - }, - { - "weekDay": 5, - "hours": [ - 0, - 6, - 12, - 18 - ] - }, - { - "weekDay": 6, - "hours": [ - 0, - 6, - 12, - 18 - ] - } - ], - "searchTerms": [ - { - "name": "isOpen", - "parameters": {} - }, - { - "name": "hasLabel", - "parameters": { - "label": "Resolution - Won't Fix" - } - }, - { - "name": "noActivitySince", - "parameters": { - "days": 7 - } - } - ], - "taskName": "Close Wont Fix", - "actions": [ - { - "name": "closeIssue", - "parameters": {} - } - ] - } - }, - { - "taskType": "scheduled", - "capabilityId": "ScheduledSearch", - "subCapability": "ScheduledSearch", - "version": "1.1", - "id": "eklMZQWVo", - "config": { - "frequency": [ - { - "weekDay": 0, - "hours": [ - 0, - 6, - 12, - 18 - ] - }, - { - "weekDay": 1, - "hours": [ - 0, - 6, - 12, - 18 - ] - }, - { - "weekDay": 2, - "hours": [ - 0, - 6, - 12, - 18 - ] - }, - { - "weekDay": 3, - "hours": [ - 0, - 6, - 12, - 18 - ] - }, - { - "weekDay": 4, - "hours": [ - 0, - 6, - 12, - 18 - ] - }, - { - "weekDay": 5, - "hours": [ - 0, - 6, - 12, - 18 - ] - }, - { - "weekDay": 6, - "hours": [ - 0, - 6, - 12, - 18 - ] - } - ], - "searchTerms": [ - { - "name": "isOpen", - "parameters": {} - }, - { - "name": "hasLabel", - "parameters": { - "label": "Need Repro Info" - } - }, - { - "name": "noActivitySince", - "parameters": { - "days": 14 - } - }, - { - "name": "noLabel", - "parameters": { - "label": "Issue - Bug" - } - } - ], - "taskName": "Close Stale Issues ", - "actions": [ - { - "name": "addReply", - "parameters": { - "comment": "Closing due to inactivity" - } - }, - { - "name": "closeIssue", - "parameters": {} - } - ] - } - } - ], - "userGroups": [] -} diff --git a/.github/policies/resourceManagement.yml b/.github/policies/resourceManagement.yml new file mode 100644 index 000000000..c5262aa28 --- /dev/null +++ b/.github/policies/resourceManagement.yml @@ -0,0 +1,92 @@ +id: +name: GitOps.PullRequestIssueManagement +description: GitOps.PullRequestIssueManagement primitive +owner: +resource: repository +disabled: false +where: +configuration: + resourceManagementConfiguration: + scheduledSearches: + - description: + frequencies: + - hourly: + hour: 3 + filters: + - isIssue + - isOpen + - hasLabel: + label: Resolution - Duplicate + - noActivitySince: + days: 1 + actions: + - addReply: + reply: This issue has been marked as duplicate and has not had any activity for **1 day**. It will be closed for housekeeping purposes. + - closeIssue + - description: + frequencies: + - hourly: + hour: 6 + filters: + - isOpen + - hasLabel: + label: Resolution - Answered + - noActivitySince: + days: 7 + actions: + - closeIssue + - description: + frequencies: + - hourly: + hour: 6 + filters: + - isOpen + - hasLabel: + label: Resolution - External + - noActivitySince: + days: 7 + actions: + - closeIssue + - description: + frequencies: + - hourly: + hour: 6 + filters: + - isOpen + - hasLabel: + label: Resolution - Fixed + - noActivitySince: + days: 7 + actions: + - closeIssue + - description: + frequencies: + - hourly: + hour: 6 + filters: + - isOpen + - hasLabel: + label: Resolution - Won't Fix + - noActivitySince: + days: 7 + actions: + - closeIssue + - description: + frequencies: + - hourly: + hour: 6 + filters: + - isOpen + - hasLabel: + label: Need Repro Info + - noActivitySince: + days: 14 + - isNotLabeledWith: + label: Issue - Bug + actions: + - addReply: + reply: Closing due to inactivity + - closeIssue + eventResponderTasks: [] +onFailure: +onSuccess: From 94c47ba6235aa6693d80d7341a9b75e8044689d3 Mon Sep 17 00:00:00 2001 From: Sean Wheeler Date: Thu, 10 Aug 2023 15:06:02 -0500 Subject: [PATCH 17/42] Sync change from Docs repository (#1929) --- docs/Rules/AlignAssignmentStatement.md | 2 +- docs/Rules/AvoidAssignmentToAutomaticVariable.md | 2 +- docs/Rules/AvoidDefaultValueForMandatoryParameter.md | 2 +- docs/Rules/AvoidDefaultValueSwitchParameter.md | 2 +- docs/Rules/AvoidGlobalAliases.md | 2 +- docs/Rules/AvoidGlobalFunctions.md | 2 +- docs/Rules/AvoidGlobalVars.md | 2 +- docs/Rules/AvoidInvokingEmptyMembers.md | 2 +- docs/Rules/AvoidLongLines.md | 2 +- docs/Rules/AvoidMultipleTypeAttributes.md | 2 +- docs/Rules/AvoidNullOrEmptyHelpMessageAttribute.md | 2 +- docs/Rules/AvoidOverwritingBuiltInCmdlets.md | 2 +- docs/Rules/AvoidSemicolonsAsLineTerminators.md | 2 +- docs/Rules/AvoidShouldContinueWithoutForce.md | 2 +- docs/Rules/AvoidTrailingWhitespace.md | 2 +- docs/Rules/AvoidUsingBrokenHashAlgorithms.md | 2 +- docs/Rules/AvoidUsingCmdletAliases.md | 2 +- docs/Rules/AvoidUsingComputerNameHardcoded.md | 2 +- docs/Rules/AvoidUsingConvertToSecureStringWithPlainText.md | 2 +- docs/Rules/AvoidUsingDeprecatedManifestFields.md | 2 +- docs/Rules/AvoidUsingDoubleQuotesForConstantString.md | 2 +- docs/Rules/AvoidUsingEmptyCatchBlock.md | 2 +- docs/Rules/AvoidUsingInvokeExpression.md | 2 +- docs/Rules/AvoidUsingPlainTextForPassword.md | 2 +- docs/Rules/AvoidUsingPositionalParameters.md | 2 +- docs/Rules/AvoidUsingUsernameAndPasswordParams.md | 2 +- docs/Rules/AvoidUsingWMICmdlet.md | 6 +++--- docs/Rules/AvoidUsingWriteHost.md | 2 +- docs/Rules/DSCDscExamplesPresent.md | 2 +- docs/Rules/DSCDscTestsPresent.md | 2 +- docs/Rules/DSCReturnCorrectTypesForDSCFunctions.md | 2 +- docs/Rules/DSCStandardDSCFunctionsInResource.md | 2 +- docs/Rules/DSCUseIdenticalMandatoryParametersForDSC.md | 2 +- docs/Rules/DSCUseIdenticalParametersForDSC.md | 2 +- docs/Rules/DSCUseVerboseMessageInDSCResource.md | 2 +- docs/Rules/MisleadingBacktick.md | 2 +- docs/Rules/MissingModuleManifestField.md | 2 +- docs/Rules/PlaceCloseBrace.md | 2 +- docs/Rules/PlaceOpenBrace.md | 2 +- docs/Rules/PossibleIncorrectComparisonWithNull.md | 2 +- docs/Rules/PossibleIncorrectUsageOfAssignmentOperator.md | 2 +- docs/Rules/PossibleIncorrectUsageOfRedirectionOperator.md | 2 +- docs/Rules/ProvideCommentHelp.md | 2 +- docs/Rules/README.md | 2 +- docs/Rules/ReservedCmdletChar.md | 2 +- docs/Rules/ReservedParams.md | 2 +- docs/Rules/ReviewUnusedParameter.md | 2 +- docs/Rules/ShouldProcess.md | 2 +- docs/Rules/UseApprovedVerbs.md | 2 +- docs/Rules/UseBOMForUnicodeEncodedFile.md | 2 +- docs/Rules/UseCmdletCorrectly.md | 2 +- docs/Rules/UseCompatibleCmdlets.md | 2 +- docs/Rules/UseCompatibleCommands.md | 2 +- docs/Rules/UseCompatibleSyntax.md | 2 +- docs/Rules/UseCompatibleTypes.md | 2 +- docs/Rules/UseConsistentIndentation.md | 2 +- docs/Rules/UseConsistentWhitespace.md | 2 +- docs/Rules/UseCorrectCasing.md | 2 +- docs/Rules/UseDeclaredVarsMoreThanAssignments.md | 2 +- docs/Rules/UseLiteralInitializerForHashtable.md | 2 +- docs/Rules/UseOutputTypeCorrectly.md | 2 +- docs/Rules/UsePSCredentialType.md | 2 +- docs/Rules/UseProcessBlockForPipelineCommand.md | 2 +- docs/Rules/UseShouldProcessForStateChangingFunctions.md | 2 +- docs/Rules/UseSingularNouns.md | 2 +- docs/Rules/UseSupportsShouldProcess.md | 2 +- docs/Rules/UseToExportFieldsInManifest.md | 2 +- docs/Rules/UseUTF8EncodingForHelpFile.md | 2 +- docs/Rules/UseUsingScopeModifierInNewRunspaces.md | 2 +- 69 files changed, 71 insertions(+), 71 deletions(-) diff --git a/docs/Rules/AlignAssignmentStatement.md b/docs/Rules/AlignAssignmentStatement.md index 1a3b7426f..21d5cfbc7 100644 --- a/docs/Rules/AlignAssignmentStatement.md +++ b/docs/Rules/AlignAssignmentStatement.md @@ -1,7 +1,7 @@ --- description: Align assignment statement ms.custom: PSSA v1.21.0 -ms.date: 10/18/2021 +ms.date: 06/28/2023 ms.topic: reference title: AlignAssignmentStatement --- diff --git a/docs/Rules/AvoidAssignmentToAutomaticVariable.md b/docs/Rules/AvoidAssignmentToAutomaticVariable.md index 6e5179525..7a978e32a 100644 --- a/docs/Rules/AvoidAssignmentToAutomaticVariable.md +++ b/docs/Rules/AvoidAssignmentToAutomaticVariable.md @@ -1,7 +1,7 @@ --- description: Changing automatic variables might have undesired side effects ms.custom: PSSA v1.21.0 -ms.date: 10/18/2021 +ms.date: 06/28/2023 ms.topic: reference title: AvoidAssignmentToAutomaticVariable --- diff --git a/docs/Rules/AvoidDefaultValueForMandatoryParameter.md b/docs/Rules/AvoidDefaultValueForMandatoryParameter.md index 8ad74a1a8..71a82605f 100644 --- a/docs/Rules/AvoidDefaultValueForMandatoryParameter.md +++ b/docs/Rules/AvoidDefaultValueForMandatoryParameter.md @@ -1,7 +1,7 @@ --- description: Avoid Default Value For Mandatory Parameter ms.custom: PSSA v1.21.0 -ms.date: 10/18/2021 +ms.date: 06/28/2023 ms.topic: reference title: AvoidDefaultValueForMandatoryParameter --- diff --git a/docs/Rules/AvoidDefaultValueSwitchParameter.md b/docs/Rules/AvoidDefaultValueSwitchParameter.md index 8a797629d..f08ac7732 100644 --- a/docs/Rules/AvoidDefaultValueSwitchParameter.md +++ b/docs/Rules/AvoidDefaultValueSwitchParameter.md @@ -1,7 +1,7 @@ --- description: Switch Parameters Should Not Default To True ms.custom: PSSA v1.21.0 -ms.date: 10/18/2021 +ms.date: 06/28/2023 ms.topic: reference title: AvoidDefaultValueSwitchParameter --- diff --git a/docs/Rules/AvoidGlobalAliases.md b/docs/Rules/AvoidGlobalAliases.md index 8ceeeaf45..9b9463196 100644 --- a/docs/Rules/AvoidGlobalAliases.md +++ b/docs/Rules/AvoidGlobalAliases.md @@ -1,7 +1,7 @@ --- description: Avoid global aliases. ms.custom: PSSA v1.21.0 -ms.date: 10/18/2021 +ms.date: 06/28/2023 ms.topic: reference title: AvoidGlobalAliases --- diff --git a/docs/Rules/AvoidGlobalFunctions.md b/docs/Rules/AvoidGlobalFunctions.md index 86870b31b..cf4ee8fad 100644 --- a/docs/Rules/AvoidGlobalFunctions.md +++ b/docs/Rules/AvoidGlobalFunctions.md @@ -1,7 +1,7 @@ --- description: Avoid global functions and aliases ms.custom: PSSA v1.21.0 -ms.date: 10/18/2021 +ms.date: 06/28/2023 ms.topic: reference title: AvoidGlobalFunctions --- diff --git a/docs/Rules/AvoidGlobalVars.md b/docs/Rules/AvoidGlobalVars.md index 0927c2b2f..54da52443 100644 --- a/docs/Rules/AvoidGlobalVars.md +++ b/docs/Rules/AvoidGlobalVars.md @@ -1,7 +1,7 @@ --- description: No Global Variables ms.custom: PSSA v1.21.0 -ms.date: 10/18/2021 +ms.date: 06/28/2023 ms.topic: reference title: AvoidGlobalVars --- diff --git a/docs/Rules/AvoidInvokingEmptyMembers.md b/docs/Rules/AvoidInvokingEmptyMembers.md index 1d5324c0e..88665f1af 100644 --- a/docs/Rules/AvoidInvokingEmptyMembers.md +++ b/docs/Rules/AvoidInvokingEmptyMembers.md @@ -1,7 +1,7 @@ --- description: Avoid Invoking Empty Members ms.custom: PSSA v1.21.0 -ms.date: 10/18/2021 +ms.date: 06/28/2023 ms.topic: reference title: AvoidInvokingEmptyMembers --- diff --git a/docs/Rules/AvoidLongLines.md b/docs/Rules/AvoidLongLines.md index edc5e30e4..eab82ad64 100644 --- a/docs/Rules/AvoidLongLines.md +++ b/docs/Rules/AvoidLongLines.md @@ -1,7 +1,7 @@ --- description: Avoid long lines ms.custom: PSSA v1.21.0 -ms.date: 10/18/2021 +ms.date: 06/28/2023 ms.topic: reference title: AvoidLongLines --- diff --git a/docs/Rules/AvoidMultipleTypeAttributes.md b/docs/Rules/AvoidMultipleTypeAttributes.md index 03b6af820..5e5dbea69 100644 --- a/docs/Rules/AvoidMultipleTypeAttributes.md +++ b/docs/Rules/AvoidMultipleTypeAttributes.md @@ -1,7 +1,7 @@ --- description: Avoid multiple type specifiers on parameters. ms.custom: PSSA v1.21.0 -ms.date: 10/18/2021 +ms.date: 06/28/2023 ms.topic: reference title: AvoidMultipleTypeAttributes --- diff --git a/docs/Rules/AvoidNullOrEmptyHelpMessageAttribute.md b/docs/Rules/AvoidNullOrEmptyHelpMessageAttribute.md index fa9459275..4ba4d8e9c 100644 --- a/docs/Rules/AvoidNullOrEmptyHelpMessageAttribute.md +++ b/docs/Rules/AvoidNullOrEmptyHelpMessageAttribute.md @@ -1,7 +1,7 @@ --- description: Avoid using null or empty HelpMessage parameter attribute. ms.custom: PSSA v1.21.0 -ms.date: 10/18/2021 +ms.date: 06/28/2023 ms.topic: reference title: AvoidNullOrEmptyHelpMessageAttribute --- diff --git a/docs/Rules/AvoidOverwritingBuiltInCmdlets.md b/docs/Rules/AvoidOverwritingBuiltInCmdlets.md index e579694b9..7ac93454e 100644 --- a/docs/Rules/AvoidOverwritingBuiltInCmdlets.md +++ b/docs/Rules/AvoidOverwritingBuiltInCmdlets.md @@ -1,7 +1,7 @@ --- description: Avoid overwriting built in cmdlets ms.custom: PSSA v1.21.0 -ms.date: 10/18/2021 +ms.date: 06/28/2023 ms.topic: reference title: AvoidOverwritingBuiltInCmdlets --- diff --git a/docs/Rules/AvoidSemicolonsAsLineTerminators.md b/docs/Rules/AvoidSemicolonsAsLineTerminators.md index 65fa0d940..0a496678c 100644 --- a/docs/Rules/AvoidSemicolonsAsLineTerminators.md +++ b/docs/Rules/AvoidSemicolonsAsLineTerminators.md @@ -1,7 +1,7 @@ --- description: Avoid semicolons as line terminators ms.custom: PSSA v1.21.0 -ms.date: 06/15/2022 +ms.date: 06/28/2023 ms.topic: reference title: AvoidSemicolonsAsLineTerminators --- diff --git a/docs/Rules/AvoidShouldContinueWithoutForce.md b/docs/Rules/AvoidShouldContinueWithoutForce.md index 36f5d6061..1ffd4ed7b 100644 --- a/docs/Rules/AvoidShouldContinueWithoutForce.md +++ b/docs/Rules/AvoidShouldContinueWithoutForce.md @@ -1,7 +1,7 @@ --- description: Avoid Using ShouldContinue Without Boolean Force Parameter ms.custom: PSSA v1.21.0 -ms.date: 10/18/2021 +ms.date: 06/28/2023 ms.topic: reference title: AvoidShouldContinueWithoutForce --- diff --git a/docs/Rules/AvoidTrailingWhitespace.md b/docs/Rules/AvoidTrailingWhitespace.md index 1decf9a57..2067cee75 100644 --- a/docs/Rules/AvoidTrailingWhitespace.md +++ b/docs/Rules/AvoidTrailingWhitespace.md @@ -1,7 +1,7 @@ --- description: Avoid trailing whitespace ms.custom: PSSA v1.21.0 -ms.date: 10/18/2021 +ms.date: 06/28/2023 ms.topic: reference title: AvoidTrailingWhitespace --- diff --git a/docs/Rules/AvoidUsingBrokenHashAlgorithms.md b/docs/Rules/AvoidUsingBrokenHashAlgorithms.md index 83b75929c..52510a5e3 100644 --- a/docs/Rules/AvoidUsingBrokenHashAlgorithms.md +++ b/docs/Rules/AvoidUsingBrokenHashAlgorithms.md @@ -1,7 +1,7 @@ --- description: Avoid using broken hash algorithms ms.custom: PSSA v1.21.0 -ms.date: 05/31/2022 +ms.date: 06/28/2023 ms.topic: reference title: AvoidUsingBrokenHashAlgorithms --- diff --git a/docs/Rules/AvoidUsingCmdletAliases.md b/docs/Rules/AvoidUsingCmdletAliases.md index a2c2b010d..87c13b33c 100644 --- a/docs/Rules/AvoidUsingCmdletAliases.md +++ b/docs/Rules/AvoidUsingCmdletAliases.md @@ -1,7 +1,7 @@ --- description: Avoid Using Cmdlet Aliases or omitting the 'Get-' prefix. ms.custom: PSSA v1.21.0 -ms.date: 10/18/2021 +ms.date: 06/28/2023 ms.topic: reference title: AvoidUsingCmdletAliases --- diff --git a/docs/Rules/AvoidUsingComputerNameHardcoded.md b/docs/Rules/AvoidUsingComputerNameHardcoded.md index f6374a305..6ff30b54a 100644 --- a/docs/Rules/AvoidUsingComputerNameHardcoded.md +++ b/docs/Rules/AvoidUsingComputerNameHardcoded.md @@ -1,7 +1,7 @@ --- description: Avoid Using ComputerName Hardcoded ms.custom: PSSA v1.21.0 -ms.date: 10/18/2021 +ms.date: 06/28/2023 ms.topic: reference title: AvoidUsingComputerNameHardcoded --- diff --git a/docs/Rules/AvoidUsingConvertToSecureStringWithPlainText.md b/docs/Rules/AvoidUsingConvertToSecureStringWithPlainText.md index 7e4088238..3c651a400 100644 --- a/docs/Rules/AvoidUsingConvertToSecureStringWithPlainText.md +++ b/docs/Rules/AvoidUsingConvertToSecureStringWithPlainText.md @@ -1,7 +1,7 @@ --- description: Avoid Using SecureString With Plain Text ms.custom: PSSA v1.21.0 -ms.date: 10/18/2021 +ms.date: 06/28/2023 ms.topic: reference title: AvoidUsingConvertToSecureStringWithPlainText --- diff --git a/docs/Rules/AvoidUsingDeprecatedManifestFields.md b/docs/Rules/AvoidUsingDeprecatedManifestFields.md index 9c64d6a0c..bac27c065 100644 --- a/docs/Rules/AvoidUsingDeprecatedManifestFields.md +++ b/docs/Rules/AvoidUsingDeprecatedManifestFields.md @@ -1,7 +1,7 @@ --- description: Avoid Using Deprecated Manifest Fields ms.custom: PSSA v1.21.0 -ms.date: 10/18/2021 +ms.date: 06/28/2023 ms.topic: reference title: AvoidUsingDeprecatedManifestFields --- diff --git a/docs/Rules/AvoidUsingDoubleQuotesForConstantString.md b/docs/Rules/AvoidUsingDoubleQuotesForConstantString.md index 464f1c0a1..ab732fc48 100644 --- a/docs/Rules/AvoidUsingDoubleQuotesForConstantString.md +++ b/docs/Rules/AvoidUsingDoubleQuotesForConstantString.md @@ -1,7 +1,7 @@ --- description: Avoid using double quotes if the string is constant. ms.custom: PSSA v1.21.0 -ms.date: 10/18/2021 +ms.date: 06/28/2023 ms.topic: reference title: AvoidUsingDoubleQuotesForConstantString --- diff --git a/docs/Rules/AvoidUsingEmptyCatchBlock.md b/docs/Rules/AvoidUsingEmptyCatchBlock.md index 16e5ea5d0..0d0749f06 100644 --- a/docs/Rules/AvoidUsingEmptyCatchBlock.md +++ b/docs/Rules/AvoidUsingEmptyCatchBlock.md @@ -1,7 +1,7 @@ --- description: Avoid Using Empty Catch Block ms.custom: PSSA v1.21.0 -ms.date: 10/18/2021 +ms.date: 06/28/2023 ms.topic: reference title: AvoidUsingEmptyCatchBlock --- diff --git a/docs/Rules/AvoidUsingInvokeExpression.md b/docs/Rules/AvoidUsingInvokeExpression.md index eb51e2ee6..de35d16a4 100644 --- a/docs/Rules/AvoidUsingInvokeExpression.md +++ b/docs/Rules/AvoidUsingInvokeExpression.md @@ -1,7 +1,7 @@ --- description: Avoid Using Invoke-Expression ms.custom: PSSA v1.21.0 -ms.date: 10/18/2021 +ms.date: 06/28/2023 ms.topic: reference title: AvoidUsingInvokeExpression --- diff --git a/docs/Rules/AvoidUsingPlainTextForPassword.md b/docs/Rules/AvoidUsingPlainTextForPassword.md index 6f6ba0492..2d53fbbbe 100644 --- a/docs/Rules/AvoidUsingPlainTextForPassword.md +++ b/docs/Rules/AvoidUsingPlainTextForPassword.md @@ -1,7 +1,7 @@ --- description: Avoid Using Plain Text For Password Parameter ms.custom: PSSA v1.21.0 -ms.date: 10/18/2021 +ms.date: 06/28/2023 ms.topic: reference title: AvoidUsingPlainTextForPassword --- diff --git a/docs/Rules/AvoidUsingPositionalParameters.md b/docs/Rules/AvoidUsingPositionalParameters.md index 4cecb2965..6373e11e6 100644 --- a/docs/Rules/AvoidUsingPositionalParameters.md +++ b/docs/Rules/AvoidUsingPositionalParameters.md @@ -1,7 +1,7 @@ --- description: Avoid Using Positional Parameters ms.custom: PSSA v1.21.0 -ms.date: 10/18/2021 +ms.date: 06/28/2023 ms.topic: reference title: AvoidUsingPositionalParameters --- diff --git a/docs/Rules/AvoidUsingUsernameAndPasswordParams.md b/docs/Rules/AvoidUsingUsernameAndPasswordParams.md index cb8a6cf5b..f7c634ff2 100644 --- a/docs/Rules/AvoidUsingUsernameAndPasswordParams.md +++ b/docs/Rules/AvoidUsingUsernameAndPasswordParams.md @@ -1,7 +1,7 @@ --- description: Avoid Using Username and Password Parameters ms.custom: PSSA v1.21.0 -ms.date: 10/18/2021 +ms.date: 06/28/2023 ms.topic: reference title: AvoidUsingUsernameAndPasswordParams --- diff --git a/docs/Rules/AvoidUsingWMICmdlet.md b/docs/Rules/AvoidUsingWMICmdlet.md index 3e81b6444..f1e633fe7 100644 --- a/docs/Rules/AvoidUsingWMICmdlet.md +++ b/docs/Rules/AvoidUsingWMICmdlet.md @@ -1,7 +1,7 @@ --- description: Avoid Using Get-WMIObject, Remove-WMIObject, Invoke-WmiMethod, Register-WmiEvent, Set-WmiInstance ms.custom: PSSA v1.21.0 -ms.date: 10/18/2021 +ms.date: 06/28/2023 ms.topic: reference title: AvoidUsingWMICmdlet --- @@ -17,7 +17,7 @@ The following cmdlets should not be used: - `Get-WmiObject` - `Remove-WmiObject` -- `Invoke-WmiObject` +- `Invoke-WmiMethod` - `Register-WmiEvent` - `Set-WmiInstance` @@ -38,7 +38,7 @@ Change to the equivalent CIM based cmdlet. - `Get-WmiObject` -> `Get-CimInstance` - `Remove-WmiObject` -> `Remove-CimInstance` -- `Invoke-WmiObject` -> `Invoke-CimMethod` +- `Invoke-WmiMethod` -> `Invoke-CimMethod` - `Register-WmiEvent` -> `Register-CimIndicationEvent` - `Set-WmiInstance` -> `Set-CimInstance` diff --git a/docs/Rules/AvoidUsingWriteHost.md b/docs/Rules/AvoidUsingWriteHost.md index e04d4f9d0..31396af81 100644 --- a/docs/Rules/AvoidUsingWriteHost.md +++ b/docs/Rules/AvoidUsingWriteHost.md @@ -1,7 +1,7 @@ --- description: Avoid Using Write-Host ms.custom: PSSA v1.21.0 -ms.date: 10/18/2021 +ms.date: 06/28/2023 ms.topic: reference title: AvoidUsingWriteHost --- diff --git a/docs/Rules/DSCDscExamplesPresent.md b/docs/Rules/DSCDscExamplesPresent.md index 084eb556a..a4ab2c792 100644 --- a/docs/Rules/DSCDscExamplesPresent.md +++ b/docs/Rules/DSCDscExamplesPresent.md @@ -1,7 +1,7 @@ --- description: DSC examples are present ms.custom: PSSA v1.21.0 -ms.date: 10/18/2021 +ms.date: 06/28/2023 ms.topic: reference title: DSCDscExamplesPresent --- diff --git a/docs/Rules/DSCDscTestsPresent.md b/docs/Rules/DSCDscTestsPresent.md index 583a8050b..f96ecbc77 100644 --- a/docs/Rules/DSCDscTestsPresent.md +++ b/docs/Rules/DSCDscTestsPresent.md @@ -1,7 +1,7 @@ --- description: Dsc tests are present ms.custom: PSSA v1.21.0 -ms.date: 10/18/2021 +ms.date: 06/28/2023 ms.topic: reference title: DSCDscTestsPresent --- diff --git a/docs/Rules/DSCReturnCorrectTypesForDSCFunctions.md b/docs/Rules/DSCReturnCorrectTypesForDSCFunctions.md index 2b92d9873..2b0a4e058 100644 --- a/docs/Rules/DSCReturnCorrectTypesForDSCFunctions.md +++ b/docs/Rules/DSCReturnCorrectTypesForDSCFunctions.md @@ -1,7 +1,7 @@ --- description: Return Correct Types For DSC Functions ms.custom: PSSA v1.21.0 -ms.date: 10/18/2021 +ms.date: 06/28/2023 ms.topic: reference title: DSCReturnCorrectTypesForDSCFunctions --- diff --git a/docs/Rules/DSCStandardDSCFunctionsInResource.md b/docs/Rules/DSCStandardDSCFunctionsInResource.md index 843f2d6c5..9fbc2c672 100644 --- a/docs/Rules/DSCStandardDSCFunctionsInResource.md +++ b/docs/Rules/DSCStandardDSCFunctionsInResource.md @@ -1,7 +1,7 @@ --- description: Use Standard Get/Set/Test TargetResource functions in DSC Resource ms.custom: PSSA v1.21.0 -ms.date: 10/18/2021 +ms.date: 06/28/2023 ms.topic: reference title: DSCStandardDSCFunctionsInResource --- diff --git a/docs/Rules/DSCUseIdenticalMandatoryParametersForDSC.md b/docs/Rules/DSCUseIdenticalMandatoryParametersForDSC.md index 5f6f021ab..65a612712 100644 --- a/docs/Rules/DSCUseIdenticalMandatoryParametersForDSC.md +++ b/docs/Rules/DSCUseIdenticalMandatoryParametersForDSC.md @@ -1,7 +1,7 @@ --- description: Use identical mandatory parameters for DSC Get/Test/Set TargetResource functions ms.custom: PSSA v1.21.0 -ms.date: 10/18/2021 +ms.date: 06/28/2023 ms.topic: reference title: DSCUseIdenticalMandatoryParametersForDSC --- diff --git a/docs/Rules/DSCUseIdenticalParametersForDSC.md b/docs/Rules/DSCUseIdenticalParametersForDSC.md index 35d3bb459..ea72db0ba 100644 --- a/docs/Rules/DSCUseIdenticalParametersForDSC.md +++ b/docs/Rules/DSCUseIdenticalParametersForDSC.md @@ -1,7 +1,7 @@ --- description: Use Identical Parameters For DSC Test and Set Functions ms.custom: PSSA v1.21.0 -ms.date: 10/18/2021 +ms.date: 06/28/2023 ms.topic: reference title: DSCUseIdenticalParametersForDSC --- diff --git a/docs/Rules/DSCUseVerboseMessageInDSCResource.md b/docs/Rules/DSCUseVerboseMessageInDSCResource.md index e8e4c725b..0af52de06 100644 --- a/docs/Rules/DSCUseVerboseMessageInDSCResource.md +++ b/docs/Rules/DSCUseVerboseMessageInDSCResource.md @@ -1,7 +1,7 @@ --- description: Use verbose message in DSC resource ms.custom: PSSA v1.21.0 -ms.date: 10/18/2021 +ms.date: 06/28/2023 ms.topic: reference title: DSCUseVerboseMessageInDSCResource --- diff --git a/docs/Rules/MisleadingBacktick.md b/docs/Rules/MisleadingBacktick.md index 3f8950376..02ec622dc 100644 --- a/docs/Rules/MisleadingBacktick.md +++ b/docs/Rules/MisleadingBacktick.md @@ -1,7 +1,7 @@ --- description: Misleading Backtick ms.custom: PSSA v1.21.0 -ms.date: 10/18/2021 +ms.date: 06/28/2023 ms.topic: reference title: MisleadingBacktick --- diff --git a/docs/Rules/MissingModuleManifestField.md b/docs/Rules/MissingModuleManifestField.md index d72f09e4b..a508e7191 100644 --- a/docs/Rules/MissingModuleManifestField.md +++ b/docs/Rules/MissingModuleManifestField.md @@ -1,7 +1,7 @@ --- description: Module Manifest Fields ms.custom: PSSA v1.21.0 -ms.date: 10/18/2021 +ms.date: 06/28/2023 ms.topic: reference title: MissingModuleManifestField --- diff --git a/docs/Rules/PlaceCloseBrace.md b/docs/Rules/PlaceCloseBrace.md index 8c3ef3fcd..11eefc9d8 100644 --- a/docs/Rules/PlaceCloseBrace.md +++ b/docs/Rules/PlaceCloseBrace.md @@ -1,7 +1,7 @@ --- description: Place close braces ms.custom: PSSA v1.21.0 -ms.date: 10/18/2021 +ms.date: 06/28/2023 ms.topic: reference title: PlaceCloseBrace --- diff --git a/docs/Rules/PlaceOpenBrace.md b/docs/Rules/PlaceOpenBrace.md index 876c25131..b3e48e0ce 100644 --- a/docs/Rules/PlaceOpenBrace.md +++ b/docs/Rules/PlaceOpenBrace.md @@ -1,7 +1,7 @@ --- description: Place open braces consistently ms.custom: PSSA v1.21.0 -ms.date: 10/18/2021 +ms.date: 06/28/2023 ms.topic: reference title: PlaceOpenBrace --- diff --git a/docs/Rules/PossibleIncorrectComparisonWithNull.md b/docs/Rules/PossibleIncorrectComparisonWithNull.md index fbeed7318..1c9ea8d24 100644 --- a/docs/Rules/PossibleIncorrectComparisonWithNull.md +++ b/docs/Rules/PossibleIncorrectComparisonWithNull.md @@ -1,7 +1,7 @@ --- description: Null Comparison ms.custom: PSSA v1.21.0 -ms.date: 10/18/2021 +ms.date: 06/28/2023 ms.topic: reference title: PossibleIncorrectComparisonWithNull --- diff --git a/docs/Rules/PossibleIncorrectUsageOfAssignmentOperator.md b/docs/Rules/PossibleIncorrectUsageOfAssignmentOperator.md index 5737b53f7..7981512ff 100644 --- a/docs/Rules/PossibleIncorrectUsageOfAssignmentOperator.md +++ b/docs/Rules/PossibleIncorrectUsageOfAssignmentOperator.md @@ -1,7 +1,7 @@ --- description: Equal sign is not an assignment operator. Did you mean the equality operator \'-eq\'? ms.custom: PSSA v1.21.0 -ms.date: 10/18/2021 +ms.date: 06/28/2023 ms.topic: reference title: PossibleIncorrectUsageOfAssignmentOperator --- diff --git a/docs/Rules/PossibleIncorrectUsageOfRedirectionOperator.md b/docs/Rules/PossibleIncorrectUsageOfRedirectionOperator.md index 9956b92d9..759252cd3 100644 --- a/docs/Rules/PossibleIncorrectUsageOfRedirectionOperator.md +++ b/docs/Rules/PossibleIncorrectUsageOfRedirectionOperator.md @@ -1,7 +1,7 @@ --- description: \'>\' is not a comparison operator. Use \'-gt\' (greater than) or \'-ge\' (greater or equal). ms.custom: PSSA v1.21.0 -ms.date: 10/18/2021 +ms.date: 06/28/2023 ms.topic: reference title: PossibleIncorrectUsageOfRedirectionOperator --- diff --git a/docs/Rules/ProvideCommentHelp.md b/docs/Rules/ProvideCommentHelp.md index 5c1f225b4..e8a45b152 100644 --- a/docs/Rules/ProvideCommentHelp.md +++ b/docs/Rules/ProvideCommentHelp.md @@ -1,7 +1,7 @@ --- description: Basic Comment Help ms.custom: PSSA v1.21.0 -ms.date: 10/18/2021 +ms.date: 06/28/2023 ms.topic: reference title: ProvideCommentHelp --- diff --git a/docs/Rules/README.md b/docs/Rules/README.md index 44062d7c3..4f8a0b4ad 100644 --- a/docs/Rules/README.md +++ b/docs/Rules/README.md @@ -1,7 +1,7 @@ --- description: List of PSScriptAnalyzer rules ms.custom: PSSA v1.21.0 -ms.date: 10/18/2021 +ms.date: 06/28/2023 ms.topic: reference title: List of PSScriptAnalyzer rules --- diff --git a/docs/Rules/ReservedCmdletChar.md b/docs/Rules/ReservedCmdletChar.md index fc9dc6496..2fc57ca3e 100644 --- a/docs/Rules/ReservedCmdletChar.md +++ b/docs/Rules/ReservedCmdletChar.md @@ -1,7 +1,7 @@ --- description: Reserved Cmdlet Chars ms.custom: PSSA v1.21.0 -ms.date: 10/18/2021 +ms.date: 06/28/2023 ms.topic: reference title: ReservedCmdletChar --- diff --git a/docs/Rules/ReservedParams.md b/docs/Rules/ReservedParams.md index 768b660f3..965881d76 100644 --- a/docs/Rules/ReservedParams.md +++ b/docs/Rules/ReservedParams.md @@ -1,7 +1,7 @@ --- description: Reserved Parameters ms.custom: PSSA v1.21.0 -ms.date: 10/18/2021 +ms.date: 06/28/2023 ms.topic: reference title: ReservedParams --- diff --git a/docs/Rules/ReviewUnusedParameter.md b/docs/Rules/ReviewUnusedParameter.md index 309bcd4d2..2408c5535 100644 --- a/docs/Rules/ReviewUnusedParameter.md +++ b/docs/Rules/ReviewUnusedParameter.md @@ -1,7 +1,7 @@ --- description: ReviewUnusedParameter ms.custom: PSSA v1.21.0 -ms.date: 10/18/2021 +ms.date: 06/28/2023 ms.topic: reference title: ReviewUnusedParameter --- diff --git a/docs/Rules/ShouldProcess.md b/docs/Rules/ShouldProcess.md index 86c894553..d35ca8d40 100644 --- a/docs/Rules/ShouldProcess.md +++ b/docs/Rules/ShouldProcess.md @@ -1,7 +1,7 @@ --- description: Should Process ms.custom: PSSA v1.21.0 -ms.date: 03/24/2022 +ms.date: 06/28/2023 ms.topic: reference title: ShouldProcess --- diff --git a/docs/Rules/UseApprovedVerbs.md b/docs/Rules/UseApprovedVerbs.md index 932795f77..2f51bfdb4 100644 --- a/docs/Rules/UseApprovedVerbs.md +++ b/docs/Rules/UseApprovedVerbs.md @@ -1,7 +1,7 @@ --- description: Cmdlet Verbs ms.custom: PSSA v1.21.0 -ms.date: 10/18/2021 +ms.date: 06/28/2023 ms.topic: reference title: UseApprovedVerbs --- diff --git a/docs/Rules/UseBOMForUnicodeEncodedFile.md b/docs/Rules/UseBOMForUnicodeEncodedFile.md index 1c4c0f40a..118158773 100644 --- a/docs/Rules/UseBOMForUnicodeEncodedFile.md +++ b/docs/Rules/UseBOMForUnicodeEncodedFile.md @@ -1,7 +1,7 @@ --- description: Use BOM encoding for non-ASCII files ms.custom: PSSA v1.21.0 -ms.date: 10/18/2021 +ms.date: 06/28/2023 ms.topic: reference title: UseBOMForUnicodeEncodedFile --- diff --git a/docs/Rules/UseCmdletCorrectly.md b/docs/Rules/UseCmdletCorrectly.md index 158dade6d..205c6a971 100644 --- a/docs/Rules/UseCmdletCorrectly.md +++ b/docs/Rules/UseCmdletCorrectly.md @@ -1,7 +1,7 @@ --- description: Use Cmdlet Correctly ms.custom: PSSA v1.21.0 -ms.date: 10/18/2021 +ms.date: 06/28/2023 ms.topic: reference title: UseCmdletCorrectly --- diff --git a/docs/Rules/UseCompatibleCmdlets.md b/docs/Rules/UseCompatibleCmdlets.md index 0dcfb22e3..93be36a34 100644 --- a/docs/Rules/UseCompatibleCmdlets.md +++ b/docs/Rules/UseCompatibleCmdlets.md @@ -1,7 +1,7 @@ --- description: Use compatible cmdlets ms.custom: PSSA v1.21.0 -ms.date: 10/18/2021 +ms.date: 06/28/2023 ms.topic: reference title: UseCompatibleCmdlets --- diff --git a/docs/Rules/UseCompatibleCommands.md b/docs/Rules/UseCompatibleCommands.md index 779956391..1fb47eae7 100644 --- a/docs/Rules/UseCompatibleCommands.md +++ b/docs/Rules/UseCompatibleCommands.md @@ -1,7 +1,7 @@ --- description: Use compatible commands ms.custom: PSSA v1.21.0 -ms.date: 10/18/2021 +ms.date: 06/28/2023 ms.topic: reference title: UseCompatibleCommands --- diff --git a/docs/Rules/UseCompatibleSyntax.md b/docs/Rules/UseCompatibleSyntax.md index ce93d2623..71974b62a 100644 --- a/docs/Rules/UseCompatibleSyntax.md +++ b/docs/Rules/UseCompatibleSyntax.md @@ -1,7 +1,7 @@ --- description: Use compatible syntax ms.custom: PSSA v1.21.0 -ms.date: 10/18/2021 +ms.date: 06/28/2023 ms.topic: reference title: UseCompatibleSyntax --- diff --git a/docs/Rules/UseCompatibleTypes.md b/docs/Rules/UseCompatibleTypes.md index 836607979..8917ef5eb 100644 --- a/docs/Rules/UseCompatibleTypes.md +++ b/docs/Rules/UseCompatibleTypes.md @@ -1,7 +1,7 @@ --- description: Use compatible types ms.custom: PSSA v1.21.0 -ms.date: 10/18/2021 +ms.date: 06/28/2023 ms.topic: reference title: UseCompatibleTypes --- diff --git a/docs/Rules/UseConsistentIndentation.md b/docs/Rules/UseConsistentIndentation.md index de5979ff7..f9b5d2d81 100644 --- a/docs/Rules/UseConsistentIndentation.md +++ b/docs/Rules/UseConsistentIndentation.md @@ -1,7 +1,7 @@ --- description: Use consistent indentation ms.custom: PSSA v1.21.0 -ms.date: 10/18/2021 +ms.date: 06/28/2023 ms.topic: reference title: UseConsistentIndentation --- diff --git a/docs/Rules/UseConsistentWhitespace.md b/docs/Rules/UseConsistentWhitespace.md index 3438c60ff..76119293d 100644 --- a/docs/Rules/UseConsistentWhitespace.md +++ b/docs/Rules/UseConsistentWhitespace.md @@ -1,7 +1,7 @@ --- description: Use whitespaces ms.custom: PSSA v1.21.0 -ms.date: 10/18/2021 +ms.date: 06/28/2023 ms.topic: reference title: UseConsistentWhitespace --- diff --git a/docs/Rules/UseCorrectCasing.md b/docs/Rules/UseCorrectCasing.md index 8d8dd2895..7fa3cc5b3 100644 --- a/docs/Rules/UseCorrectCasing.md +++ b/docs/Rules/UseCorrectCasing.md @@ -1,7 +1,7 @@ --- description: Use exact casing of cmdlet/function/parameter name. ms.custom: PSSA v1.21.0 -ms.date: 10/18/2021 +ms.date: 06/28/2023 ms.topic: reference title: UseCorrectCasing --- diff --git a/docs/Rules/UseDeclaredVarsMoreThanAssignments.md b/docs/Rules/UseDeclaredVarsMoreThanAssignments.md index 2c37e4efc..080fbb671 100644 --- a/docs/Rules/UseDeclaredVarsMoreThanAssignments.md +++ b/docs/Rules/UseDeclaredVarsMoreThanAssignments.md @@ -1,7 +1,7 @@ --- description: Extra Variables ms.custom: PSSA v1.21.0 -ms.date: 06/30/2022 +ms.date: 06/28/2023 ms.topic: reference title: UseDeclaredVarsMoreThanAssignments --- diff --git a/docs/Rules/UseLiteralInitializerForHashtable.md b/docs/Rules/UseLiteralInitializerForHashtable.md index d7ff68f80..31462c743 100644 --- a/docs/Rules/UseLiteralInitializerForHashtable.md +++ b/docs/Rules/UseLiteralInitializerForHashtable.md @@ -1,7 +1,7 @@ --- description: Create hashtables with literal initializers ms.custom: PSSA v1.21.0 -ms.date: 10/18/2021 +ms.date: 06/28/2023 ms.topic: reference title: UseLiteralInitializerForHashtable --- diff --git a/docs/Rules/UseOutputTypeCorrectly.md b/docs/Rules/UseOutputTypeCorrectly.md index 64482db93..4ce9994da 100644 --- a/docs/Rules/UseOutputTypeCorrectly.md +++ b/docs/Rules/UseOutputTypeCorrectly.md @@ -1,7 +1,7 @@ --- description: Use OutputType Correctly ms.custom: PSSA v1.21.0 -ms.date: 10/18/2021 +ms.date: 06/28/2023 ms.topic: reference title: UseOutputTypeCorrectly --- diff --git a/docs/Rules/UsePSCredentialType.md b/docs/Rules/UsePSCredentialType.md index 85e7ed2d8..79e1a194b 100644 --- a/docs/Rules/UsePSCredentialType.md +++ b/docs/Rules/UsePSCredentialType.md @@ -1,7 +1,7 @@ --- description: Use PSCredential type. ms.custom: PSSA v1.21.0 -ms.date: 10/18/2021 +ms.date: 06/28/2023 ms.topic: reference title: UsePSCredentialType --- diff --git a/docs/Rules/UseProcessBlockForPipelineCommand.md b/docs/Rules/UseProcessBlockForPipelineCommand.md index 3bb5d2f4c..bcf11a8b4 100644 --- a/docs/Rules/UseProcessBlockForPipelineCommand.md +++ b/docs/Rules/UseProcessBlockForPipelineCommand.md @@ -1,7 +1,7 @@ --- description: Use process block for command that accepts input from pipeline. ms.custom: PSSA v1.21.0 -ms.date: 10/18/2021 +ms.date: 06/28/2023 ms.topic: reference title: UseProcessBlockForPipelineCommand --- diff --git a/docs/Rules/UseShouldProcessForStateChangingFunctions.md b/docs/Rules/UseShouldProcessForStateChangingFunctions.md index 84f79bbbf..45017dba8 100644 --- a/docs/Rules/UseShouldProcessForStateChangingFunctions.md +++ b/docs/Rules/UseShouldProcessForStateChangingFunctions.md @@ -1,7 +1,7 @@ --- description: Use ShouldProcess For State Changing Functions ms.custom: PSSA v1.21.0 -ms.date: 10/18/2021 +ms.date: 06/28/2023 ms.topic: reference title: UseShouldProcessForStateChangingFunctions --- diff --git a/docs/Rules/UseSingularNouns.md b/docs/Rules/UseSingularNouns.md index 9dc24a017..4e7576bf0 100644 --- a/docs/Rules/UseSingularNouns.md +++ b/docs/Rules/UseSingularNouns.md @@ -1,7 +1,7 @@ --- description: Cmdlet Singular Noun ms.custom: PSSA v1.21.0 -ms.date: 10/18/2021 +ms.date: 06/28/2023 ms.topic: reference title: UseSingularNouns --- diff --git a/docs/Rules/UseSupportsShouldProcess.md b/docs/Rules/UseSupportsShouldProcess.md index 1c3426366..9d894b85b 100644 --- a/docs/Rules/UseSupportsShouldProcess.md +++ b/docs/Rules/UseSupportsShouldProcess.md @@ -1,7 +1,7 @@ --- description: Use SupportsShouldProcess ms.custom: PSSA v1.21.0 -ms.date: 12/06/2022 +ms.date: 06/28/2023 ms.topic: reference title: UseSupportsShouldProcess --- diff --git a/docs/Rules/UseToExportFieldsInManifest.md b/docs/Rules/UseToExportFieldsInManifest.md index 9b3bbaaef..dcbf890b7 100644 --- a/docs/Rules/UseToExportFieldsInManifest.md +++ b/docs/Rules/UseToExportFieldsInManifest.md @@ -1,7 +1,7 @@ --- description: Use the *ToExport module manifest fields. ms.custom: PSSA v1.21.0 -ms.date: 10/18/2021 +ms.date: 06/28/2023 ms.topic: reference title: UseToExportFieldsInManifest --- diff --git a/docs/Rules/UseUTF8EncodingForHelpFile.md b/docs/Rules/UseUTF8EncodingForHelpFile.md index 9452d2b9b..56b6f0010 100644 --- a/docs/Rules/UseUTF8EncodingForHelpFile.md +++ b/docs/Rules/UseUTF8EncodingForHelpFile.md @@ -1,7 +1,7 @@ --- description: Use UTF8 Encoding For Help File ms.custom: PSSA v1.21.0 -ms.date: 10/18/2021 +ms.date: 06/28/2023 ms.topic: reference title: UseUTF8EncodingForHelpFile --- diff --git a/docs/Rules/UseUsingScopeModifierInNewRunspaces.md b/docs/Rules/UseUsingScopeModifierInNewRunspaces.md index dfab8d1a2..88769d80b 100644 --- a/docs/Rules/UseUsingScopeModifierInNewRunspaces.md +++ b/docs/Rules/UseUsingScopeModifierInNewRunspaces.md @@ -1,7 +1,7 @@ --- description: Use 'Using:' scope modifier in RunSpace ScriptBlocks ms.custom: PSSA v1.21.0 -ms.date: 10/18/2021 +ms.date: 06/28/2023 ms.topic: reference title: UseUsingScopeModifierInNewRunspaces --- From da2c4fa64b313c570e510f0d95e22f930088a46d Mon Sep 17 00:00:00 2001 From: Joel Tipke Date: Fri, 18 Aug 2023 08:44:54 -0700 Subject: [PATCH 18/42] minor documention fixes (#1928) --- README.md | 2 +- Rules/Strings.resx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 75dd8668b..a9ad2ae36 100644 --- a/README.md +++ b/README.md @@ -144,7 +144,7 @@ To install **PSScriptAnalyzer** from source code: - Import the module ```powershell - Import-Module .\out\PSScriptAnalyzer\PSScriptAnalyzer.psd1 + Import-Module .\out\PSScriptAnalyzer\[version]\PSScriptAnalyzer.psd1 ``` To confirm installation: run `Get-ScriptAnalyzerRule` in the PowerShell console to obtain the diff --git a/Rules/Strings.resx b/Rules/Strings.resx index dbba6e570..db7062d6f 100644 --- a/Rules/Strings.resx +++ b/Rules/Strings.resx @@ -1069,7 +1069,7 @@ '>' is not a comparison operator. Use '-gt' (greater than) or '-ge' (greater or equal). - When switching between different languages it is easy to forget that '>' does not mean 'great than' in PowerShell. + When switching between different languages it is easy to forget that '>' does not mean 'greater than' in PowerShell. Did you mean to use the redirection operator '>'? The comparison operators in PowerShell are '-gt' (greater than) or '-ge' (greater or equal). From 4b976a27035e7b38a6c2b1cb975fa1e29ae92635 Mon Sep 17 00:00:00 2001 From: ImportTaste <53661808+ImportTaste@users.noreply.github.com> Date: Fri, 18 Aug 2023 10:48:10 -0500 Subject: [PATCH 19/42] corrections in AvoidUsingPositionalParameters.md (#1917) --- docs/Rules/AvoidUsingPositionalParameters.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/Rules/AvoidUsingPositionalParameters.md b/docs/Rules/AvoidUsingPositionalParameters.md index 6373e11e6..2d1dab690 100644 --- a/docs/Rules/AvoidUsingPositionalParameters.md +++ b/docs/Rules/AvoidUsingPositionalParameters.md @@ -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 } @@ -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. From b0383ee52b45dfd6fbb78aba363e6cb3e1ebc8fe Mon Sep 17 00:00:00 2001 From: Liam Peters Date: Wed, 6 Sep 2023 18:48:37 +0100 Subject: [PATCH 20/42] Add the AvoidExclaimOperator rule to warn about the use of the ! negation operator. Fixes #1826 (#1922) * Added the AvoidExclamationPointOperator rule to warn about the use of the negation operator !. Fixes #1826 * Updated license header of Rules/AvoidExclamationPointOperator.cs * Updated the description of the rule in docs Co-authored-by: Christoph Bergmeister * Fix alignment Co-authored-by: Christoph Bergmeister * Update Rules/Strings.resx Co-authored-by: Christoph Bergmeister * Renamed rule from AvoidExclamationPointOperator to AvoidExclaimOperator * Added comment explanation of the replacement suggestion logic and renamed loop variable for clarity --------- Co-authored-by: Christoph Bergmeister --- Engine/Formatter.cs | 1 + Rules/AvoidExclaimOperator.cs | 147 +++++++++++++++++++ Rules/Strings.Designer.cs | 47 +++++- Rules/Strings.resx | 17 ++- Tests/Engine/GetScriptAnalyzerRule.tests.ps1 | 2 +- Tests/Rules/AvoidExclaimOperator.tests.ps1 | 54 +++++++ docs/Rules/AvoidExclaimOperator.md | 44 ++++++ docs/Rules/README.md | 1 + 8 files changed, 310 insertions(+), 3 deletions(-) create mode 100644 Rules/AvoidExclaimOperator.cs create mode 100644 Tests/Rules/AvoidExclaimOperator.tests.ps1 create mode 100644 docs/Rules/AvoidExclaimOperator.md diff --git a/Engine/Formatter.cs b/Engine/Formatter.cs index 3c1325a5d..3db99e79d 100644 --- a/Engine/Formatter.cs +++ b/Engine/Formatter.cs @@ -46,6 +46,7 @@ public static string Format( "PSAvoidUsingCmdletAliases", "PSAvoidUsingDoubleQuotesForConstantString", "PSAvoidSemicolonsAsLineTerminators", + "PSAvoidExclaimOperator", }; var text = new EditableText(scriptDefinition); diff --git a/Rules/AvoidExclaimOperator.cs b/Rules/AvoidExclaimOperator.cs new file mode 100644 index 000000000..5521463ea --- /dev/null +++ b/Rules/AvoidExclaimOperator.cs @@ -0,0 +1,147 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using System.Collections.Generic; +#if !CORECLR +using System.ComponentModel.Composition; +#endif +using System.Globalization; +using System.Linq; +using System.Management.Automation; +using System.Management.Automation.Language; +using Microsoft.Windows.PowerShell.ScriptAnalyzer.Generic; + +namespace Microsoft.Windows.PowerShell.ScriptAnalyzer.BuiltinRules +{ + /// + /// AvoidExclaimOperator: Checks for use of the exclaim operator + /// +#if !CORECLR + [Export(typeof(IScriptRule))] +#endif + public class AvoidExclaimOperator : ConfigurableRule + { + + /// + /// Construct an object of AvoidExclaimOperator type. + /// + public AvoidExclaimOperator() { + Enable = false; + } + + /// + /// Analyzes the given ast to find the [violation] + /// + /// AST to be analyzed. This should be non-null + /// Name of file that corresponds to the input AST. + /// A an enumerable type containing the violations + public override IEnumerable AnalyzeScript(Ast ast, string fileName) + { + if (ast == null) throw new ArgumentNullException(Strings.NullAstErrorMessage); + + var diagnosticRecords = new List(); + + IEnumerable foundAsts = ast.FindAll(testAst => testAst is UnaryExpressionAst, true); + if (foundAsts != null) { + var correctionDescription = Strings.AvoidExclaimOperatorCorrectionDescription; + foreach (UnaryExpressionAst unaryExpressionAst in foundAsts) { + if (unaryExpressionAst.TokenKind == TokenKind.Exclaim) { + var replaceWith = "-not"; + // The UnaryExpressionAST should have a single child, the argument that the unary operator is acting upon. + // If the child's extent starts 1 after the parent's extent then there's no whitespace between the exclaim + // token and any variable/expression; in that case the replacement -not should include a space + if (unaryExpressionAst.Child != null && unaryExpressionAst.Child.Extent.StartColumnNumber == unaryExpressionAst.Extent.StartColumnNumber + 1) { + replaceWith = "-not "; + } + var corrections = new List { + new CorrectionExtent( + unaryExpressionAst.Extent.StartLineNumber, + unaryExpressionAst.Extent.EndLineNumber, + unaryExpressionAst.Extent.StartColumnNumber, + unaryExpressionAst.Extent.StartColumnNumber + 1, + replaceWith, + fileName, + correctionDescription + ) + }; + diagnosticRecords.Add(new DiagnosticRecord( + string.Format( + CultureInfo.CurrentCulture, + Strings.AvoidExclaimOperatorError + ), + unaryExpressionAst.Extent, + GetName(), + GetDiagnosticSeverity(), + fileName, + suggestedCorrections: corrections + )); + } + } + } + return diagnosticRecords; + } + + /// + /// Retrieves the common name of this rule. + /// + public override string GetCommonName() + { + return string.Format(CultureInfo.CurrentCulture, Strings.AvoidExclaimOperatorCommonName); + } + + /// + /// Retrieves the description of this rule. + /// + public override string GetDescription() + { + return string.Format(CultureInfo.CurrentCulture, Strings.AvoidExclaimOperatorDescription); + } + + /// + /// Retrieves the name of this rule. + /// + public override string GetName() + { + return string.Format( + CultureInfo.CurrentCulture, + Strings.NameSpaceFormat, + GetSourceName(), + Strings.AvoidExclaimOperatorName); + } + + /// + /// Retrieves the severity of the rule: error, warning or information. + /// + public override RuleSeverity GetSeverity() + { + return RuleSeverity.Warning; + } + + /// + /// Gets the severity of the returned diagnostic record: error, warning, or information. + /// + /// + public DiagnosticSeverity GetDiagnosticSeverity() + { + return DiagnosticSeverity.Warning; + } + + /// + /// Retrieves the name of the module/assembly the rule is from. + /// + public override string GetSourceName() + { + return string.Format(CultureInfo.CurrentCulture, Strings.SourceName); + } + + /// + /// Retrieves the type of the rule, Builtin, Managed or Module. + /// + public override SourceType GetSourceType() + { + return SourceType.Builtin; + } + } +} + diff --git a/Rules/Strings.Designer.cs b/Rules/Strings.Designer.cs index 30d0a7321..f346e9084 100644 --- a/Rules/Strings.Designer.cs +++ b/Rules/Strings.Designer.cs @@ -285,6 +285,51 @@ internal static string AvoidEmptyCatchBlockError { } } + /// + /// Looks up a localized string similar to Avoid exclaim operator. + /// + internal static string AvoidExclaimOperatorCommonName { + get { + return ResourceManager.GetString("AvoidExclaimOperatorCommonName", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Replace ! with -not. + /// + internal static string AvoidExclaimOperatorCorrectionDescription { + get { + return ResourceManager.GetString("AvoidExclaimOperatorCorrectionDescription", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to The negation operator ! should not be used for readability purposes. Use -not instead.. + /// + internal static string AvoidExclaimOperatorDescription { + get { + return ResourceManager.GetString("AvoidExclaimOperatorDescription", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Avoid using the ! negation operator. + /// + internal static string AvoidExclaimOperatorError { + get { + return ResourceManager.GetString("AvoidExclaimOperatorError", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to AvoidExclaimOperator. + /// + internal static string AvoidExclaimOperatorName { + get { + return ResourceManager.GetString("AvoidExclaimOperatorName", resourceCulture); + } + } + /// /// Looks up a localized string similar to Avoid global aliases.. /// @@ -1132,7 +1177,7 @@ internal static string AvoidUsingPlainTextForPasswordDescription { } /// - /// Looks up a localized string similar to Parameter '{0}' should not use String type but either SecureString or PSCredential, otherwise it increases the chance to to expose this sensitive information.. + /// Looks up a localized string similar to Parameter '{0}' should not use String type but either SecureString or PSCredential, otherwise it increases the chance to expose this sensitive information.. /// internal static string AvoidUsingPlainTextForPasswordError { get { diff --git a/Rules/Strings.resx b/Rules/Strings.resx index db7062d6f..479ca1f7a 100644 --- a/Rules/Strings.resx +++ b/Rules/Strings.resx @@ -1191,4 +1191,19 @@ Parameter '{0}' of function/cmdlet '{1}' does not match its exact casing '{2}'. - + + AvoidExclaimOperator + + + Avoid exclaim operator + + + The negation operator ! should not be used for readability purposes. Use -not instead. + + + Avoid using the ! negation operator + + + Replace ! with -not + + \ No newline at end of file diff --git a/Tests/Engine/GetScriptAnalyzerRule.tests.ps1 b/Tests/Engine/GetScriptAnalyzerRule.tests.ps1 index 0ca6e569f..960a2fcd5 100644 --- a/Tests/Engine/GetScriptAnalyzerRule.tests.ps1 +++ b/Tests/Engine/GetScriptAnalyzerRule.tests.ps1 @@ -63,7 +63,7 @@ Describe "Test Name parameters" { It "get Rules with no parameters supplied" { $defaultRules = Get-ScriptAnalyzerRule - $expectedNumRules = 68 + $expectedNumRules = 69 if ($PSVersionTable.PSVersion.Major -le 4) { # for PSv3 PSAvoidGlobalAliases is not shipped because diff --git a/Tests/Rules/AvoidExclaimOperator.tests.ps1 b/Tests/Rules/AvoidExclaimOperator.tests.ps1 new file mode 100644 index 000000000..8307aef5a --- /dev/null +++ b/Tests/Rules/AvoidExclaimOperator.tests.ps1 @@ -0,0 +1,54 @@ +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. + +BeforeAll { + $ruleName = "PSAvoidExclaimOperator" + + $ruleSettings = @{ + Enable = $true + } + $settings = @{ + IncludeRules = @($ruleName) + Rules = @{ $ruleName = $ruleSettings } + } +} + +Describe "AvoidExclaimOperator" { + Context "When the rule is not enabled explicitly" { + It "Should not find violations" { + $def = '!$true' + $violations = Invoke-ScriptAnalyzer -ScriptDefinition $def + $violations.Count | Should -Be 0 + } + } + + Context "Given a line with the exclaim operator" { + It "Should find one violation" { + $def = '!$true' + $violations = Invoke-ScriptAnalyzer -ScriptDefinition $def -Settings $settings + $violations.Count | Should -Be 1 + } + } + + Context "Given a line with the exclaim operator" { + It "Should replace the exclaim operator with the -not operator" { + $def = '!$true' + $expected = '-not $true' + Invoke-Formatter -ScriptDefinition $def -Settings $settings | Should -Be $expected + } + } + Context "Given a line with the exlaim operator followed by a space" { + It "Should replace the exclaim operator without adding an additional space" { + $def = '! $true' + $expected = '-not $true' + Invoke-Formatter -ScriptDefinition $def -Settings $settings | Should -Be $expected + } + } + Context "Given a line with a string containing an exclamation point" { + It "Should not replace it" { + $def = '$MyVar = "Should not replace!"' + $expected = '$MyVar = "Should not replace!"' + Invoke-Formatter -ScriptDefinition $def -Settings $settings | Should -Be $expected + } + } +} \ No newline at end of file diff --git a/docs/Rules/AvoidExclaimOperator.md b/docs/Rules/AvoidExclaimOperator.md new file mode 100644 index 000000000..5f858feca --- /dev/null +++ b/docs/Rules/AvoidExclaimOperator.md @@ -0,0 +1,44 @@ +--- +description: Avoid exclaim operator +ms.custom: PSSA v1.21.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. \ No newline at end of file diff --git a/docs/Rules/README.md b/docs/Rules/README.md index 4f8a0b4ad..f5c8d8bd3 100644 --- a/docs/Rules/README.md +++ b/docs/Rules/README.md @@ -15,6 +15,7 @@ The PSScriptAnalyzer contains the following rule definitions. | [AvoidAssignmentToAutomaticVariable](./AvoidAssignmentToAutomaticVariable.md) | Warning | Yes | | | [AvoidDefaultValueForMandatoryParameter](./AvoidDefaultValueForMandatoryParameter.md) | Warning | Yes | | | [AvoidDefaultValueSwitchParameter](./AvoidDefaultValueSwitchParameter.md) | Warning | Yes | | +| [AvoidExclaimOperator](./AvoidExclaimOperator.md) | Warning | No | | | [AvoidGlobalAliases1](./AvoidGlobalAliases.md) | Warning | Yes | | | [AvoidGlobalFunctions](./AvoidGlobalFunctions.md) | Warning | Yes | | | [AvoidGlobalVars](./AvoidGlobalVars.md) | Warning | Yes | | From 85ad15b8c2807caa6c6feeb9872d6b16803e1826 Mon Sep 17 00:00:00 2001 From: Christoph Bergmeister Date: Mon, 11 Sep 2023 20:21:01 +0100 Subject: [PATCH 21/42] Update minimum PowerShell Core version to 7.2.11 as 7.0 is now EOL (#1872) * Update PSScriptAnalyzer.psm1 * use latest patch version 7.2.11 --- Engine/PSScriptAnalyzer.psm1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Engine/PSScriptAnalyzer.psm1 b/Engine/PSScriptAnalyzer.psm1 index 91f096c25..166e48e61 100644 --- a/Engine/PSScriptAnalyzer.psm1 +++ b/Engine/PSScriptAnalyzer.psm1 @@ -9,7 +9,7 @@ $PSModuleRoot = $PSModule.ModuleBase # Import the appropriate nested binary module based on the current PowerShell version $binaryModuleRoot = $PSModuleRoot -[Version] $minimumPowerShellCoreVersion = '7.0.11' +[Version] $minimumPowerShellCoreVersion = '7.2.11' if ($PSVersionTable.PSVersion.Major -ge 6) { $binaryModuleRoot = Join-Path -Path $PSModuleRoot -ChildPath "PSv$($PSVersionTable.PSVersion.Major)" # Minimum PowerShell Core version given by PowerShell Core support itself and From bd79460c3d2d5e6fd2da3ebe0bbdd0698f888235 Mon Sep 17 00:00:00 2001 From: Christoph Bergmeister Date: Mon, 11 Sep 2023 21:07:38 +0100 Subject: [PATCH 22/42] Remove dead code and simplify (#1856) * Remove unused variables * simplify code and remove unused method * remove unused member * more cleanup * more cleanup * more * more --- Engine/CommandInfoCache.cs | 4 +--- Engine/Commands/GetScriptAnalyzerRuleCommand.cs | 5 ++--- Engine/Commands/InvokeFormatterCommand.cs | 6 ------ Engine/Commands/InvokeScriptAnalyzerCommand.cs | 3 +-- Engine/Formatter.cs | 2 +- Engine/Generic/ModuleDependencyHandler.cs | 3 --- Engine/Helper.cs | 12 +++--------- Engine/ScriptAnalyzer.cs | 3 +-- Engine/Settings.cs | 11 ----------- .../Collection/PlatformInformationCollector.cs | 12 ------------ .../Commands/CommandUtilities.cs | 2 -- Rules/AvoidUserNameAndPasswordParams.cs | 4 ++-- Rules/AvoidUsingDeprecatedManifestFields.cs | 3 +-- Rules/CompatibilityRules/UseCompatibleCommands.cs | 3 +-- Rules/UseConsistentIndentation.cs | 5 ----- Rules/UseIdenticalMandatoryParametersDSC.cs | 2 -- Rules/UseToExportFieldsInManifest.cs | 5 ++--- 17 files changed, 15 insertions(+), 70 deletions(-) diff --git a/Engine/CommandInfoCache.cs b/Engine/CommandInfoCache.cs index dbcb41eda..71c37d83c 100644 --- a/Engine/CommandInfoCache.cs +++ b/Engine/CommandInfoCache.cs @@ -15,17 +15,15 @@ namespace Microsoft.Windows.PowerShell.ScriptAnalyzer internal class CommandInfoCache : IDisposable { private readonly ConcurrentDictionary> _commandInfoCache; - private readonly Helper _helperInstance; private readonly RunspacePool _runspacePool; private bool disposed = false; /// /// Create a fresh command info cache instance. /// - public CommandInfoCache(Helper pssaHelperInstance) + public CommandInfoCache() { _commandInfoCache = new ConcurrentDictionary>(); - _helperInstance = pssaHelperInstance; _runspacePool = RunspaceFactory.CreateRunspacePool(1, 10); _runspacePool.Open(); } diff --git a/Engine/Commands/GetScriptAnalyzerRuleCommand.cs b/Engine/Commands/GetScriptAnalyzerRuleCommand.cs index 7a9d50561..3219affa7 100644 --- a/Engine/Commands/GetScriptAnalyzerRuleCommand.cs +++ b/Engine/Commands/GetScriptAnalyzerRuleCommand.cs @@ -84,13 +84,12 @@ protected override void BeginProcessing() // Initialize helper Helper.Instance = new Helper( - SessionState.InvokeCommand, - this); + SessionState.InvokeCommand); Helper.Instance.Initialize(); string[] rulePaths = Helper.ProcessCustomRulePaths(customRulePath, this.SessionState, recurseCustomRulePath); - ScriptAnalyzer.Instance.Initialize(this, rulePaths, null, null, null, null == rulePaths ? true : false); + ScriptAnalyzer.Instance.Initialize(this, rulePaths, null, null, null, null == rulePaths); } /// diff --git a/Engine/Commands/InvokeFormatterCommand.cs b/Engine/Commands/InvokeFormatterCommand.cs index d08d8c817..25a2d364e 100644 --- a/Engine/Commands/InvokeFormatterCommand.cs +++ b/Engine/Commands/InvokeFormatterCommand.cs @@ -124,11 +124,5 @@ protected override void StopProcessing() ScriptAnalyzer.Instance.CleanUp(); base.StopProcessing(); } - - private void ValidateInputSettings() - { - // todo implement this - return; - } } } diff --git a/Engine/Commands/InvokeScriptAnalyzerCommand.cs b/Engine/Commands/InvokeScriptAnalyzerCommand.cs index 77364ac9c..3be9cd7fc 100644 --- a/Engine/Commands/InvokeScriptAnalyzerCommand.cs +++ b/Engine/Commands/InvokeScriptAnalyzerCommand.cs @@ -285,8 +285,7 @@ protected override void BeginProcessing() } #endif Helper.Instance = new Helper( - SessionState.InvokeCommand, - this); + SessionState.InvokeCommand); Helper.Instance.Initialize(); var psVersionTable = this.SessionState.PSVariable.GetValue("PSVersionTable") as Hashtable; diff --git a/Engine/Formatter.cs b/Engine/Formatter.cs index 3db99e79d..5a93854c5 100644 --- a/Engine/Formatter.cs +++ b/Engine/Formatter.cs @@ -32,7 +32,7 @@ public static string Format( ValidateNotNull(settings, "settings"); ValidateNotNull(cmdlet, "cmdlet"); - Helper.Instance = new Helper(cmdlet.SessionState.InvokeCommand, cmdlet); + Helper.Instance = new Helper(cmdlet.SessionState.InvokeCommand); Helper.Instance.Initialize(); var ruleOrder = new string[] diff --git a/Engine/Generic/ModuleDependencyHandler.cs b/Engine/Generic/ModuleDependencyHandler.cs index 347b9a9a1..31a43d6ca 100644 --- a/Engine/Generic/ModuleDependencyHandler.cs +++ b/Engine/Generic/ModuleDependencyHandler.cs @@ -22,7 +22,6 @@ public class ModuleDependencyHandler : IDisposable private string moduleRepository; private string tempPath; // path to the user temporary directory private string tempModulePath; // path to temp directory containing modules - Dictionary modulesFound; private string localAppdataPath; private string pssaAppDataPath; private const string symLinkName = "TempModuleDir"; @@ -271,8 +270,6 @@ public ModuleDependencyHandler( ? "PSScriptAnalyzer" : pssaAppDataPath); - modulesFound = new Dictionary(StringComparer.OrdinalIgnoreCase); - // TODO Add PSSA Version in the path symLinkPath = Path.Combine(pssaAppDataPath, symLinkName); SetupPSSAAppData(); diff --git a/Engine/Helper.cs b/Engine/Helper.cs index feea8a5ec..528a3fe88 100644 --- a/Engine/Helper.cs +++ b/Engine/Helper.cs @@ -24,7 +24,6 @@ public class Helper #region Private members private CommandInvocationIntrinsics invokeCommand; - private IOutputWriter outputWriter; private readonly static Version minSupportedPSVersion = new Version(3, 0); private Dictionary> ruleArguments; private PSVersionTable psVersionTable; @@ -115,7 +114,7 @@ internal set /// private Helper() { - _commandInfoCacheLazy = new Lazy(() => new CommandInfoCache(pssaHelperInstance: this)); + _commandInfoCacheLazy = new Lazy(() => new CommandInfoCache()); } /// @@ -125,16 +124,11 @@ private Helper() /// A CommandInvocationIntrinsics instance for use in gathering /// information about available commands and aliases. /// - /// - /// An IOutputWriter instance for use in writing output - /// to the PowerShell environment. - /// public Helper( - CommandInvocationIntrinsics invokeCommand, - IOutputWriter outputWriter) : this() + CommandInvocationIntrinsics invokeCommand + ): this() { this.invokeCommand = invokeCommand; - this.outputWriter = outputWriter; } #region Methods diff --git a/Engine/ScriptAnalyzer.cs b/Engine/ScriptAnalyzer.cs index d35ab7e0a..1a885eabe 100644 --- a/Engine/ScriptAnalyzer.cs +++ b/Engine/ScriptAnalyzer.cs @@ -168,8 +168,7 @@ public void Initialize( //initialize helper Helper.Instance = new Helper( - runspace.SessionStateProxy.InvokeCommand, - outputWriter); + runspace.SessionStateProxy.InvokeCommand); Helper.Instance.Initialize(); SuppressionPreference suppressionPreference = suppressedOnly diff --git a/Engine/Settings.cs b/Engine/Settings.cs index b13f9405b..a4931978c 100644 --- a/Engine/Settings.cs +++ b/Engine/Settings.cs @@ -285,17 +285,6 @@ private Dictionary GetDictionaryFromHashtable(Hashtable hashtabl return dictionary; } - private bool IsStringOrStringArray(object val) - { - if (val is string) - { - return true; - } - - var valArr = val as object[]; - return val == null ? false : valArr.All(x => x is string); - } - private List GetData(object val, string key) { // value must be either string or or an array of strings diff --git a/PSCompatibilityCollector/Microsoft.PowerShell.CrossCompatibility/Collection/PlatformInformationCollector.cs b/PSCompatibilityCollector/Microsoft.PowerShell.CrossCompatibility/Collection/PlatformInformationCollector.cs index 9a7eab952..26aa0ee7a 100644 --- a/PSCompatibilityCollector/Microsoft.PowerShell.CrossCompatibility/Collection/PlatformInformationCollector.cs +++ b/PSCompatibilityCollector/Microsoft.PowerShell.CrossCompatibility/Collection/PlatformInformationCollector.cs @@ -351,18 +351,6 @@ private Architecture GetOSArchitecture() #endif } - private DotnetRuntime GetDotnetRuntime() - { -#if CoreCLR - // Our CoreCLR is actuall .NET Standard, so we could be loaded into net47 - return RuntimeInformation.FrameworkDescription.StartsWith(".NET Core") - ? DotnetRuntime.Core - : DotnetRuntime.Framework; -#else - return DotnetRuntime.Framework; -#endif - } - /// /// Get the Windows SKU ID of the current PowerShell session. /// diff --git a/PSCompatibilityCollector/Microsoft.PowerShell.CrossCompatibility/Commands/CommandUtilities.cs b/PSCompatibilityCollector/Microsoft.PowerShell.CrossCompatibility/Commands/CommandUtilities.cs index 3e14494f1..6a957f7cc 100644 --- a/PSCompatibilityCollector/Microsoft.PowerShell.CrossCompatibility/Commands/CommandUtilities.cs +++ b/PSCompatibilityCollector/Microsoft.PowerShell.CrossCompatibility/Commands/CommandUtilities.cs @@ -13,8 +13,6 @@ namespace Microsoft.PowerShell.CrossCompatibility.Commands /// internal static class CommandUtilities { - private const string COMPATIBILITY_ERROR_ID = "CompatibilityAnalysisError"; - public const string MODULE_PREFIX = "PSCompatibility"; /// diff --git a/Rules/AvoidUserNameAndPasswordParams.cs b/Rules/AvoidUserNameAndPasswordParams.cs index 0609505fd..ced0c8ee1 100644 --- a/Rules/AvoidUserNameAndPasswordParams.cs +++ b/Rules/AvoidUserNameAndPasswordParams.cs @@ -86,7 +86,7 @@ public IEnumerable AnalyzeScript(Ast ast, string fileName) { yield return new DiagnosticRecord( String.Format(CultureInfo.CurrentCulture, Strings.AvoidUsernameAndPasswordParamsError, funcAst.Name), - GetExtent(usernameAst, passwordAst, ast), GetName(), DiagnosticSeverity.Error, fileName); + GetExtent(usernameAst, passwordAst), GetName(), DiagnosticSeverity.Error, fileName); } } } @@ -111,7 +111,7 @@ private bool IsAttributeOfType(AttributeBaseAst attributeAst, Type type) /// /// /// IScriptExtent - private IScriptExtent GetExtent(ParameterAst usernameAst, ParameterAst passwordAst, Ast scriptAst) + private IScriptExtent GetExtent(ParameterAst usernameAst, ParameterAst passwordAst) { var usrExt = usernameAst.Extent; var pwdExt = passwordAst.Extent; diff --git a/Rules/AvoidUsingDeprecatedManifestFields.cs b/Rules/AvoidUsingDeprecatedManifestFields.cs index 8856745d2..fd3431251 100644 --- a/Rules/AvoidUsingDeprecatedManifestFields.cs +++ b/Rules/AvoidUsingDeprecatedManifestFields.cs @@ -70,10 +70,9 @@ public IEnumerable AnalyzeScript(Ast ast, string fileName) if (value != null) { - Version psVersion = null; // get the version - if (Version.TryParse((value as StringConstantExpressionAst).Value, out psVersion)) + if (Version.TryParse((value as StringConstantExpressionAst).Value, out Version psVersion)) { // if version exists and version less than 3, don't raise rule if (psVersion.Major < 3) diff --git a/Rules/CompatibilityRules/UseCompatibleCommands.cs b/Rules/CompatibilityRules/UseCompatibleCommands.cs index 0f7cfadbf..bad708e2c 100644 --- a/Rules/CompatibilityRules/UseCompatibleCommands.cs +++ b/Rules/CompatibilityRules/UseCompatibleCommands.cs @@ -263,8 +263,7 @@ public static CommandCompatibilityDiagnostic CreateForParameter( PlatformData platform, IScriptExtent extent, string analyzedFileName, - IRule rule, - IEnumerable suggestedCorrections = null) + IRule rule) { string message = string.Format( CultureInfo.CurrentCulture, diff --git a/Rules/UseConsistentIndentation.cs b/Rules/UseConsistentIndentation.cs index da5cfb8a5..bbb12bd41 100644 --- a/Rules/UseConsistentIndentation.cs +++ b/Rules/UseConsistentIndentation.cs @@ -563,11 +563,6 @@ private static int ClipNegative(int x) return x > 0 ? x : 0; } - private int GetIndentationColumnNumber(int indentationLevel) - { - return GetIndentation(indentationLevel) + 1; - } - private int GetIndentation(int indentationLevel) { // todo if condition can be evaluated during rule configuration diff --git a/Rules/UseIdenticalMandatoryParametersDSC.cs b/Rules/UseIdenticalMandatoryParametersDSC.cs index 713b86814..56acb5b48 100644 --- a/Rules/UseIdenticalMandatoryParametersDSC.cs +++ b/Rules/UseIdenticalMandatoryParametersDSC.cs @@ -32,7 +32,6 @@ namespace Microsoft.Windows.PowerShell.ScriptAnalyzer.BuiltinRules public class UseIdenticalMandatoryParametersDSC : IDSCResourceRule { private bool isDSCClassCacheInitialized = false; - private Ast ast; private string fileName; private IDictionary propAttrDict; private IEnumerable resourceFunctions; @@ -94,7 +93,6 @@ public IEnumerable AnalyzeDSCResource(Ast ast, string fileName } // Get the keys in the corresponding mof file - this.ast = ast; this.fileName = fileName; this.propAttrDict = GetKeys(fileName); this.resourceFunctions = Helper.Instance.DscResourceFunctions(ast) diff --git a/Rules/UseToExportFieldsInManifest.cs b/Rules/UseToExportFieldsInManifest.cs index bfd99db9e..9bf612f83 100644 --- a/Rules/UseToExportFieldsInManifest.cs +++ b/Rules/UseToExportFieldsInManifest.cs @@ -69,7 +69,7 @@ public IEnumerable AnalyzeScript(Ast ast, string fileName) foreach(string field in manifestFields) { IScriptExtent extent; - if (!HasAcceptableExportField(field, hashtableAst, ast.Extent.Text, out extent) && extent != null) + if (!HasAcceptableExportField(field, hashtableAst, out extent) && extent != null) { yield return new DiagnosticRecord( GetError(field), @@ -200,10 +200,9 @@ private bool HasNullInExpression(Ast ast) /// /// /// - /// /// /// A boolean value indicating if the the ToExport fields are explicitly set to arrays or not. - private bool HasAcceptableExportField(string key, HashtableAst hast, string scriptText, out IScriptExtent extent) + private bool HasAcceptableExportField(string key, HashtableAst hast, out IScriptExtent extent) { extent = null; foreach (var pair in hast.KeyValuePairs) From 2e77c2a64a4ec262a6905fd843ae526f3a2f1aed Mon Sep 17 00:00:00 2001 From: Peter Vandivier Date: Mon, 11 Sep 2023 18:42:00 -0400 Subject: [PATCH 23/42] PSReservedParams - link about_CommonParameters (#1908) * PSReservedParams - link about_CommonParameters Knowing that I'm not allowed to use certain words is more helpful if I have a list of those forbidden words. * Update docs/Rules/ReservedParams.md * change link markdown to reference-style syntax Co-authored-by: Mikey Lombardi (He/Him) --------- Co-authored-by: Christoph Bergmeister Co-authored-by: Mikey Lombardi (He/Him) --- docs/Rules/ReservedParams.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/docs/Rules/ReservedParams.md b/docs/Rules/ReservedParams.md index 965881d76..2a254683f 100644 --- a/docs/Rules/ReservedParams.md +++ b/docs/Rules/ReservedParams.md @@ -11,7 +11,9 @@ title: ReservedParams ## Description -You cannot use reserved common parameters in an advanced function. +You cannot use [reserved common parameters][01] in an advanced function. + +[01]: https://learn.microsoft.com/powershell/module/microsoft.powershell.core/about/about_commonparameters ## How @@ -24,7 +26,7 @@ Change the name of the parameter. ```powershell function Test { - [CmdletBinding] + [CmdletBinding()] Param ( $ErrorVariable, @@ -38,7 +40,7 @@ function Test ```powershell function Test { - [CmdletBinding] + [CmdletBinding()] Param ( $Err, From 40be5932808940f8cd89f8d8be7c35772fcdb5d5 Mon Sep 17 00:00:00 2001 From: Frode Flaten <3436158+fflaten@users.noreply.github.com> Date: Sun, 17 Sep 2023 20:36:52 +0200 Subject: [PATCH 24/42] Enable suppression of PSAvoidAssignmentToAutomaticVariable for specific variable or parameter (#1896) * add ruleId to PSAvoidAssignmentToAutomaticVariable Enables suppression for specific variable/parameter. Fix #1589 * add tests --- Rules/AvoidAssignmentToAutomaticVariable.cs | 12 +- ...oidAssignmentToAutomaticVariable.tests.ps1 | 126 +++++++++++------- 2 files changed, 81 insertions(+), 57 deletions(-) diff --git a/Rules/AvoidAssignmentToAutomaticVariable.cs b/Rules/AvoidAssignmentToAutomaticVariable.cs index 1f2a784dd..c188da341 100644 --- a/Rules/AvoidAssignmentToAutomaticVariable.cs +++ b/Rules/AvoidAssignmentToAutomaticVariable.cs @@ -62,20 +62,20 @@ public IEnumerable AnalyzeScript(Ast ast, string fileName) if (_readOnlyAutomaticVariables.Contains(variableName, StringComparer.OrdinalIgnoreCase)) { yield return new DiagnosticRecord(DiagnosticRecordHelper.FormatError(Strings.AvoidAssignmentToReadOnlyAutomaticVariableError, variableName), - variableExpressionAst.Extent, GetName(), DiagnosticSeverity.Error, fileName); + variableExpressionAst.Extent, GetName(), DiagnosticSeverity.Error, fileName, variableName); } if (_readOnlyAutomaticVariablesIntroducedInVersion6_0.Contains(variableName, StringComparer.OrdinalIgnoreCase)) { var severity = IsPowerShellVersion6OrGreater() ? DiagnosticSeverity.Error : DiagnosticSeverity.Warning; yield return new DiagnosticRecord(DiagnosticRecordHelper.FormatError(Strings.AvoidAssignmentToReadOnlyAutomaticVariableIntroducedInPowerShell6_0Error, variableName), - variableExpressionAst.Extent, GetName(), severity, fileName); + variableExpressionAst.Extent, GetName(), severity, fileName, variableName); } if (_writableAutomaticVariables.Contains(variableName, StringComparer.OrdinalIgnoreCase)) { yield return new DiagnosticRecord(DiagnosticRecordHelper.FormatError(Strings.AvoidAssignmentToWritableAutomaticVariableError, variableName), - variableExpressionAst.Extent, GetName(), DiagnosticSeverity.Warning, fileName); + variableExpressionAst.Extent, GetName(), DiagnosticSeverity.Warning, fileName, variableName); } } @@ -93,20 +93,20 @@ public IEnumerable AnalyzeScript(Ast ast, string fileName) if (_readOnlyAutomaticVariables.Contains(variableName, StringComparer.OrdinalIgnoreCase)) { yield return new DiagnosticRecord(DiagnosticRecordHelper.FormatError(Strings.AvoidAssignmentToReadOnlyAutomaticVariableError, variableName), - variableExpressionAst.Extent, GetName(), DiagnosticSeverity.Error, fileName); + variableExpressionAst.Extent, GetName(), DiagnosticSeverity.Error, fileName, variableName); } if (_readOnlyAutomaticVariablesIntroducedInVersion6_0.Contains(variableName, StringComparer.OrdinalIgnoreCase)) { var severity = IsPowerShellVersion6OrGreater() ? DiagnosticSeverity.Error : DiagnosticSeverity.Warning; yield return new DiagnosticRecord(DiagnosticRecordHelper.FormatError(Strings.AvoidAssignmentToReadOnlyAutomaticVariableIntroducedInPowerShell6_0Error, variableName), - variableExpressionAst.Extent, GetName(), severity, fileName); + variableExpressionAst.Extent, GetName(), severity, fileName, variableName); } if (_writableAutomaticVariables.Contains(variableName, StringComparer.OrdinalIgnoreCase)) { yield return new DiagnosticRecord(DiagnosticRecordHelper.FormatError(Strings.AvoidAssignmentToWritableAutomaticVariableError, variableName), - variableExpressionAst.Extent, GetName(), DiagnosticSeverity.Warning, fileName); + variableExpressionAst.Extent, GetName(), DiagnosticSeverity.Warning, fileName, variableName); } } } diff --git a/Tests/Rules/AvoidAssignmentToAutomaticVariable.tests.ps1 b/Tests/Rules/AvoidAssignmentToAutomaticVariable.tests.ps1 index 50aea15cd..8130990c2 100644 --- a/Tests/Rules/AvoidAssignmentToAutomaticVariable.tests.ps1 +++ b/Tests/Rules/AvoidAssignmentToAutomaticVariable.tests.ps1 @@ -7,60 +7,61 @@ BeforeAll { Describe "AvoidAssignmentToAutomaticVariables" { Context "ReadOnly Variables" { + BeforeDiscovery { + $excpectedSeverityForAutomaticVariablesInPowerShell6 = 'Warning' + if ($PSVersionTable.PSVersion.Major -ge 6) + { + $excpectedSeverityForAutomaticVariablesInPowerShell6 = 'Error' + } - $excpectedSeverityForAutomaticVariablesInPowerShell6 = 'Warning' - if ($PSVersionTable.PSVersion.Major -ge 6) - { - $excpectedSeverityForAutomaticVariablesInPowerShell6 = 'Error' + $testCases_AutomaticVariables = @( + @{ VariableName = '?'; ExpectedSeverity = 'Error'; IsReadOnly = $true } + @{ VariableName = 'Error' ; ExpectedSeverity = 'Error'; IsReadOnly = $true } + @{ VariableName = 'ExecutionContext'; ExpectedSeverity = 'Error'; IsReadOnly = $true } + @{ VariableName = 'false'; ExpectedSeverity = 'Error'; IsReadOnly = $true } + @{ VariableName = 'Home'; ExpectedSeverity = 'Error'; IsReadOnly = $true } + @{ VariableName = 'Host'; ExpectedSeverity = 'Error'; IsReadOnly = $true } + @{ VariableName = 'PID'; ExpectedSeverity = 'Error'; IsReadOnly = $true } + @{ VariableName = 'PSCulture'; ExpectedSeverity = 'Error'; IsReadOnly = $true } + @{ VariableName = 'PSEdition'; ExpectedSeverity = 'Error'; IsReadOnly = $true } + @{ VariableName = 'PSHome'; ExpectedSeverity = 'Error'; IsReadOnly = $true } + @{ VariableName = 'PSUICulture'; ExpectedSeverity = 'Error'; IsReadOnly = $true } + @{ VariableName = 'PSVersionTable'; ExpectedSeverity = 'Error'; IsReadOnly = $true } + @{ VariableName = 'ShellId'; ExpectedSeverity = 'Error'; IsReadOnly = $true } + @{ VariableName = 'true'; ExpectedSeverity = 'Error'; IsReadOnly = $true } + # Variables introduced only in PowerShell 6+ have a Severity of Warning only + @{ VariableName = 'IsCoreCLR'; ExpectedSeverity = $excpectedSeverityForAutomaticVariablesInPowerShell6; OnlyPresentInCoreClr = $true } + @{ VariableName = 'IsLinux'; ExpectedSeverity = $excpectedSeverityForAutomaticVariablesInPowerShell6; OnlyPresentInCoreClr = $true } + @{ VariableName = 'IsMacOS'; ExpectedSeverity = $excpectedSeverityForAutomaticVariablesInPowerShell6; OnlyPresentInCoreClr = $true } + @{ VariableName = 'IsWindows'; ExpectedSeverity = $excpectedSeverityForAutomaticVariablesInPowerShell6; OnlyPresentInCoreClr = $true } + @{ VariableName = '_'; ExpectedSeverity = 'Warning' } + @{ VariableName = 'AllNodes'; ExpectedSeverity = 'Warning' } + @{ VariableName = 'Args'; ExpectedSeverity = 'Warning' } + @{ VariableName = 'ConsoleFilename'; ExpectedSeverity = 'Warning' } + @{ VariableName = 'Event'; ExpectedSeverity = 'Warning' } + @{ VariableName = 'EventArgs'; ExpectedSeverity = 'Warning' } + @{ VariableName = 'EventSubscriber'; ExpectedSeverity = 'Warning' } + @{ VariableName = 'ForEach'; ExpectedSeverity = 'Warning' } + @{ VariableName = 'Input'; ExpectedSeverity = 'Warning' } + @{ VariableName = 'Matches'; ExpectedSeverity = 'Warning' } + @{ VariableName = 'MyInvocation'; ExpectedSeverity = 'Warning' } + @{ VariableName = 'NestedPromptLevel'; ExpectedSeverity = 'Warning' } + @{ VariableName = 'Profile'; ExpectedSeverity = 'Warning' } + @{ VariableName = 'PSBoundParameters'; ExpectedSeverity = 'Warning' } + @{ VariableName = 'PsCmdlet'; ExpectedSeverity = 'Warning' } + @{ VariableName = 'PSCommandPath'; ExpectedSeverity = 'Warning' } + @{ VariableName = 'ReportErrorShowExceptionClass'; ExpectedSeverity = 'Warning' } + @{ VariableName = 'ReportErrorShowInnerException'; ExpectedSeverity = 'Warning' } + @{ VariableName = 'ReportErrorShowSource'; ExpectedSeverity = 'Warning' } + @{ VariableName = 'ReportErrorShowStackTrace'; ExpectedSeverity = 'Warning' } + @{ VariableName = 'Sender'; ExpectedSeverity = 'Warning' } + @{ VariableName = 'StackTrace'; ExpectedSeverity = 'Warning' } + @{ VariableName = 'This'; ExpectedSeverity = 'Warning' } + ) + + $testCases_ReadOnlyAutomaticVariables = $testCases_AutomaticVariables | Where-Object { $_.IsReadonly } } - $testCases_AutomaticVariables = @( - @{ VariableName = '?'; ExpectedSeverity = 'Error'; IsReadOnly = $true } - @{ VariableName = 'Error' ; ExpectedSeverity = 'Error'; IsReadOnly = $true } - @{ VariableName = 'ExecutionContext'; ExpectedSeverity = 'Error'; IsReadOnly = $true } - @{ VariableName = 'false'; ExpectedSeverity = 'Error'; IsReadOnly = $true } - @{ VariableName = 'Home'; ExpectedSeverity = 'Error'; IsReadOnly = $true } - @{ VariableName = 'Host'; ExpectedSeverity = 'Error'; IsReadOnly = $true } - @{ VariableName = 'PID'; ExpectedSeverity = 'Error'; IsReadOnly = $true } - @{ VariableName = 'PSCulture'; ExpectedSeverity = 'Error'; IsReadOnly = $true } - @{ VariableName = 'PSEdition'; ExpectedSeverity = 'Error'; IsReadOnly = $true } - @{ VariableName = 'PSHome'; ExpectedSeverity = 'Error'; IsReadOnly = $true } - @{ VariableName = 'PSUICulture'; ExpectedSeverity = 'Error'; IsReadOnly = $true } - @{ VariableName = 'PSVersionTable'; ExpectedSeverity = 'Error'; IsReadOnly = $true } - @{ VariableName = 'ShellId'; ExpectedSeverity = 'Error'; IsReadOnly = $true } - @{ VariableName = 'true'; ExpectedSeverity = 'Error'; IsReadOnly = $true } - # Variables introduced only in PowerShell 6+ have a Severity of Warning only - @{ VariableName = 'IsCoreCLR'; ExpectedSeverity = $excpectedSeverityForAutomaticVariablesInPowerShell6; OnlyPresentInCoreClr = $true } - @{ VariableName = 'IsLinux'; ExpectedSeverity = $excpectedSeverityForAutomaticVariablesInPowerShell6; OnlyPresentInCoreClr = $true } - @{ VariableName = 'IsMacOS'; ExpectedSeverity = $excpectedSeverityForAutomaticVariablesInPowerShell6; OnlyPresentInCoreClr = $true } - @{ VariableName = 'IsWindows'; ExpectedSeverity = $excpectedSeverityForAutomaticVariablesInPowerShell6; OnlyPresentInCoreClr = $true } - @{ VariableName = '_'; ExpectedSeverity = 'Warning' } - @{ VariableName = 'AllNodes'; ExpectedSeverity = 'Warning' } - @{ VariableName = 'Args'; ExpectedSeverity = 'Warning' } - @{ VariableName = 'ConsoleFilename'; ExpectedSeverity = 'Warning' } - @{ VariableName = 'Event'; ExpectedSeverity = 'Warning' } - @{ VariableName = 'EventArgs'; ExpectedSeverity = 'Warning' } - @{ VariableName = 'EventSubscriber'; ExpectedSeverity = 'Warning' } - @{ VariableName = 'ForEach'; ExpectedSeverity = 'Warning' } - @{ VariableName = 'Input'; ExpectedSeverity = 'Warning' } - @{ VariableName = 'Matches'; ExpectedSeverity = 'Warning' } - @{ VariableName = 'MyInvocation'; ExpectedSeverity = 'Warning' } - @{ VariableName = 'NestedPromptLevel'; ExpectedSeverity = 'Warning' } - @{ VariableName = 'Profile'; ExpectedSeverity = 'Warning' } - @{ VariableName = 'PSBoundParameters'; ExpectedSeverity = 'Warning' } - @{ VariableName = 'PsCmdlet'; ExpectedSeverity = 'Warning' } - @{ VariableName = 'PSCommandPath'; ExpectedSeverity = 'Warning' } - @{ VariableName = 'ReportErrorShowExceptionClass'; ExpectedSeverity = 'Warning' } - @{ VariableName = 'ReportErrorShowInnerException'; ExpectedSeverity = 'Warning' } - @{ VariableName = 'ReportErrorShowSource'; ExpectedSeverity = 'Warning' } - @{ VariableName = 'ReportErrorShowStackTrace'; ExpectedSeverity = 'Warning' } - @{ VariableName = 'Sender'; ExpectedSeverity = 'Warning' } - @{ VariableName = 'StackTrace'; ExpectedSeverity = 'Warning' } - @{ VariableName = 'This'; ExpectedSeverity = 'Warning' } - ) - - $testCases_ReadOnlyAutomaticVariables = $testCases_AutomaticVariables | Where-Object { $_.IsReadonly } - It "Variable produces warning of Severity " -TestCases $testCases_AutomaticVariables { param ($VariableName, $ExpectedSeverity) @@ -133,6 +134,29 @@ Describe "AvoidAssignmentToAutomaticVariables" { } } } + } + + Context 'Suppression' { + BeforeDiscovery { + $testCases_RuleSuppression = @( + @{ VariableName = 'true'; Type = 'ReadOnlyAutomaticVariableError' } + @{ VariableName = 'IsWindows'; Type = 'ReadOnlyAutomaticVariableIntroducedInPowerShell6_0Error' } + @{ VariableName = 'ForEach'; Type = 'WritableAutomaticVariableError' } + ) + } + + It 'Variable of type can be suppressed by RuleSuppressionId' -TestCases $testCases_RuleSuppression { + $scriptDef = @" +function suppressionTest { + [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('$ruleName', '$VariableName')] + param( + `$$VariableName + ) +} +"@ + $warnings = @(Invoke-ScriptAnalyzer -ScriptDefinition $scriptDef -ExcludeRule PSReviewUnusedParameter) + $warnings.Count | Should -Be 0 + } } } From 772997f6ca780421fb5277818a729007ccd16ec4 Mon Sep 17 00:00:00 2001 From: Christoph Bergmeister Date: Sun, 17 Sep 2023 19:39:23 +0100 Subject: [PATCH 25/42] Upgrade to use .NET 6 (#1873) --- Engine/Engine.csproj | 10 +++++----- README.md | 2 +- Rules/Rules.csproj | 6 +++--- appveyor.yml | 2 +- build.psm1 | 2 +- global.json | 2 +- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/Engine/Engine.csproj b/Engine/Engine.csproj index 10ebf1222..ac8f389e7 100644 --- a/Engine/Engine.csproj +++ b/Engine/Engine.csproj @@ -2,7 +2,7 @@ 1.21.0 - netcoreapp3.1;net462 + net6;net462 Microsoft.Windows.PowerShell.ScriptAnalyzer 1.21.0 Engine @@ -18,11 +18,11 @@ portable - + $(DefineConstants);CORECLR - + @@ -63,10 +63,10 @@ - + - + $(DefineConstants);PSV7;CORECLR diff --git a/README.md b/README.md index a9ad2ae36..0e82f34be 100644 --- a/README.md +++ b/README.md @@ -72,7 +72,7 @@ To install **PSScriptAnalyzer** from source code: ### Requirements -- [.NET Core 3.1.424 SDK](https://www.microsoft.com/net/download/dotnet-core/3.1#sdk-3.1.424) or +- [.NET 6.0.11 containing 6.0.403 SDK](https://dotnet.microsoft.com/en-us/download/dotnet/6.0) or newer patch release * If building for Windows PowerShell versions, then the .NET Framework 4.6.2 [targeting pack](https://dotnet.microsoft.com/en-us/download/dotnet-framework/net462) (also referred to as developer/targeting pack) need to be installed. This is only possible on Windows. * Optionally but recommended for development: [Visual Studio 2017/2019](https://www.visualstudio.com/downloads) diff --git a/Rules/Rules.csproj b/Rules/Rules.csproj index 038d4b149..c52b04ad2 100644 --- a/Rules/Rules.csproj +++ b/Rules/Rules.csproj @@ -2,7 +2,7 @@ 1.21.0 - netcoreapp3.1;net462 + net6;net462 Microsoft.Windows.PowerShell.ScriptAnalyzer.BuiltinRules 1.21.0 Rules @@ -16,7 +16,7 @@ - + @@ -57,7 +57,7 @@ $(DefineConstants);PSV3;PSV4 - + $(DefineConstants);PSV7;CORECLR diff --git a/appveyor.yml b/appveyor.yml index e311eaa3a..4ba8d02c8 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -36,7 +36,7 @@ build_script: if ($env:PowerShellEdition -eq 'PowerShellCore') { Set-Location $env:APPVEYOR_BUILD_FOLDER ./build.ps1 -Configuration "$env:BuildConfiguration" -PSVersion 7 - ./PSCompatibilityCollector/build.ps1 -Configuration "$env:BuildConfiguration" -Framework 'netcoreapp3.1' + ./PSCompatibilityCollector/build.ps1 -Configuration "$env:BuildConfiguration" -Framework 'net6' } test_script: diff --git a/build.psm1 b/build.psm1 index 9f27d99a8..86dfbd763 100644 --- a/build.psm1 +++ b/build.psm1 @@ -203,7 +203,7 @@ function Start-ScriptAnalyzerBuild $framework = 'net462' if ($PSVersion -eq 7) { - $framework = 'netcoreapp3.1' + $framework = 'net6' } # build the appropriate assembly diff --git a/global.json b/global.json index e758de528..6d86a5b04 100644 --- a/global.json +++ b/global.json @@ -1,5 +1,5 @@ { "sdk": { - "version": "3.1.424" + "version": "6.0.403" } } From af02e801de8d4700e0f9c9aea08e1ce8d22a2443 Mon Sep 17 00:00:00 2001 From: ewisniew0 <114481734+ewisniew0@users.noreply.github.com> Date: Sun, 17 Sep 2023 18:43:53 +0000 Subject: [PATCH 26/42] Add ErrorView to SpecialVars.cs (#1865) * add ErrorView to SpecialVars and create test * Changed type of ErrorView --- Engine/SpecialVars.cs | 5 ++++- Tests/Rules/UseDeclaredVarsMoreThanAssignments.tests.ps1 | 5 +++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/Engine/SpecialVars.cs b/Engine/SpecialVars.cs index 26f1afcf7..0b820c0d4 100644 --- a/Engine/SpecialVars.cs +++ b/Engine/SpecialVars.cs @@ -91,6 +91,7 @@ static SpecialVars() internal const string ConfirmPreference = "ConfirmPreference"; internal const string ProgressPreference = "ProgressPreference"; internal const string InformationPreference = "InformationPreference"; + internal const string ErrorView = "ErrorView"; internal static readonly string[] PreferenceVariables = new string[] { @@ -101,7 +102,8 @@ static SpecialVars() WarningPreference, ConfirmPreference, ProgressPreference, - InformationPreference + InformationPreference, + ErrorView }; internal static readonly Type[] PreferenceVariableTypes = new Type[] @@ -114,6 +116,7 @@ static SpecialVars() /* ConfirmPreference */ typeof(ConfirmImpact), /* ProgressPreference */ typeof(Enum), /* InformationPreference */ typeof(ActionPreference), + /* ErrorView */ typeof(Enum), //ErrorView type not available on PS3 }; internal enum AutomaticVariable diff --git a/Tests/Rules/UseDeclaredVarsMoreThanAssignments.tests.ps1 b/Tests/Rules/UseDeclaredVarsMoreThanAssignments.tests.ps1 index 983ac017f..823334afb 100644 --- a/Tests/Rules/UseDeclaredVarsMoreThanAssignments.tests.ps1 +++ b/Tests/Rules/UseDeclaredVarsMoreThanAssignments.tests.ps1 @@ -72,6 +72,11 @@ function MyFunc2() { } Context "When there are no violations" { + It "No warning is issued for assignment without use of preference variable ErrorView" { + $results = Invoke-ScriptAnalyzer -ScriptDefinition '$ErrorView = NormalView' + $results.Count | Should -Be 0 + } + It "returns no violations" { $noViolations.Count | Should -Be 0 } From 847b146a08a1dd53857b6894ca79a1ad6ca5fc62 Mon Sep 17 00:00:00 2001 From: Christoph Bergmeister Date: Tue, 16 Jan 2024 22:30:00 +0000 Subject: [PATCH 27/42] Generate strongly typed resources as part of build (#1855) * first working version * cleanup * apply change to rules project as well --- Engine/Engine.csproj | 24 +- Engine/Strings.Designer.cs | 684 -------- Rules/Rules.csproj | 25 +- Rules/Strings.Designer.cs | 3330 ------------------------------------ 4 files changed, 30 insertions(+), 4033 deletions(-) delete mode 100644 Engine/Strings.Designer.cs delete mode 100644 Rules/Strings.Designer.cs diff --git a/Engine/Engine.csproj b/Engine/Engine.csproj index ac8f389e7..a22df13ee 100644 --- a/Engine/Engine.csproj +++ b/Engine/Engine.csproj @@ -48,20 +48,26 @@ - - - True - True - Strings.resx - - - + - ResXFileCodeGenerator + + MSBuild:Compile Strings.Designer.cs + $(IntermediateOutputPath)\Strings.Designer.cs + CSharp + Microsoft.Windows.PowerShell.ScriptAnalyzer + Strings + + + PrepareResources;$(CompileDependsOn) + + diff --git a/Engine/Strings.Designer.cs b/Engine/Strings.Designer.cs deleted file mode 100644 index 1fed6e234..000000000 --- a/Engine/Strings.Designer.cs +++ /dev/null @@ -1,684 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:4.0.30319.42000 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace Microsoft.Windows.PowerShell.ScriptAnalyzer { - using System; - - - /// - /// A strongly-typed resource class, for looking up localized strings, etc. - /// - // This class was auto-generated by the StronglyTypedResourceBuilder - // class via a tool like ResGen or Visual Studio. - // To add or remove a member, edit your .ResX file then rerun ResGen - // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - internal class Strings { - - private static global::System.Resources.ResourceManager resourceMan; - - private static global::System.Globalization.CultureInfo resourceCulture; - - [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] - internal Strings() { - } - - /// - /// Returns the cached ResourceManager instance used by this class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Resources.ResourceManager ResourceManager { - get { - if (object.ReferenceEquals(resourceMan, null)) { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Microsoft.Windows.PowerShell.ScriptAnalyzer.Strings", typeof(Strings).Assembly); - resourceMan = temp; - } - return resourceMan; - } - } - - /// - /// Overrides the current thread's CurrentUICulture property for all - /// resource lookups using this strongly typed resource class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Globalization.CultureInfo Culture { - get { - return resourceCulture; - } - set { - resourceCulture = value; - } - } - - /// - /// Looks up a localized string similar to Checking assembly file '{0}' .... - /// - internal static string CheckAssemblyFile { - get { - return ResourceManager.GetString("CheckAssemblyFile", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Checking module '{0}' .... - /// - internal static string CheckModuleName { - get { - return ResourceManager.GetString("CheckModuleName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to CommandInfo not found for function: {0}. - /// - internal static string CommandInfoNotFound { - get { - return ResourceManager.GetString("CommandInfoNotFound", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to "Argument should not be null.".. - /// - internal static string ConfigurableScriptRuleNRE { - get { - return ResourceManager.GetString("ConfigurableScriptRuleNRE", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to "Cannot find a ConfigurableRuleProperty attribute on property {0}".. - /// - internal static string ConfigurableScriptRulePropertyHasNotAttribute { - get { - return ResourceManager.GetString("ConfigurableScriptRulePropertyHasNotAttribute", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to SettingsFileHasInvalidHashtable. - /// - internal static string ConfigurationFileHasInvalidHashtable { - get { - return ResourceManager.GetString("ConfigurationFileHasInvalidHashtable", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to SettingsFileHasNoHashTable. - /// - internal static string ConfigurationFileHasNoHashTable { - get { - return ResourceManager.GetString("ConfigurationFileHasNoHashTable", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to SettingsFileNotFound. - /// - internal static string ConfigurationFileNotFound { - get { - return ResourceManager.GetString("ConfigurationFileNotFound", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to SettingsKeyNotAString. - /// - internal static string ConfigurationKeyNotAString { - get { - return ResourceManager.GetString("ConfigurationKeyNotAString", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to SettingsValueNotAString. - /// - internal static string ConfigurationValueNotAString { - get { - return ResourceManager.GetString("ConfigurationValueNotAString", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to SettingsValueWrongFormat. - /// - internal static string ConfigurationValueWrongFormat { - get { - return ResourceManager.GetString("ConfigurationValueWrongFormat", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Writes all diagnostics to WriteObject.. - /// - internal static string DefaultLoggerDescription { - get { - return ResourceManager.GetString("DefaultLoggerDescription", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to WriteObjects. - /// - internal static string DefaultLoggerName { - get { - return ResourceManager.GetString("DefaultLoggerName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Edge from {0} to {1} already exists.. - /// - internal static string DigraphEdgeAlreadyExists { - get { - return ResourceManager.GetString("DigraphEdgeAlreadyExists", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Vertex {0} already exists! Cannot add it to the digraph.. - /// - internal static string DigraphVertexAlreadyExists { - get { - return ResourceManager.GetString("DigraphVertexAlreadyExists", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Vertex {0} does not exist in the digraph.. - /// - internal static string DigraphVertexDoesNotExists { - get { - return ResourceManager.GetString("DigraphVertexDoesNotExists", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Cannot determine line endings as the text probably contain mixed line endings.. - /// - internal static string EditableTextInvalidLineEnding { - get { - return ResourceManager.GetString("EditableTextInvalidLineEnding", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to TextEdit extent not completely contained in EditableText.. - /// - internal static string EditableTextRangeIsNotContained { - get { - return ResourceManager.GetString("EditableTextRangeIsNotContained", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Cannot find file '{0}'.. - /// - internal static string FileNotFound { - get { - return ResourceManager.GetString("FileNotFound", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Cannot find the path '{0}'.. - /// - internal static string InvalidPath { - get { - return ResourceManager.GetString("InvalidPath", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Settings file '{0}' is invalid because it does not contain a hashtable.. - /// - internal static string InvalidProfile { - get { - return ResourceManager.GetString("InvalidProfile", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Key {0} in the settings is not a string.. - /// - internal static string KeyNotString { - get { - return ResourceManager.GetString("KeyNotString", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to No loggers found.. - /// - internal static string LoggersNotFound { - get { - return ResourceManager.GetString("LoggersNotFound", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Cannot find rule extension '{0}'.. - /// - internal static string MissingRuleExtension { - get { - return ResourceManager.GetString("MissingRuleExtension", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Temporary module location: {0}.. - /// - internal static string ModuleDepHandlerTempLocation { - get { - return ResourceManager.GetString("ModuleDepHandlerTempLocation", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to {0} cannot be set by both positional and named arguments.. - /// - internal static string NamedAndPositionalArgumentsConflictError { - get { - return ResourceManager.GetString("NamedAndPositionalArgumentsConflictError", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Named arguments must always come after positional arguments.. - /// - internal static string NamedArgumentsBeforePositionalError { - get { - return ResourceManager.GetString("NamedArgumentsBeforePositionalError", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to RuleName must not be null.. - /// - internal static string NullRuleNameError { - get { - return ResourceManager.GetString("NullRuleNameError", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Parse error in script definition: {0} at line {1} column {2}.. - /// - internal static string ParseErrorFormatForScriptDefinition { - get { - return ResourceManager.GetString("ParseErrorFormatForScriptDefinition", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Parse error in file {0}: {1} at line {2} column {3}.. - /// - internal static string ParserErrorFormat { - get { - return ResourceManager.GetString("ParserErrorFormat", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to There are too many parser errors in {0}. Please correct them before running ScriptAnalyzer.. - /// - internal static string ParserErrorMessage { - get { - return ResourceManager.GetString("ParserErrorMessage", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to There are too many parser errors in the script definition. Please correct them before running ScriptAnalyzer.. - /// - internal static string ParserErrorMessageForScriptDefinition { - get { - return ResourceManager.GetString("ParserErrorMessageForScriptDefinition", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Column number cannot be less than 1.. - /// - internal static string PositionColumnLessThanOne { - get { - return ResourceManager.GetString("PositionColumnLessThanOne", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Line number cannot be less than 1.. - /// - internal static string PositionLineLessThanOne { - get { - return ResourceManager.GetString("PositionLineLessThanOne", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Input position should be less than that of the invoking object.. - /// - internal static string PositionRefPosLessThanInputPos { - get { - return ResourceManager.GetString("PositionRefPosLessThanInputPos", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Reference Position should begin before start Position of Range.. - /// - internal static string RangeRefPosShouldStartBeforeRangeStartPos { - get { - return ResourceManager.GetString("RangeRefPosShouldStartBeforeRangeStartPos", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Start position cannot be before End position.. - /// - internal static string RangeStartPosGreaterThanEndPos { - get { - return ResourceManager.GetString("RangeStartPosGreaterThanEndPos", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to RULE_ERROR. - /// - internal static string RuleErrorMessage { - get { - return ResourceManager.GetString("RuleErrorMessage", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Cannot find ScriptAnalyzer rules in the specified path. - /// - internal static string RulesNotFound { - get { - return ResourceManager.GetString("RulesNotFound", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Suppression Message Attribute error at line {0} in {1} : {2}. - /// - internal static string RuleSuppressionErrorFormat { - get { - return ResourceManager.GetString("RuleSuppressionErrorFormat", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Suppression Message Attribute error at line {0} in script definition : {1}. - /// - internal static string RuleSuppressionErrorFormatScriptDefinition { - get { - return ResourceManager.GetString("RuleSuppressionErrorFormatScriptDefinition", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Cannot find any DiagnosticRecord with the Rule Suppression ID {0}.. - /// - internal static string RuleSuppressionIDError { - get { - return ResourceManager.GetString("RuleSuppressionIDError", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Found {0}. Will use it to provide settings for this invocation.. - /// - internal static string SettingsAutoDiscovered { - get { - return ResourceManager.GetString("SettingsAutoDiscovered", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Cannot resolve settings file path '{0}'.. - /// - internal static string SettingsCannotFindFile { - get { - return ResourceManager.GetString("SettingsCannotFindFile", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Dictionary should be indexable in a case-insensitive manner.. - /// - internal static string SettingsDictionaryShouldBeCaseInsesitive { - get { - return ResourceManager.GetString("SettingsDictionaryShouldBeCaseInsesitive", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Input should be a dictionary type.. - /// - internal static string SettingsInputShouldBeDictionary { - get { - return ResourceManager.GetString("SettingsInputShouldBeDictionary", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Settings should be either a file path, built-in preset or a hashtable.. - /// - internal static string SettingsInvalidType { - get { - return ResourceManager.GetString("SettingsInvalidType", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Cannot parse settings. Will abort the invocation.. - /// - internal static string SettingsNotParsable { - get { - return ResourceManager.GetString("SettingsNotParsable", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Settings not provided. Will look for settings file in the given path {0}.. - /// - internal static string SettingsNotProvided { - get { - return ResourceManager.GetString("SettingsNotProvided", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Settings object could not be resolved.. - /// - internal static string SettingsObjectCouldNotBResolved { - get { - return ResourceManager.GetString("SettingsObjectCouldNotBResolved", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Using settings file at {0}.. - /// - internal static string SettingsUsingFile { - get { - return ResourceManager.GetString("SettingsUsingFile", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Using settings hashtable.. - /// - internal static string SettingsUsingHashtable { - get { - return ResourceManager.GetString("SettingsUsingHashtable", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to {0} property must be of type bool.. - /// - internal static string SettingsValueTypeMustBeBool { - get { - return ResourceManager.GetString("SettingsValueTypeMustBeBool", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to All the arguments of the Suppress Message Attribute should be string constants.. - /// - internal static string StringConstantArgumentsSuppressionAttributeError { - get { - return ResourceManager.GetString("StringConstantArgumentsSuppressionAttributeError", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Cannot find any Targets {0} that match the Scope {1} to apply the SuppressMessageAttribute.. - /// - internal static string TargetCannotBeFoundError { - get { - return ResourceManager.GetString("TargetCannotBeFoundError", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to If Target is specified, Scope must be specified.. - /// - internal static string TargetWithoutScopeSuppressionAttributeError { - get { - return ResourceManager.GetString("TargetWithoutScopeSuppressionAttributeError", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Line element cannot be null.. - /// - internal static string TextEditNoNullItem { - get { - return ResourceManager.GetString("TextEditNoNullItem", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Line element cannot be null.. - /// - internal static string TextLinesNoNullItem { - get { - return ResourceManager.GetString("TextLinesNoNullItem", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Ignoring 'TypeNotFound' parse error on type '{0}'. Check if the specified type is correct. This can also be due the type not being known at parse time due to types imported by 'using' statements.. - /// - internal static string TypeNotFoundParseErrorFound { - get { - return ResourceManager.GetString("TypeNotFoundParseErrorFound", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Analyzing file: {0}. - /// - internal static string VerboseFileMessage { - get { - return ResourceManager.GetString("VerboseFileMessage", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Running {0} rule.. - /// - internal static string VerboseRunningMessage { - get { - return ResourceManager.GetString("VerboseRunningMessage", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Analyzing Script Definition.. - /// - internal static string VerboseScriptDefinitionMessage { - get { - return ResourceManager.GetString("VerboseScriptDefinitionMessage", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to WrongSettingsKey. - /// - internal static string WrongConfigurationKey { - get { - return ResourceManager.GetString("WrongConfigurationKey", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to {0} is not a valid key in the settings hashtable: file {3}. Valid keys are ExcludeRules, IncludeRules and Severity.. - /// - internal static string WrongKey { - get { - return ResourceManager.GetString("WrongKey", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Key in the settings hashtable should be a string: line {0} column {1} in file {2}. - /// - internal static string WrongKeyFormat { - get { - return ResourceManager.GetString("WrongKeyFormat", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to {0} is not a valid key in the settings hashtable. Valid keys are CustomRulePath, ExcludeRules, IncludeRules, IncludeDefaultRules, RecurseCustomRulePath, Rules and Severity.. - /// - internal static string WrongKeyHashTable { - get { - return ResourceManager.GetString("WrongKeyHashTable", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Scope can only be either function or class.. - /// - internal static string WrongScopeArgumentSuppressionAttributeError { - get { - return ResourceManager.GetString("WrongScopeArgumentSuppressionAttributeError", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Value in the settings hashtable should be a string or an array of strings: line {0} column {1} in file {2}. - /// - internal static string WrongValueFormat { - get { - return ResourceManager.GetString("WrongValueFormat", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Value {0} for key {1} has the wrong data type.. - /// - internal static string WrongValueHashTable { - get { - return ResourceManager.GetString("WrongValueHashTable", resourceCulture); - } - } - } -} diff --git a/Rules/Rules.csproj b/Rules/Rules.csproj index c52b04ad2..e3ab388c7 100644 --- a/Rules/Rules.csproj +++ b/Rules/Rules.csproj @@ -34,21 +34,26 @@ portable - - - True - True - Strings.resx - - - + - ResXFileCodeGenerator + + MSBuild:Compile Strings.Designer.cs + $(IntermediateOutputPath)\Strings.Designer.cs + CSharp + Microsoft.Windows.PowerShell.ScriptAnalyzer + Strings - + + + PrepareResources;$(CompileDependsOn) + + $(DefineConstants);PSV3 diff --git a/Rules/Strings.Designer.cs b/Rules/Strings.Designer.cs deleted file mode 100644 index f346e9084..000000000 --- a/Rules/Strings.Designer.cs +++ /dev/null @@ -1,3330 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:4.0.30319.42000 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace Microsoft.Windows.PowerShell.ScriptAnalyzer { - using System; - - - /// - /// A strongly-typed resource class, for looking up localized strings, etc. - /// - // This class was auto-generated by the StronglyTypedResourceBuilder - // class via a tool like ResGen or Visual Studio. - // To add or remove a member, edit your .ResX file then rerun ResGen - // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - internal class Strings { - - private static global::System.Resources.ResourceManager resourceMan; - - private static global::System.Globalization.CultureInfo resourceCulture; - - [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] - internal Strings() { - } - - /// - /// Returns the cached ResourceManager instance used by this class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Resources.ResourceManager ResourceManager { - get { - if (object.ReferenceEquals(resourceMan, null)) { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Microsoft.Windows.PowerShell.ScriptAnalyzer.Strings", typeof(Strings).Assembly); - resourceMan = temp; - } - return resourceMan; - } - } - - /// - /// Overrides the current thread's CurrentUICulture property for all - /// resource lookups using this strongly typed resource class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Globalization.CultureInfo Culture { - get { - return resourceCulture; - } - set { - resourceCulture = value; - } - } - - /// - /// Looks up a localized string similar to Align assignment statement. - /// - internal static string AlignAssignmentStatementCommonName { - get { - return ResourceManager.GetString("AlignAssignmentStatementCommonName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Line up assignment statements such that the assignment operator are aligned.. - /// - internal static string AlignAssignmentStatementDescription { - get { - return ResourceManager.GetString("AlignAssignmentStatementDescription", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Assignment statements are not aligned. - /// - internal static string AlignAssignmentStatementError { - get { - return ResourceManager.GetString("AlignAssignmentStatementError", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to AlignAssignmentStatement. - /// - internal static string AlignAssignmentStatementName { - get { - return ResourceManager.GetString("AlignAssignmentStatementName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to AvoidAssignmentToAutomaticVariable. - /// - internal static string AvoidAssignmentToAutomaticVariableName { - get { - return ResourceManager.GetString("AvoidAssignmentToAutomaticVariableName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Use a different variable name. - /// - internal static string AvoidAssignmentToReadOnlyAutomaticVariable { - get { - return ResourceManager.GetString("AvoidAssignmentToReadOnlyAutomaticVariable", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Changing automtic variables might have undesired side effects. - /// - internal static string AvoidAssignmentToReadOnlyAutomaticVariableCommonName { - get { - return ResourceManager.GetString("AvoidAssignmentToReadOnlyAutomaticVariableCommonName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to This automatic variables is built into PowerShell and readonly.. - /// - internal static string AvoidAssignmentToReadOnlyAutomaticVariableDescription { - get { - return ResourceManager.GetString("AvoidAssignmentToReadOnlyAutomaticVariableDescription", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to The Variable '{0}' cannot be assigned since it is a readonly automatic variable that is built into PowerShell, please use a different name.. - /// - internal static string AvoidAssignmentToReadOnlyAutomaticVariableError { - get { - return ResourceManager.GetString("AvoidAssignmentToReadOnlyAutomaticVariableError", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Starting from PowerShell 6.0, the Variable '{0}' cannot be assigned any more since it is a readonly automatic variable that is built into PowerShell, please use a different name.. - /// - internal static string AvoidAssignmentToReadOnlyAutomaticVariableIntroducedInPowerShell6_0Error { - get { - return ResourceManager.GetString("AvoidAssignmentToReadOnlyAutomaticVariableIntroducedInPowerShell6_0Error", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to The Variable '{0}' is an automatic variable that is built into PowerShell, assigning to it might have undesired side effects. If assignment is not by design, please use a different name.. - /// - internal static string AvoidAssignmentToWritableAutomaticVariableError { - get { - return ResourceManager.GetString("AvoidAssignmentToWritableAutomaticVariableError", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Avoid Using ComputerName Hardcoded. - /// - internal static string AvoidComputerNameHardcodedCommonName { - get { - return ResourceManager.GetString("AvoidComputerNameHardcodedCommonName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to The ComputerName parameter of a cmdlet should not be hardcoded as this will expose sensitive information about the system.. - /// - internal static string AvoidComputerNameHardcodedDescription { - get { - return ResourceManager.GetString("AvoidComputerNameHardcodedDescription", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to The ComputerName parameter of cmdlet '{0}' is hardcoded. This will expose sensitive information about the system if the script is shared.. - /// - internal static string AvoidComputerNameHardcodedError { - get { - return ResourceManager.GetString("AvoidComputerNameHardcodedError", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to AvoidUsingComputerNameHardcoded. - /// - internal static string AvoidComputerNameHardcodedName { - get { - return ResourceManager.GetString("AvoidComputerNameHardcodedName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Avoid Default Value For Mandatory Parameter. - /// - internal static string AvoidDefaultValueForMandatoryParameterCommonName { - get { - return ResourceManager.GetString("AvoidDefaultValueForMandatoryParameterCommonName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Mandatory parameter should not be initialized with a default value in the param block because this value will be ignored.. To fix a violation of this rule, please avoid initializing a value for the mandatory parameter in the param block.. - /// - internal static string AvoidDefaultValueForMandatoryParameterDescription { - get { - return ResourceManager.GetString("AvoidDefaultValueForMandatoryParameterDescription", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Mandatory Parameter '{0}' is initialized in the Param block. To fix a violation of this rule, please leave it uninitialized.. - /// - internal static string AvoidDefaultValueForMandatoryParameterError { - get { - return ResourceManager.GetString("AvoidDefaultValueForMandatoryParameterError", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to AvoidDefaultValueForMandatoryParameter. - /// - internal static string AvoidDefaultValueForMandatoryParameterName { - get { - return ResourceManager.GetString("AvoidDefaultValueForMandatoryParameterName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Switch Parameters Should Not Default To True. - /// - internal static string AvoidDefaultValueSwitchParameterCommonName { - get { - return ResourceManager.GetString("AvoidDefaultValueSwitchParameterCommonName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Switch parameter should not default to true.. - /// - internal static string AvoidDefaultValueSwitchParameterDescription { - get { - return ResourceManager.GetString("AvoidDefaultValueSwitchParameterDescription", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to File '{0}' has a switch parameter default to true.. - /// - internal static string AvoidDefaultValueSwitchParameterError { - get { - return ResourceManager.GetString("AvoidDefaultValueSwitchParameterError", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Script definition has a switch parameter default to true.. - /// - internal static string AvoidDefaultValueSwitchParameterErrorScriptDefinition { - get { - return ResourceManager.GetString("AvoidDefaultValueSwitchParameterErrorScriptDefinition", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to AvoidDefaultValueSwitchParameter. - /// - internal static string AvoidDefaultValueSwitchParameterName { - get { - return ResourceManager.GetString("AvoidDefaultValueSwitchParameterName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Empty catch block is used. Please use Write-Error or throw statements in catch blocks.. - /// - internal static string AvoidEmptyCatchBlockError { - get { - return ResourceManager.GetString("AvoidEmptyCatchBlockError", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Avoid exclaim operator. - /// - internal static string AvoidExclaimOperatorCommonName { - get { - return ResourceManager.GetString("AvoidExclaimOperatorCommonName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Replace ! with -not. - /// - internal static string AvoidExclaimOperatorCorrectionDescription { - get { - return ResourceManager.GetString("AvoidExclaimOperatorCorrectionDescription", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to The negation operator ! should not be used for readability purposes. Use -not instead.. - /// - internal static string AvoidExclaimOperatorDescription { - get { - return ResourceManager.GetString("AvoidExclaimOperatorDescription", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Avoid using the ! negation operator. - /// - internal static string AvoidExclaimOperatorError { - get { - return ResourceManager.GetString("AvoidExclaimOperatorError", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to AvoidExclaimOperator. - /// - internal static string AvoidExclaimOperatorName { - get { - return ResourceManager.GetString("AvoidExclaimOperatorName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Avoid global aliases.. - /// - internal static string AvoidGlobalAliasesCommonName { - get { - return ResourceManager.GetString("AvoidGlobalAliasesCommonName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Checks that global aliases are not used. Global aliases are strongly discouraged as they overwrite desired aliases with name conflicts.. - /// - internal static string AvoidGlobalAliasesDescription { - get { - return ResourceManager.GetString("AvoidGlobalAliasesDescription", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Avoid creating aliases with a Global scope.. - /// - internal static string AvoidGlobalAliasesError { - get { - return ResourceManager.GetString("AvoidGlobalAliasesError", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to AvoidGlobalAliases. - /// - internal static string AvoidGlobalAliasesName { - get { - return ResourceManager.GetString("AvoidGlobalAliasesName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Avoid global functiosn and aliases. - /// - internal static string AvoidGlobalFunctionsCommonName { - get { - return ResourceManager.GetString("AvoidGlobalFunctionsCommonName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Checks that global functions and aliases are not used. Global functions are strongly discouraged as they can cause errors across different systems.. - /// - internal static string AvoidGlobalFunctionsDescription { - get { - return ResourceManager.GetString("AvoidGlobalFunctionsDescription", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Avoid creating functions with a Global scope.. - /// - internal static string AvoidGlobalFunctionsError { - get { - return ResourceManager.GetString("AvoidGlobalFunctionsError", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to AvoidGlobalFunctions. - /// - internal static string AvoidGlobalFunctionsName { - get { - return ResourceManager.GetString("AvoidGlobalFunctionsName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to No Global Variables. - /// - internal static string AvoidGlobalVarsCommonName { - get { - return ResourceManager.GetString("AvoidGlobalVarsCommonName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Checks that global variables are not used. Global variables are strongly discouraged as they can cause errors across different systems.. - /// - internal static string AvoidGlobalVarsDescription { - get { - return ResourceManager.GetString("AvoidGlobalVarsDescription", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Found global variable '{0}'.. - /// - internal static string AvoidGlobalVarsError { - get { - return ResourceManager.GetString("AvoidGlobalVarsError", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to AvoidGlobalVars. - /// - internal static string AvoidGlobalVarsName { - get { - return ResourceManager.GetString("AvoidGlobalVarsName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Avoid Invoking Empty Members. - /// - internal static string AvoidInvokingEmptyMembersCommonName { - get { - return ResourceManager.GetString("AvoidInvokingEmptyMembersCommonName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Invoking non-constant members would cause potential bugs. Please double check the syntax to make sure members invoked are non-constant.. - /// - internal static string AvoidInvokingEmptyMembersDescription { - get { - return ResourceManager.GetString("AvoidInvokingEmptyMembersDescription", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to '{0}' has non-constant members. Invoking non-constant members may cause bugs in the script.. - /// - internal static string AvoidInvokingEmptyMembersError { - get { - return ResourceManager.GetString("AvoidInvokingEmptyMembersError", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to AvoidInvokingEmptyMembers. - /// - internal static string AvoidInvokingEmptyMembersName { - get { - return ResourceManager.GetString("AvoidInvokingEmptyMembersName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Avoid long lines. - /// - internal static string AvoidLongLinesCommonName { - get { - return ResourceManager.GetString("AvoidLongLinesCommonName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Line lengths should be less than the configured maximum. - /// - internal static string AvoidLongLinesDescription { - get { - return ResourceManager.GetString("AvoidLongLinesDescription", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Line exceeds the configured maximum length of {0} characters. - /// - internal static string AvoidLongLinesError { - get { - return ResourceManager.GetString("AvoidLongLinesError", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to AvoidLongLines. - /// - internal static string AvoidLongLinesName { - get { - return ResourceManager.GetString("AvoidLongLinesName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Avoid multiple type specifiers on parameters. - /// - internal static string AvoidMultipleTypeAttributesCommonName { - get { - return ResourceManager.GetString("AvoidMultipleTypeAttributesCommonName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Prameter should not have more than one type specifier.. - /// - internal static string AvoidMultipleTypeAttributesDescription { - get { - return ResourceManager.GetString("AvoidMultipleTypeAttributesDescription", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Parameter '{0}' has more than one type specifier.. - /// - internal static string AvoidMultipleTypeAttributesError { - get { - return ResourceManager.GetString("AvoidMultipleTypeAttributesError", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to AvoidMultipleTypeAttributes. - /// - internal static string AvoidMultipleTypeAttributesName { - get { - return ResourceManager.GetString("AvoidMultipleTypeAttributesName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Avoid using null or empty HelpMessage parameter attribute.. - /// - internal static string AvoidNullOrEmptyHelpMessageAttributeCommonName { - get { - return ResourceManager.GetString("AvoidNullOrEmptyHelpMessageAttributeCommonName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Setting the HelpMessage attribute to an empty string or null value causes PowerShell interpreter to throw an error while executing the corresponding function.. - /// - internal static string AvoidNullOrEmptyHelpMessageAttributeDescription { - get { - return ResourceManager.GetString("AvoidNullOrEmptyHelpMessageAttributeDescription", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to HelpMessage parameter attribute should not be null or empty. To fix a violation of this rule, please set its value to a non-empty string.. - /// - internal static string AvoidNullOrEmptyHelpMessageAttributeError { - get { - return ResourceManager.GetString("AvoidNullOrEmptyHelpMessageAttributeError", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to AvoidNullOrEmptyHelpMessageAttribute. - /// - internal static string AvoidNullOrEmptyHelpMessageAttributeName { - get { - return ResourceManager.GetString("AvoidNullOrEmptyHelpMessageAttributeName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Avoid overwriting built in cmdlets. - /// - internal static string AvoidOverwritingBuiltInCmdletsCommonName { - get { - return ResourceManager.GetString("AvoidOverwritingBuiltInCmdletsCommonName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Do not overwrite the definition of a cmdlet that is included with PowerShell. - /// - internal static string AvoidOverwritingBuiltInCmdletsDescription { - get { - return ResourceManager.GetString("AvoidOverwritingBuiltInCmdletsDescription", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to '{0}' is a cmdlet that is included with PowerShell (version {1}) whose definition should not be overridden. - /// - internal static string AvoidOverwritingBuiltInCmdletsError { - get { - return ResourceManager.GetString("AvoidOverwritingBuiltInCmdletsError", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to AvoidOverwritingBuiltInCmdlets. - /// - internal static string AvoidOverwritingBuiltInCmdletsName { - get { - return ResourceManager.GetString("AvoidOverwritingBuiltInCmdletsName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Avoid semicolons as line terminators. - /// - internal static string AvoidSemicolonsAsLineTerminatorsCommonName { - get { - return ResourceManager.GetString("AvoidSemicolonsAsLineTerminatorsCommonName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Line should not end with a semicolon. - /// - internal static string AvoidSemicolonsAsLineTerminatorsDescription { - get { - return ResourceManager.GetString("AvoidSemicolonsAsLineTerminatorsDescription", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Line ends with a semicolon. - /// - internal static string AvoidSemicolonsAsLineTerminatorsError { - get { - return ResourceManager.GetString("AvoidSemicolonsAsLineTerminatorsError", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to AvoidSemicolonsAsLineTerminators. - /// - internal static string AvoidSemicolonsAsLineTerminatorsName { - get { - return ResourceManager.GetString("AvoidSemicolonsAsLineTerminatorsName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Avoid Using ShouldContinue Without Boolean Force Parameter. - /// - internal static string AvoidShouldContinueWithoutForceCommonName { - get { - return ResourceManager.GetString("AvoidShouldContinueWithoutForceCommonName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Functions that use ShouldContinue should have a boolean force parameter to allow user to bypass it.. - /// - internal static string AvoidShouldContinueWithoutForceDescription { - get { - return ResourceManager.GetString("AvoidShouldContinueWithoutForceDescription", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Function '{0}' in file '{1}' uses ShouldContinue but does not have a boolean force parameter. The force parameter will allow users of the script to bypass ShouldContinue prompt. - /// - internal static string AvoidShouldContinueWithoutForceError { - get { - return ResourceManager.GetString("AvoidShouldContinueWithoutForceError", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Function '{0}' in script definition uses ShouldContinue but does not have a boolean force parameter. The force parameter will allow users of the script to bypass ShouldContinue prompt. - /// - internal static string AvoidShouldContinueWithoutForceErrorScriptDefinition { - get { - return ResourceManager.GetString("AvoidShouldContinueWithoutForceErrorScriptDefinition", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to AvoidShouldContinueWithoutForce. - /// - internal static string AvoidShouldContinueWithoutForceName { - get { - return ResourceManager.GetString("AvoidShouldContinueWithoutForceName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Avoid trailing whitespace. - /// - internal static string AvoidTrailingWhitespaceCommonName { - get { - return ResourceManager.GetString("AvoidTrailingWhitespaceCommonName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Each line should have no trailing whitespace.. - /// - internal static string AvoidTrailingWhitespaceDescription { - get { - return ResourceManager.GetString("AvoidTrailingWhitespaceDescription", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Line has trailing whitespace. - /// - internal static string AvoidTrailingWhitespaceError { - get { - return ResourceManager.GetString("AvoidTrailingWhitespaceError", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to AvoidTrailingWhitespace. - /// - internal static string AvoidTrailingWhitespaceName { - get { - return ResourceManager.GetString("AvoidTrailingWhitespaceName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Module Must Be Loadable. - /// - internal static string AvoidUnloadableModuleCommonName { - get { - return ResourceManager.GetString("AvoidUnloadableModuleCommonName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to If a script file is in a PowerShell module folder, then that folder must be loadable.. - /// - internal static string AvoidUnloadableModuleDescription { - get { - return ResourceManager.GetString("AvoidUnloadableModuleDescription", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Cannot load the module '{0}' that file '{1}' is in.. - /// - internal static string AvoidUnloadableModuleError { - get { - return ResourceManager.GetString("AvoidUnloadableModuleError", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to AvoidUnloadableModule. - /// - internal static string AvoidUnloadableModuleName { - get { - return ResourceManager.GetString("AvoidUnloadableModuleName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Avoid Using Username and Password Parameters. - /// - internal static string AvoidUsernameAndPasswordParamsCommonName { - get { - return ResourceManager.GetString("AvoidUsernameAndPasswordParamsCommonName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Functions should take in a Credential parameter of type PSCredential (with a Credential transformation attribute defined after it in PowerShell 4.0 or earlier) or set the Password parameter to type SecureString.. - /// - internal static string AvoidUsernameAndPasswordParamsDescription { - get { - return ResourceManager.GetString("AvoidUsernameAndPasswordParamsDescription", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Function '{0}' has both Username and Password parameters. Either set the type of the Password parameter to SecureString or replace the Username and Password parameters with a Credential parameter of type PSCredential. If using a Credential parameter in PowerShell 4.0 or earlier, please define a credential transformation attribute after the PSCredential type attribute.. - /// - internal static string AvoidUsernameAndPasswordParamsError { - get { - return ResourceManager.GetString("AvoidUsernameAndPasswordParamsError", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to AvoidUsingUsernameAndPasswordParams. - /// - internal static string AvoidUsernameAndPasswordParamsName { - get { - return ResourceManager.GetString("AvoidUsernameAndPasswordParamsName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Avoid Using Broken Hash Algorithms. - /// - internal static string AvoidUsingBrokenHashAlgorithmsCommonName { - get { - return ResourceManager.GetString("AvoidUsingBrokenHashAlgorithmsCommonName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Avoid using the broken algorithms MD5 or SHA-1.. - /// - internal static string AvoidUsingBrokenHashAlgorithmsDescription { - get { - return ResourceManager.GetString("AvoidUsingBrokenHashAlgorithmsDescription", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to The Algorithm parameter of cmdlet '{0}' was used with the broken algorithm '{1}'.. - /// - internal static string AvoidUsingBrokenHashAlgorithmsError { - get { - return ResourceManager.GetString("AvoidUsingBrokenHashAlgorithmsError", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to AvoidUsingBrokenHashAlgorithms. - /// - internal static string AvoidUsingBrokenHashAlgorithmsName { - get { - return ResourceManager.GetString("AvoidUsingBrokenHashAlgorithmsName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Avoid Using Clear-Host. - /// - internal static string AvoidUsingClearHostCommonName { - get { - return ResourceManager.GetString("AvoidUsingClearHostCommonName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Using Clear-Host is not recommended because the cmdlet may not work in some hosts or there may even be no hosts at all.. - /// - internal static string AvoidUsingClearHostDescription { - get { - return ResourceManager.GetString("AvoidUsingClearHostDescription", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to File '{0}' uses Clear-Host. This is not recommended because it may not work in some hosts or there may even be no hosts at all.. - /// - internal static string AvoidUsingClearHostError { - get { - return ResourceManager.GetString("AvoidUsingClearHostError", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to AvoidUsingClearHost. - /// - internal static string AvoidUsingClearHostName { - get { - return ResourceManager.GetString("AvoidUsingClearHostName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Avoid Using Cmdlet Aliases or omitting the 'Get-' prefix.. - /// - internal static string AvoidUsingCmdletAliasesCommonName { - get { - return ResourceManager.GetString("AvoidUsingCmdletAliasesCommonName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Replace {0} with {1}. - /// - internal static string AvoidUsingCmdletAliasesCorrectionDescription { - get { - return ResourceManager.GetString("AvoidUsingCmdletAliasesCorrectionDescription", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to An alias is an alternate name or nickname for a cmdlet or for a command element, such as a function, script, file, or executable file. An implicit alias is also the omission of the 'Get-' prefix for commands with this prefix. But when writing scripts that will potentially need to be maintained over time, either by the original author or another Windows PowerShell scripter, please consider using full cmdlet name instead of alias. Aliases can introduce these problems, readability, understandability and availa [rest of string was truncated]";. - /// - internal static string AvoidUsingCmdletAliasesDescription { - get { - return ResourceManager.GetString("AvoidUsingCmdletAliasesDescription", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to '{0}' is an alias of '{1}'. Alias can introduce possible problems and make scripts hard to maintain. Please consider changing alias to its full content.. - /// - internal static string AvoidUsingCmdletAliasesError { - get { - return ResourceManager.GetString("AvoidUsingCmdletAliasesError", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to '{0}' is implicitly aliasing '{1}' because it is missing the 'Get-' prefix. This can introduce possible problems and make scripts hard to maintain. Please consider changing command to its full name.. - /// - internal static string AvoidUsingCmdletAliasesMissingGetPrefixError { - get { - return ResourceManager.GetString("AvoidUsingCmdletAliasesMissingGetPrefixError", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to AvoidUsingCmdletAliases. - /// - internal static string AvoidUsingCmdletAliasesName { - get { - return ResourceManager.GetString("AvoidUsingCmdletAliasesName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to File '{0}' uses Console.'{1}'. Using Console to write is not recommended because it may not work in all hosts or there may even be no hosts at all. Use Write-Output instead.. - /// - internal static string AvoidUsingConsoleWriteError { - get { - return ResourceManager.GetString("AvoidUsingConsoleWriteError", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Avoid Using SecureString With Plain Text. - /// - internal static string AvoidUsingConvertToSecureStringWithPlainTextCommonName { - get { - return ResourceManager.GetString("AvoidUsingConvertToSecureStringWithPlainTextCommonName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Using ConvertTo-SecureString with plain text will expose secure information.. - /// - internal static string AvoidUsingConvertToSecureStringWithPlainTextDescription { - get { - return ResourceManager.GetString("AvoidUsingConvertToSecureStringWithPlainTextDescription", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to File '{0}' uses ConvertTo-SecureString with plaintext. This will expose secure information. Encrypted standard strings should be used instead.. - /// - internal static string AvoidUsingConvertToSecureStringWithPlainTextError { - get { - return ResourceManager.GetString("AvoidUsingConvertToSecureStringWithPlainTextError", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Script definition uses ConvertTo-SecureString with plaintext. This will expose secure information. Encrypted standard strings should be used instead.. - /// - internal static string AvoidUsingConvertToSecureStringWithPlainTextErrorScriptDefinition { - get { - return ResourceManager.GetString("AvoidUsingConvertToSecureStringWithPlainTextErrorScriptDefinition", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to AvoidUsingConvertToSecureStringWithPlainText. - /// - internal static string AvoidUsingConvertToSecureStringWithPlainTextName { - get { - return ResourceManager.GetString("AvoidUsingConvertToSecureStringWithPlainTextName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Avoid Using Deprecated Manifest Fields. - /// - internal static string AvoidUsingDeprecatedManifestFieldsCommonName { - get { - return ResourceManager.GetString("AvoidUsingDeprecatedManifestFieldsCommonName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to "ModuleToProcess" is obsolete in the latest PowerShell version. Please update with the latest field "RootModule" in manifest files to avoid PowerShell version inconsistency.. - /// - internal static string AvoidUsingDeprecatedManifestFieldsDescription { - get { - return ResourceManager.GetString("AvoidUsingDeprecatedManifestFieldsDescription", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to AvoidUsingDeprecatedManifestFields. - /// - internal static string AvoidUsingDeprecatedManifestFieldsName { - get { - return ResourceManager.GetString("AvoidUsingDeprecatedManifestFieldsName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Avoid using double quotes if the string is constant.. - /// - internal static string AvoidUsingDoubleQuotesForConstantStringCommonName { - get { - return ResourceManager.GetString("AvoidUsingDoubleQuotesForConstantStringCommonName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Use single quotes if the string is constant.. - /// - internal static string AvoidUsingDoubleQuotesForConstantStringDescription { - get { - return ResourceManager.GetString("AvoidUsingDoubleQuotesForConstantStringDescription", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Use single quotes when a string is constant.. - /// - internal static string AvoidUsingDoubleQuotesForConstantStringError { - get { - return ResourceManager.GetString("AvoidUsingDoubleQuotesForConstantStringError", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to AvoidUsingDoubleQuotesForConstantString. - /// - internal static string AvoidUsingDoubleQuotesForConstantStringName { - get { - return ResourceManager.GetString("AvoidUsingDoubleQuotesForConstantStringName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Avoid Using Empty Catch Block. - /// - internal static string AvoidUsingEmptyCatchBlockCommonName { - get { - return ResourceManager.GetString("AvoidUsingEmptyCatchBlockCommonName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Empty catch blocks are considered poor design decisions because if an error occurs in the try block, this error is simply swallowed and not acted upon. While this does not inherently lead to bad things. It can and this should be avoided if possible. To fix a violation of this rule, using Write-Error or throw statements in catch blocks.. - /// - internal static string AvoidUsingEmptyCatchBlockDescription { - get { - return ResourceManager.GetString("AvoidUsingEmptyCatchBlockDescription", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to AvoidUsingEmptyCatchBlock. - /// - internal static string AvoidUsingEmptyCatchBlockName { - get { - return ResourceManager.GetString("AvoidUsingEmptyCatchBlockName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Avoid Using Internal URLs. - /// - internal static string AvoidUsingInternalURLsCommonName { - get { - return ResourceManager.GetString("AvoidUsingInternalURLsCommonName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Using Internal URLs in the scripts may cause security problems.. - /// - internal static string AvoidUsingInternalURLsDescription { - get { - return ResourceManager.GetString("AvoidUsingInternalURLsDescription", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to '{0}' could be an internal URL. Using internal URL directly in the script may cause potential information disclosure.. - /// - internal static string AvoidUsingInternalURLsError { - get { - return ResourceManager.GetString("AvoidUsingInternalURLsError", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to AvoidUsingInternalURLs. - /// - internal static string AvoidUsingInternalURLsName { - get { - return ResourceManager.GetString("AvoidUsingInternalURLsName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Invoke-Expression is used. Please remove Invoke-Expression from script and find other options instead.. - /// - internal static string AvoidUsingInvokeExpressionError { - get { - return ResourceManager.GetString("AvoidUsingInvokeExpressionError", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Avoid Using Invoke-Expression. - /// - internal static string AvoidUsingInvokeExpressionRuleCommonName { - get { - return ResourceManager.GetString("AvoidUsingInvokeExpressionRuleCommonName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to The Invoke-Expression cmdlet evaluates or runs a specified string as a command and returns the results of the expression or command. It can be extraordinarily powerful so it is not that you want to never use it but you need to be very careful about using it. In particular, you are probably on safe ground if the data only comes from the program itself. If you include any data provided from the user - you need to protect yourself from Code Injection. To fix a violation of this rule, please remove Invoke-Exp [rest of string was truncated]";. - /// - internal static string AvoidUsingInvokeExpressionRuleDescription { - get { - return ResourceManager.GetString("AvoidUsingInvokeExpressionRuleDescription", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to AvoidUsingInvokeExpression. - /// - internal static string AvoidUsingInvokeExpressionRuleName { - get { - return ResourceManager.GetString("AvoidUsingInvokeExpressionRuleName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Avoid Using Plain Text For Password Parameter. - /// - internal static string AvoidUsingPlainTextForPasswordCommonName { - get { - return ResourceManager.GetString("AvoidUsingPlainTextForPasswordCommonName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Set {0} type to {1}. - /// - internal static string AvoidUsingPlainTextForPasswordCorrectionDescription { - get { - return ResourceManager.GetString("AvoidUsingPlainTextForPasswordCorrectionDescription", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Password parameters that take in plaintext will expose passwords and compromise the security of your system.. - /// - internal static string AvoidUsingPlainTextForPasswordDescription { - get { - return ResourceManager.GetString("AvoidUsingPlainTextForPasswordDescription", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Parameter '{0}' should not use String type but either SecureString or PSCredential, otherwise it increases the chance to expose this sensitive information.. - /// - internal static string AvoidUsingPlainTextForPasswordError { - get { - return ResourceManager.GetString("AvoidUsingPlainTextForPasswordError", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to AvoidUsingPlainTextForPassword. - /// - internal static string AvoidUsingPlainTextForPasswordName { - get { - return ResourceManager.GetString("AvoidUsingPlainTextForPasswordName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Avoid Using Positional Parameters. - /// - internal static string AvoidUsingPositionalParametersCommonName { - get { - return ResourceManager.GetString("AvoidUsingPositionalParametersCommonName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Readability and clarity should be the goal of any script we expect to maintain over time. When calling a command that takes parameters, where possible consider using name parameters as opposed to positional parameters. To fix a violation of this rule, please use named parameters instead of positional parameters when calling a command.. - /// - internal static string AvoidUsingPositionalParametersDescription { - get { - return ResourceManager.GetString("AvoidUsingPositionalParametersDescription", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Cmdlet '{0}' has positional parameter. Please use named parameters instead of positional parameters when calling a command.. - /// - internal static string AvoidUsingPositionalParametersError { - get { - return ResourceManager.GetString("AvoidUsingPositionalParametersError", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to AvoidUsingPositionalParameters. - /// - internal static string AvoidUsingPositionalParametersName { - get { - return ResourceManager.GetString("AvoidUsingPositionalParametersName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Avoid Using Get-WMIObject, Remove-WMIObject, Invoke-WmiMethod, Register-WmiEvent, Set-WmiInstance. - /// - internal static string AvoidUsingWMICmdletCommonName { - get { - return ResourceManager.GetString("AvoidUsingWMICmdletCommonName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Deprecated. Starting in Windows PowerShell 3.0, these cmdlets have been superseded by CIM cmdlets.. - /// - internal static string AvoidUsingWMICmdletDescription { - get { - return ResourceManager.GetString("AvoidUsingWMICmdletDescription", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to File '{0}' uses WMI cmdlet. For PowerShell 3.0 and above, use CIM cmdlet which perform the same tasks as the WMI cmdlets. The CIM cmdlets comply with WS-Management (WSMan) standards and with the Common Information Model (CIM) standard, which enables the cmdlets to use the same techniques to manage Windows computers and those running other operating systems.. - /// - internal static string AvoidUsingWMICmdletError { - get { - return ResourceManager.GetString("AvoidUsingWMICmdletError", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Script definition uses WMI cmdlet. For PowerShell 3.0 and above, use CIM cmdlet which perform the same tasks as the WMI cmdlets. The CIM cmdlets comply with WS-Management (WSMan) standards and with the Common Information Model (CIM) standard, which enables the cmdlets to use the same techniques to manage Windows computers and those running other operating systems.. - /// - internal static string AvoidUsingWMICmdletErrorScriptDefinition { - get { - return ResourceManager.GetString("AvoidUsingWMICmdletErrorScriptDefinition", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to AvoidUsingWMICmdlet. - /// - internal static string AvoidUsingWMICmdletName { - get { - return ResourceManager.GetString("AvoidUsingWMICmdletName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Avoid Using Write-Host. - /// - internal static string AvoidUsingWriteHostCommonName { - get { - return ResourceManager.GetString("AvoidUsingWriteHostCommonName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Avoid using the Write-Host cmdlet. Instead, use Write-Output, Write-Verbose, or Write-Information. Because Write-Host is host-specific, its implementation might vary unpredictably. Also, prior to PowerShell 5.0, Write-Host did not write to a stream, so users cannot suppress it, capture its value, or redirect it.. - /// - internal static string AvoidUsingWriteHostDescription { - get { - return ResourceManager.GetString("AvoidUsingWriteHostDescription", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to File '{0}' uses Write-Host. Avoid using Write-Host because it might not work in all hosts, does not work when there is no host, and (prior to PS 5.0) cannot be suppressed, captured, or redirected. Instead, use Write-Output, Write-Verbose, or Write-Information.. - /// - internal static string AvoidUsingWriteHostError { - get { - return ResourceManager.GetString("AvoidUsingWriteHostError", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Script definition uses Write-Host. Avoid using Write-Host because it might not work in all hosts, does not work when there is no host, and (prior to PS 5.0) cannot be suppressed, captured, or redirected. Instead, use Write-Output, Write-Verbose, or Write-Information.. - /// - internal static string AvoidUsingWriteHostErrorScriptDefinition { - get { - return ResourceManager.GetString("AvoidUsingWriteHostErrorScriptDefinition", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to AvoidUsingWriteHost. - /// - internal static string AvoidUsingWriteHostName { - get { - return ResourceManager.GetString("AvoidUsingWriteHostName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Command Not Found. - /// - internal static string CommandNotFoundCommonName { - get { - return ResourceManager.GetString("CommandNotFoundCommonName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Commands that are undefined or do not exist should not be used.. - /// - internal static string CommandNotFoundDescription { - get { - return ResourceManager.GetString("CommandNotFoundDescription", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Command '{0}' Is Not Found. - /// - internal static string CommandNotFoundError { - get { - return ResourceManager.GetString("CommandNotFoundError", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to CommandNotFound. - /// - internal static string CommandNotFoundName { - get { - return ResourceManager.GetString("CommandNotFoundName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to DscExamplesPresent. - /// - internal static string DscExamplesPresent { - get { - return ResourceManager.GetString("DscExamplesPresent", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to DSC examples are present. - /// - internal static string DscExamplesPresentCommonName { - get { - return ResourceManager.GetString("DscExamplesPresentCommonName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Every DSC resource module should contain folder "Examples" with sample configurations for every resource. Sample configurations should have resource name they are demonstrating in the title.. - /// - internal static string DscExamplesPresentDescription { - get { - return ResourceManager.GetString("DscExamplesPresentDescription", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to No examples found for resource '{0}'. - /// - internal static string DscExamplesPresentNoExamplesError { - get { - return ResourceManager.GetString("DscExamplesPresentNoExamplesError", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to PSDSC. - /// - internal static string DSCSourceName { - get { - return ResourceManager.GetString("DSCSourceName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to DscTestsPresent. - /// - internal static string DscTestsPresent { - get { - return ResourceManager.GetString("DscTestsPresent", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Dsc tests are present. - /// - internal static string DscTestsPresentCommonName { - get { - return ResourceManager.GetString("DscTestsPresentCommonName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Every DSC resource module should contain folder "Tests" with tests for every resource. Test scripts should have resource name they are testing in the file name.. - /// - internal static string DscTestsPresentDescription { - get { - return ResourceManager.GetString("DscTestsPresentDescription", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to No tests found for resource '{0}'. - /// - internal static string DscTestsPresentNoTestsError { - get { - return ResourceManager.GetString("DscTestsPresentNoTestsError", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to When using an explicit process block, no preceding code is allowed, only begin, end and dynamicparams blocks.. - /// - internal static string InvalidSyntaxAroundProcessBlockError { - get { - return ResourceManager.GetString("InvalidSyntaxAroundProcessBlockError", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Misleading Backtick. - /// - internal static string MisleadingBacktickCommonName { - get { - return ResourceManager.GetString("MisleadingBacktickCommonName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Ending a line with an escaped whitepsace character is misleading. A trailing backtick is usually used for line continuation. Users typically don't intend to end a line with escaped whitespace.. - /// - internal static string MisleadingBacktickDescription { - get { - return ResourceManager.GetString("MisleadingBacktickDescription", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to This line has a backtick at the end trailed by a whitespace character. Did you mean for this to be a line continuation?. - /// - internal static string MisleadingBacktickError { - get { - return ResourceManager.GetString("MisleadingBacktickError", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to MisleadingBacktick. - /// - internal static string MisleadingBacktickName { - get { - return ResourceManager.GetString("MisleadingBacktickName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Module Manifest Fields. - /// - internal static string MissingModuleManifestFieldCommonName { - get { - return ResourceManager.GetString("MissingModuleManifestFieldCommonName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Add {0} = {1} to the module manifest. - /// - internal static string MissingModuleManifestFieldCorrectionDescription { - get { - return ResourceManager.GetString("MissingModuleManifestFieldCorrectionDescription", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Some fields of the module manifest (such as ModuleVersion) are required.. - /// - internal static string MissingModuleManifestFieldDescription { - get { - return ResourceManager.GetString("MissingModuleManifestFieldDescription", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to MissingModuleManifestField. - /// - internal static string MissingModuleManifestFieldName { - get { - return ResourceManager.GetString("MissingModuleManifestFieldName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to {0}{1}. - /// - internal static string NameSpaceFormat { - get { - return ResourceManager.GetString("NameSpaceFormat", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Not all code path in {0} function in DSC Class {1} returns a value. - /// - internal static string NotAllCodePathReturnsDSCFunctionsError { - get { - return ResourceManager.GetString("NotAllCodePathReturnsDSCFunctionsError", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Cannot process null Ast. - /// - internal static string NullAstErrorMessage { - get { - return ResourceManager.GetString("NullAstErrorMessage", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Cannot process null CommandInfo. - /// - internal static string NullCommandInfoError { - get { - return ResourceManager.GetString("NullCommandInfoError", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Error Message is Null.. - /// - internal static string NullErrorMessage { - get { - return ResourceManager.GetString("NullErrorMessage", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to One Char. - /// - internal static string OneCharCommonName { - get { - return ResourceManager.GetString("OneCharCommonName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Checks that cmdlets and parameters have more than one character.. - /// - internal static string OneCharDescription { - get { - return ResourceManager.GetString("OneCharDescription", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to The cmdlet name '{0}' only has one character.. - /// - internal static string OneCharErrorCmdlet { - get { - return ResourceManager.GetString("OneCharErrorCmdlet", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to The cmdlet '{0}' has a parameter '{1}' that only has one character.. - /// - internal static string OneCharErrorParameter { - get { - return ResourceManager.GetString("OneCharErrorParameter", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to A script block has a parameter '{0}' that only has one character.. - /// - internal static string OneCharErrorParameterSB { - get { - return ResourceManager.GetString("OneCharErrorParameterSB", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to OneChar. - /// - internal static string OneCharName { - get { - return ResourceManager.GetString("OneCharName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Place close braces. - /// - internal static string PlaceCloseBraceCommonName { - get { - return ResourceManager.GetString("PlaceCloseBraceCommonName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Close brace should be on a new line by itself.. - /// - internal static string PlaceCloseBraceDescription { - get { - return ResourceManager.GetString("PlaceCloseBraceDescription", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Close brace is not on a new line.. - /// - internal static string PlaceCloseBraceErrorShouldBeOnNewLine { - get { - return ResourceManager.GetString("PlaceCloseBraceErrorShouldBeOnNewLine", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Close brace before a branch statement is followed by a new line.. - /// - internal static string PlaceCloseBraceErrorShouldCuddleBranchStatement { - get { - return ResourceManager.GetString("PlaceCloseBraceErrorShouldCuddleBranchStatement", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Close brace does not follow a new line.. - /// - internal static string PlaceCloseBraceErrorShouldFollowNewLine { - get { - return ResourceManager.GetString("PlaceCloseBraceErrorShouldFollowNewLine", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Close brace does not follow a non-empty line.. - /// - internal static string PlaceCloseBraceErrorShouldNotFollowEmptyLine { - get { - return ResourceManager.GetString("PlaceCloseBraceErrorShouldNotFollowEmptyLine", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to PlaceCloseBrace. - /// - internal static string PlaceCloseBraceName { - get { - return ResourceManager.GetString("PlaceCloseBraceName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Place open braces consistently. - /// - internal static string PlaceOpenBraceCommonName { - get { - return ResourceManager.GetString("PlaceOpenBraceCommonName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Place open braces either on the same line as the preceding expression or on a new line.. - /// - internal static string PlaceOpenBraceDescription { - get { - return ResourceManager.GetString("PlaceOpenBraceDescription", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to There is no new line after open brace.. - /// - internal static string PlaceOpenBraceErrorNoNewLineAfterBrace { - get { - return ResourceManager.GetString("PlaceOpenBraceErrorNoNewLineAfterBrace", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Open brace not on same line as preceding keyword. It should be on the same line.. - /// - internal static string PlaceOpenBraceErrorShouldBeOnSameLine { - get { - return ResourceManager.GetString("PlaceOpenBraceErrorShouldBeOnSameLine", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Open brace is not on a new line.. - /// - internal static string PlaceOpenBraceErrorShouldNotBeOnSameLine { - get { - return ResourceManager.GetString("PlaceOpenBraceErrorShouldNotBeOnSameLine", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to PlaceOpenBrace. - /// - internal static string PlaceOpenBraceName { - get { - return ResourceManager.GetString("PlaceOpenBraceName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Null Comparison. - /// - internal static string PossibleIncorrectComparisonWithNullCommonName { - get { - return ResourceManager.GetString("PossibleIncorrectComparisonWithNullCommonName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Checks that $null is on the left side of any equaltiy comparisons (eq, ne, ceq, cne, ieq, ine). When there is an array on the left side of a null equality comparison, PowerShell will check for a $null IN the array rather than if the array is null. If the two sides of the comaprision are switched this is fixed. Therefore, $null should always be on the left side of equality comparisons just in case.. - /// - internal static string PossibleIncorrectComparisonWithNullDescription { - get { - return ResourceManager.GetString("PossibleIncorrectComparisonWithNullDescription", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to $null should be on the left side of equality comparisons.. - /// - internal static string PossibleIncorrectComparisonWithNullError { - get { - return ResourceManager.GetString("PossibleIncorrectComparisonWithNullError", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to PossibleIncorrectComparisonWithNull. - /// - internal static string PossibleIncorrectComparisonWithNullName { - get { - return ResourceManager.GetString("PossibleIncorrectComparisonWithNullName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Use $null on the left hand side for safe comparison with $null.. - /// - internal static string PossibleIncorrectComparisonWithNullSuggesteCorrectionDescription { - get { - return ResourceManager.GetString("PossibleIncorrectComparisonWithNullSuggesteCorrectionDescription", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to '=' is not an assignment operator. Did you mean the equality operator '-eq'?. - /// - internal static string PossibleIncorrectUsageOfAssignmentOperatorCommonName { - get { - return ResourceManager.GetString("PossibleIncorrectUsageOfAssignmentOperatorCommonName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to '=' or '==' are not comparison operators in the PowerShell language and rarely needed inside conditional statements.. - /// - internal static string PossibleIncorrectUsageOfAssignmentOperatorDescription { - get { - return ResourceManager.GetString("PossibleIncorrectUsageOfAssignmentOperatorDescription", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Did you mean to use the assignment operator '='? The equality operator in PowerShell is 'eq'.. - /// - internal static string PossibleIncorrectUsageOfAssignmentOperatorError { - get { - return ResourceManager.GetString("PossibleIncorrectUsageOfAssignmentOperatorError", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to PossibleIncorrectUsageOfAssignmentOperator. - /// - internal static string PossibleIncorrectUsageOfAssignmentOperatorName { - get { - return ResourceManager.GetString("PossibleIncorrectUsageOfAssignmentOperatorName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to '>' is not a comparison operator. Use '-gt' (greater than) or '-ge' (greater or equal).. - /// - internal static string PossibleIncorrectUsageOfRedirectionOperatorCommonName { - get { - return ResourceManager.GetString("PossibleIncorrectUsageOfRedirectionOperatorCommonName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to When switching between different languages it is easy to forget that '>' does not mean 'great than' in PowerShell.. - /// - internal static string PossibleIncorrectUsageOfRedirectionOperatorDescription { - get { - return ResourceManager.GetString("PossibleIncorrectUsageOfRedirectionOperatorDescription", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Did you mean to use the redirection operator '>'? The comparison operators in PowerShell are '-gt' (greater than) or '-ge' (greater or equal).. - /// - internal static string PossibleIncorrectUsageOfRedirectionOperatorError { - get { - return ResourceManager.GetString("PossibleIncorrectUsageOfRedirectionOperatorError", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to PossibleIncorrectUsageOfRedirectionOperator. - /// - internal static string PossibleIncorrectUsageOfRedirectionOperatorName { - get { - return ResourceManager.GetString("PossibleIncorrectUsageOfRedirectionOperatorName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Basic Comment Help. - /// - internal static string ProvideCommentHelpCommonName { - get { - return ResourceManager.GetString("ProvideCommentHelpCommonName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Checks that all cmdlets have a help comment. This rule only checks existence. It does not check the content of the comment.. - /// - internal static string ProvideCommentHelpDescription { - get { - return ResourceManager.GetString("ProvideCommentHelpDescription", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to The cmdlet '{0}' does not have a help comment.. - /// - internal static string ProvideCommentHelpError { - get { - return ResourceManager.GetString("ProvideCommentHelpError", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to ProvideCommentHelp. - /// - internal static string ProvideCommentHelpName { - get { - return ResourceManager.GetString("ProvideCommentHelpName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Reserved Cmdlet Chars. - /// - internal static string ReservedCmdletCharCommonName { - get { - return ResourceManager.GetString("ReservedCmdletCharCommonName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Checks for reserved characters in cmdlet names. These characters usually cause a parsing error. Otherwise they will generally cause runtime errors.. - /// - internal static string ReservedCmdletCharDescription { - get { - return ResourceManager.GetString("ReservedCmdletCharDescription", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to The cmdlet '{0}' uses a reserved char in its name.. - /// - internal static string ReservedCmdletCharError { - get { - return ResourceManager.GetString("ReservedCmdletCharError", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to ReservedCmdletChar. - /// - internal static string ReservedCmdletCharName { - get { - return ResourceManager.GetString("ReservedCmdletCharName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to The cmdlet '{0}'. - /// - internal static string ReservedParamsCmdletPrefix { - get { - return ResourceManager.GetString("ReservedParamsCmdletPrefix", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Reserved Parameters. - /// - internal static string ReservedParamsCommonName { - get { - return ResourceManager.GetString("ReservedParamsCommonName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Checks for reserved parameters in function definitions. If these parameters are defined by the user, an error generally occurs.. - /// - internal static string ReservedParamsDescription { - get { - return ResourceManager.GetString("ReservedParamsDescription", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to '{0}' defines the reserved common parameter '{1}'.. - /// - internal static string ReservedParamsError { - get { - return ResourceManager.GetString("ReservedParamsError", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to ReservedParams. - /// - internal static string ReservedParamsName { - get { - return ResourceManager.GetString("ReservedParamsName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to The script. - /// - internal static string ReservedParamsScriptPrefix { - get { - return ResourceManager.GetString("ReservedParamsScriptPrefix", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to #,(){}[]&/\\$^;:\"'<>|?@`*%+=~. - /// - internal static string ReserverCmdletChars { - get { - return ResourceManager.GetString("ReserverCmdletChars", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to ReturnCorrectTypesForDSCFunctions. - /// - internal static string ReturnCorrectTypeDSCFunctionsName { - get { - return ResourceManager.GetString("ReturnCorrectTypeDSCFunctionsName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Return Correct Types For DSC Functions. - /// - internal static string ReturnCorrectTypesForDSCFunctionsCommonName { - get { - return ResourceManager.GetString("ReturnCorrectTypesForDSCFunctionsCommonName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Set function in DSC class and Set-TargetResource in DSC resource must not return anything. Get function in DSC class must return an instance of the DSC class and Get-TargetResource function in DSC resource must return a hashtable. Test function in DSC class and Get-TargetResource function in DSC resource must return a boolean.. - /// - internal static string ReturnCorrectTypesForDSCFunctionsDescription { - get { - return ResourceManager.GetString("ReturnCorrectTypesForDSCFunctionsDescription", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to {0} function in DSC Class {1} should return object of type {2}. - /// - internal static string ReturnCorrectTypesForDSCFunctionsNoTypeError { - get { - return ResourceManager.GetString("ReturnCorrectTypesForDSCFunctionsNoTypeError", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to {0} function in DSC Class {1} should return object of type {2} instead of type {3}. - /// - internal static string ReturnCorrectTypesForDSCFunctionsWrongTypeError { - get { - return ResourceManager.GetString("ReturnCorrectTypesForDSCFunctionsWrongTypeError", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to {0} function in DSC Resource should return object of type {1} instead of {2}. - /// - internal static string ReturnCorrectTypesForGetTestTargetResourceFunctionsDSCResourceError { - get { - return ResourceManager.GetString("ReturnCorrectTypesForGetTestTargetResourceFunctionsDSCResourceError", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Set function in DSC Class {0} should not return anything. - /// - internal static string ReturnCorrectTypesForSetFunctionsDSCError { - get { - return ResourceManager.GetString("ReturnCorrectTypesForSetFunctionsDSCError", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Set-TargetResource function in DSC Resource should not output anything to the pipeline.. - /// - internal static string ReturnCorrectTypesForSetTargetResourceFunctionsDSCError { - get { - return ResourceManager.GetString("ReturnCorrectTypesForSetTargetResourceFunctionsDSCError", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to ReviewUnusedParameter. - /// - internal static string ReviewUnusedParameterCommonName { - get { - return ResourceManager.GetString("ReviewUnusedParameterCommonName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Ensure all parameters are used within the same script, scriptblock, or function where they are declared.. - /// - internal static string ReviewUnusedParameterDescription { - get { - return ResourceManager.GetString("ReviewUnusedParameterDescription", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to The parameter '{0}' has been declared but not used. . - /// - internal static string ReviewUnusedParameterError { - get { - return ResourceManager.GetString("ReviewUnusedParameterError", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to ReviewUnusedParameter. - /// - internal static string ReviewUnusedParameterName { - get { - return ResourceManager.GetString("ReviewUnusedParameterName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to ScriptDefinition. - /// - internal static string ScriptDefinitionName { - get { - return ResourceManager.GetString("ScriptDefinitionName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to www.sharepoint.com. - /// - internal static string SharepointURL { - get { - return ResourceManager.GetString("SharepointURL", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Should Process. - /// - internal static string ShouldProcessCommonName { - get { - return ResourceManager.GetString("ShouldProcessCommonName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Checks that if the SupportsShouldProcess is present, the function calls ShouldProcess/ShouldContinue and vice versa. Scripts with one or the other but not both will generally run into an error or unexpected behavior.. - /// - internal static string ShouldProcessDescription { - get { - return ResourceManager.GetString("ShouldProcessDescription", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to '{0}' has the ShouldProcess attribute but does not call ShouldProcess/ShouldContinue.. - /// - internal static string ShouldProcessErrorHasAttribute { - get { - return ResourceManager.GetString("ShouldProcessErrorHasAttribute", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to A script block has the ShouldProcess attribute but does not call ShouldProcess/ShouldContinue.. - /// - internal static string ShouldProcessErrorHasAttributeSB { - get { - return ResourceManager.GetString("ShouldProcessErrorHasAttributeSB", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to '{0}' calls ShouldProcess/ShouldContinue but does not have the ShouldProcess attribute.. - /// - internal static string ShouldProcessErrorHasCmdlet { - get { - return ResourceManager.GetString("ShouldProcessErrorHasCmdlet", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to A script block calls ShouldProcess/ShouldContinue but does not have the ShouldProcess attribute.. - /// - internal static string ShouldProcessErrorHasCmdletSB { - get { - return ResourceManager.GetString("ShouldProcessErrorHasCmdletSB", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to ShouldProcess. - /// - internal static string ShouldProcessName { - get { - return ResourceManager.GetString("ShouldProcessName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to PS. - /// - internal static string SourceName { - get { - return ResourceManager.GetString("SourceName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Type Not Found. - /// - internal static string TypeNotFoundCommonName { - get { - return ResourceManager.GetString("TypeNotFoundCommonName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Undefined type should not be used. - /// - internal static string TypeNotFoundDescription { - get { - return ResourceManager.GetString("TypeNotFoundDescription", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Type '{0}' is not found. Please check that it is defined.. - /// - internal static string TypeNotFoundError { - get { - return ResourceManager.GetString("TypeNotFoundError", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to TypeNotFound. - /// - internal static string TypeNotFoundName { - get { - return ResourceManager.GetString("TypeNotFoundName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Cmdlet Verbs. - /// - internal static string UseApprovedVerbsCommonName { - get { - return ResourceManager.GetString("UseApprovedVerbsCommonName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Checks that all defined cmdlets use approved verbs. This is in line with PowerShell's best practices.. - /// - internal static string UseApprovedVerbsDescription { - get { - return ResourceManager.GetString("UseApprovedVerbsDescription", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to The cmdlet '{0}' uses an unapproved verb.. - /// - internal static string UseApprovedVerbsError { - get { - return ResourceManager.GetString("UseApprovedVerbsError", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to UseApprovedVerbs. - /// - internal static string UseApprovedVerbsName { - get { - return ResourceManager.GetString("UseApprovedVerbsName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Use BOM encoding for non-ASCII files. - /// - internal static string UseBOMForUnicodeEncodedFileCommonName { - get { - return ResourceManager.GetString("UseBOMForUnicodeEncodedFileCommonName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to For a file encoded with a format other than ASCII, ensure BOM is present to ensure that any application consuming this file can interpret it correctly.. - /// - internal static string UseBOMForUnicodeEncodedFileDescription { - get { - return ResourceManager.GetString("UseBOMForUnicodeEncodedFileDescription", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Missing BOM encoding for non-ASCII encoded file '{0}'. - /// - internal static string UseBOMForUnicodeEncodedFileError { - get { - return ResourceManager.GetString("UseBOMForUnicodeEncodedFileError", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to UseBOMForUnicodeEncodedFile. - /// - internal static string UseBOMForUnicodeEncodedFileName { - get { - return ResourceManager.GetString("UseBOMForUnicodeEncodedFileName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Use Cmdlet Correctly. - /// - internal static string UseCmdletCorrectlyCommonName { - get { - return ResourceManager.GetString("UseCmdletCorrectlyCommonName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Cmdlet should be called with the mandatory parameters.. - /// - internal static string UseCmdletCorrectlyDescription { - get { - return ResourceManager.GetString("UseCmdletCorrectlyDescription", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Cmdlet '{0}' may be used incorrectly. Please check that all mandatory parameters are supplied.. - /// - internal static string UseCmdletCorrectlyError { - get { - return ResourceManager.GetString("UseCmdletCorrectlyError", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to UseCmdletCorrectly. - /// - internal static string UseCmdletCorrectlyName { - get { - return ResourceManager.GetString("UseCmdletCorrectlyName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Use compatible cmdlets. - /// - internal static string UseCompatibleCmdletsCommonName { - get { - return ResourceManager.GetString("UseCompatibleCmdletsCommonName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Use cmdlets compatible with the given PowerShell version and edition and operating system. - /// - internal static string UseCompatibleCmdletsDescription { - get { - return ResourceManager.GetString("UseCompatibleCmdletsDescription", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to '{0}' is not compatible with PowerShell edition '{1}', version '{2}' and OS '{3}'. - /// - internal static string UseCompatibleCmdletsError { - get { - return ResourceManager.GetString("UseCompatibleCmdletsError", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to UseCompatibleCmdlets. - /// - internal static string UseCompatibleCmdletsName { - get { - return ResourceManager.GetString("UseCompatibleCmdletsName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to The command '{0}' is not available by default in PowerShell version '{1}' on platform '{2}'. - /// - internal static string UseCompatibleCommandsCommandError { - get { - return ResourceManager.GetString("UseCompatibleCommandsCommandError", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Use compatible commands. - /// - internal static string UseCompatibleCommandsCommonName { - get { - return ResourceManager.GetString("UseCompatibleCommandsCommonName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Use commands compatible with the given PowerShell version and operating system. - /// - internal static string UseCompatibleCommandsDescription { - get { - return ResourceManager.GetString("UseCompatibleCommandsDescription", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to UseCompatibleCommands. - /// - internal static string UseCompatibleCommandsName { - get { - return ResourceManager.GetString("UseCompatibleCommandsName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to The parameter '{0}' is not available for command '{1}' by default in PowerShell version '{2}' on platform '{3}'. - /// - internal static string UseCompatibleCommandsParameterError { - get { - return ResourceManager.GetString("UseCompatibleCommandsParameterError", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Use compatible syntax. - /// - internal static string UseCompatibleSyntaxCommonName { - get { - return ResourceManager.GetString("UseCompatibleSyntaxCommonName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Use the '{0}' syntax instead for compatibility with PowerShell versions {1}. - /// - internal static string UseCompatibleSyntaxCorrection { - get { - return ResourceManager.GetString("UseCompatibleSyntaxCorrection", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Use script syntax compatible with the given PowerShell versions. - /// - internal static string UseCompatibleSyntaxDescription { - get { - return ResourceManager.GetString("UseCompatibleSyntaxDescription", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to The {0} syntax '{1}' is not available by default in PowerShell versions {2}. - /// - internal static string UseCompatibleSyntaxError { - get { - return ResourceManager.GetString("UseCompatibleSyntaxError", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to UseCompatibleSyntax. - /// - internal static string UseCompatibleSyntaxName { - get { - return ResourceManager.GetString("UseCompatibleSyntaxName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Use compatible types. - /// - internal static string UseCompatibleTypesCommonName { - get { - return ResourceManager.GetString("UseCompatibleTypesCommonName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Use types compatible with the given PowerShell version and operating system. - /// - internal static string UseCompatibleTypesDescription { - get { - return ResourceManager.GetString("UseCompatibleTypesDescription", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to The member '{0}' is not available on type '{1}' by default in PowerShell version '{2}' on platform '{3}'. - /// - internal static string UseCompatibleTypesMemberError { - get { - return ResourceManager.GetString("UseCompatibleTypesMemberError", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to The method '{0}' is not available on type '{1}' by default in PowerShell version '{2}' on platform '{3}'. - /// - internal static string UseCompatibleTypesMethodError { - get { - return ResourceManager.GetString("UseCompatibleTypesMethodError", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to UseCompatibleTypes. - /// - internal static string UseCompatibleTypesName { - get { - return ResourceManager.GetString("UseCompatibleTypesName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to The type accelerator '{0}' is not available by default in PowerShell version '{1}' on platform '{2}'. - /// - internal static string UseCompatibleTypesTypeAcceleratorError { - get { - return ResourceManager.GetString("UseCompatibleTypesTypeAcceleratorError", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to The type '{0}' is not available by default in PowerShell version '{1}' on platform '{2}'. - /// - internal static string UseCompatibleTypesTypeError { - get { - return ResourceManager.GetString("UseCompatibleTypesTypeError", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Use consistent indentation. - /// - internal static string UseConsistentIndentationCommonName { - get { - return ResourceManager.GetString("UseConsistentIndentationCommonName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Each statement block should have a consistent indenation.. - /// - internal static string UseConsistentIndentationDescription { - get { - return ResourceManager.GetString("UseConsistentIndentationDescription", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Indentation not consistent. - /// - internal static string UseConsistentIndentationError { - get { - return ResourceManager.GetString("UseConsistentIndentationError", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to UseConsistentIndentation. - /// - internal static string UseConsistentIndentationName { - get { - return ResourceManager.GetString("UseConsistentIndentationName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Use whitespaces. - /// - internal static string UseConsistentWhitespaceCommonName { - get { - return ResourceManager.GetString("UseConsistentWhitespaceCommonName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Check for whitespace between keyword and open paren/curly, around assigment operator ('='), around arithmetic operators and after separators (',' and ';'). - /// - internal static string UseConsistentWhitespaceDescription { - get { - return ResourceManager.GetString("UseConsistentWhitespaceDescription", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Use space after open brace.. - /// - internal static string UseConsistentWhitespaceErrorAfterOpeningBrace { - get { - return ResourceManager.GetString("UseConsistentWhitespaceErrorAfterOpeningBrace", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Use space before closing brace.. - /// - internal static string UseConsistentWhitespaceErrorBeforeClosingInnerBrace { - get { - return ResourceManager.GetString("UseConsistentWhitespaceErrorBeforeClosingInnerBrace", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Use space before open brace.. - /// - internal static string UseConsistentWhitespaceErrorBeforeOpeningBrace { - get { - return ResourceManager.GetString("UseConsistentWhitespaceErrorBeforeOpeningBrace", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Use space before open parenthesis.. - /// - internal static string UseConsistentWhitespaceErrorBeforeParen { - get { - return ResourceManager.GetString("UseConsistentWhitespaceErrorBeforeParen", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Use space before and after binary and assignment operators.. - /// - internal static string UseConsistentWhitespaceErrorOperator { - get { - return ResourceManager.GetString("UseConsistentWhitespaceErrorOperator", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Use space after a comma.. - /// - internal static string UseConsistentWhitespaceErrorSeparatorComma { - get { - return ResourceManager.GetString("UseConsistentWhitespaceErrorSeparatorComma", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Use space after a semicolon.. - /// - internal static string UseConsistentWhitespaceErrorSeparatorSemi { - get { - return ResourceManager.GetString("UseConsistentWhitespaceErrorSeparatorSemi", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Use space after pipe.. - /// - internal static string UseConsistentWhitespaceErrorSpaceAfterPipe { - get { - return ResourceManager.GetString("UseConsistentWhitespaceErrorSpaceAfterPipe", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Use space before pipe.. - /// - internal static string UseConsistentWhitespaceErrorSpaceBeforePipe { - get { - return ResourceManager.GetString("UseConsistentWhitespaceErrorSpaceBeforePipe", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Use only 1 whitespace between parameter names or values.. - /// - internal static string UseConsistentWhitespaceErrorSpaceBetweenParameter { - get { - return ResourceManager.GetString("UseConsistentWhitespaceErrorSpaceBetweenParameter", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to UseConsistentWhitespace. - /// - internal static string UseConsistentWhitespaceName { - get { - return ResourceManager.GetString("UseConsistentWhitespaceName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Use exact casing of cmdlet/function/parameter name.. - /// - internal static string UseCorrectCasingCommonName { - get { - return ResourceManager.GetString("UseCorrectCasingCommonName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to For better readability and consistency, use the exact casing of the cmdlet/function/parameter.. - /// - internal static string UseCorrectCasingDescription { - get { - return ResourceManager.GetString("UseCorrectCasingDescription", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Function/Cmdlet '{0}' does not match its exact casing '{1}'.. - /// - internal static string UseCorrectCasingError { - get { - return ResourceManager.GetString("UseCorrectCasingError", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to UseCorrectCasing. - /// - internal static string UseCorrectCasingName { - get { - return ResourceManager.GetString("UseCorrectCasingName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Parameter '{0}' of function/cmdlet '{1}' does not match its exact casing '{2}'.. - /// - internal static string UseCorrectCasingParameterError { - get { - return ResourceManager.GetString("UseCorrectCasingParameterError", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Extra Variables. - /// - internal static string UseDeclaredVarsMoreThanAssignmentsCommonName { - get { - return ResourceManager.GetString("UseDeclaredVarsMoreThanAssignmentsCommonName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Ensure declared variables are used elsewhere in the script and not just during assignment.. - /// - internal static string UseDeclaredVarsMoreThanAssignmentsDescription { - get { - return ResourceManager.GetString("UseDeclaredVarsMoreThanAssignmentsDescription", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to The variable '{0}' is assigned but never used.. - /// - internal static string UseDeclaredVarsMoreThanAssignmentsError { - get { - return ResourceManager.GetString("UseDeclaredVarsMoreThanAssignmentsError", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to UseDeclaredVarsMoreThanAssignments. - /// - internal static string UseDeclaredVarsMoreThanAssignmentsName { - get { - return ResourceManager.GetString("UseDeclaredVarsMoreThanAssignmentsName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Use identical mandatory parameters for DSC Get/Test/Set TargetResource functions. - /// - internal static string UseIdenticalMandatoryParametersDSCCommonName { - get { - return ResourceManager.GetString("UseIdenticalMandatoryParametersDSCCommonName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to The Get/Test/Set TargetResource functions of DSC resource must have the same mandatory parameters.. - /// - internal static string UseIdenticalMandatoryParametersDSCDescription { - get { - return ResourceManager.GetString("UseIdenticalMandatoryParametersDSCDescription", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to The '{0}' parameter '{1}' is not present in '{2}' DSC resource function(s).. - /// - internal static string UseIdenticalMandatoryParametersDSCError { - get { - return ResourceManager.GetString("UseIdenticalMandatoryParametersDSCError", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to UseIdenticalMandatoryParametersForDSC. - /// - internal static string UseIdenticalMandatoryParametersDSCName { - get { - return ResourceManager.GetString("UseIdenticalMandatoryParametersDSCName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Use Identical Parameters For DSC Test and Set Functions. - /// - internal static string UseIdenticalParametersDSCCommonName { - get { - return ResourceManager.GetString("UseIdenticalParametersDSCCommonName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to The Test and Set-TargetResource functions of DSC Resource must have the same parameters.. - /// - internal static string UseIdenticalParametersDSCDescription { - get { - return ResourceManager.GetString("UseIdenticalParametersDSCDescription", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to The Test and Set-TargetResource functions of DSC Resource must have the same parameters.. - /// - internal static string UseIdenticalParametersDSCError { - get { - return ResourceManager.GetString("UseIdenticalParametersDSCError", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to UseIdenticalParametersForDSC. - /// - internal static string UseIdenticalParametersDSCName { - get { - return ResourceManager.GetString("UseIdenticalParametersDSCName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Create hashtables with literal initializers. - /// - internal static string UseLiteralInitilializerForHashtableCommonName { - get { - return ResourceManager.GetString("UseLiteralInitilializerForHashtableCommonName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Use literal initializer, @{{}}, for creating a hashtable as they are case-insensitive by default. - /// - internal static string UseLiteralInitilializerForHashtableDescription { - get { - return ResourceManager.GetString("UseLiteralInitilializerForHashtableDescription", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Create hashtables with literal initliazers. - /// - internal static string UseLiteralInitilializerForHashtableError { - get { - return ResourceManager.GetString("UseLiteralInitilializerForHashtableError", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to UseLiteralInitializerForHashtable. - /// - internal static string UseLiteralInitilializerForHashtableName { - get { - return ResourceManager.GetString("UseLiteralInitilializerForHashtableName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Use OutputType Correctly. - /// - internal static string UseOutputTypeCorrectlyCommonName { - get { - return ResourceManager.GetString("UseOutputTypeCorrectlyCommonName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to The return types of a cmdlet should be declared using the OutputType attribute.. - /// - internal static string UseOutputTypeCorrectlyDescription { - get { - return ResourceManager.GetString("UseOutputTypeCorrectlyDescription", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to The cmdlet '{0}' returns an object of type '{1}' but this type is not declared in the OutputType attribute.. - /// - internal static string UseOutputTypeCorrectlyError { - get { - return ResourceManager.GetString("UseOutputTypeCorrectlyError", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to UseOutputTypeCorrectly. - /// - internal static string UseOutputTypeCorrectlyName { - get { - return ResourceManager.GetString("UseOutputTypeCorrectlyName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Use process block for command that accepts input from pipeline.. - /// - internal static string UseProcessBlockForPipelineCommandCommonName { - get { - return ResourceManager.GetString("UseProcessBlockForPipelineCommandCommonName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to If a command parameter takes its value from the pipeline, the command must use a process block to bind the input objects from the pipeline to that parameter.. - /// - internal static string UseProcessBlockForPipelineCommandDescription { - get { - return ResourceManager.GetString("UseProcessBlockForPipelineCommandDescription", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Command accepts pipeline input but has not defined a process block.. - /// - internal static string UseProcessBlockForPipelineCommandError { - get { - return ResourceManager.GetString("UseProcessBlockForPipelineCommandError", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to UseProcessBlockForPipelineCommand. - /// - internal static string UseProcessBlockForPipelineCommandName { - get { - return ResourceManager.GetString("UseProcessBlockForPipelineCommandName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Use PSCredential type.. - /// - internal static string UsePSCredentialTypeCommonName { - get { - return ResourceManager.GetString("UsePSCredentialTypeCommonName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to For PowerShell 4.0 and earlier, a parameter named Credential with type PSCredential must have a credential transformation attribute defined after the PSCredential type attribute. . - /// - internal static string UsePSCredentialTypeDescription { - get { - return ResourceManager.GetString("UsePSCredentialTypeDescription", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to The Credential parameter in '{0}' must be of type PSCredential. For PowerShell 4.0 and earlier, please define a credential transformation attribute, e.g. [System.Management.Automation.Credential()], after the PSCredential type attribute.. - /// - internal static string UsePSCredentialTypeError { - get { - return ResourceManager.GetString("UsePSCredentialTypeError", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to The Credential parameter found in the script block must be of type PSCredential. For PowerShell 4.0 and earlier please define a credential transformation attribute, e.g. [System.Management.Automation.Credential()], after the PSCredential type attribute. . - /// - internal static string UsePSCredentialTypeErrorSB { - get { - return ResourceManager.GetString("UsePSCredentialTypeErrorSB", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to UsePSCredentialType. - /// - internal static string UsePSCredentialTypeName { - get { - return ResourceManager.GetString("UsePSCredentialTypeName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Use ShouldProcess For State Changing Functions. - /// - internal static string UseShouldProcessForStateChangingFunctionsCommonName { - get { - return ResourceManager.GetString("UseShouldProcessForStateChangingFunctionsCommonName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Functions that have verbs like New, Start, Stop, Set, Reset, Restart that change system state should support 'ShouldProcess'.. - /// - internal static string UseShouldProcessForStateChangingFunctionsDescrption { - get { - return ResourceManager.GetString("UseShouldProcessForStateChangingFunctionsDescrption", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Function '{0}' has verb that could change system state. Therefore, the function has to support 'ShouldProcess'.. - /// - internal static string UseShouldProcessForStateChangingFunctionsError { - get { - return ResourceManager.GetString("UseShouldProcessForStateChangingFunctionsError", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to UseShouldProcessForStateChangingFunctions. - /// - internal static string UseShouldProcessForStateChangingFunctionsName { - get { - return ResourceManager.GetString("UseShouldProcessForStateChangingFunctionsName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Cmdlet Singular Noun. - /// - internal static string UseSingularNounsCommonName { - get { - return ResourceManager.GetString("UseSingularNounsCommonName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Cmdlet should use singular instead of plural nouns.. - /// - internal static string UseSingularNounsDescription { - get { - return ResourceManager.GetString("UseSingularNounsDescription", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to The cmdlet '{0}' uses a plural noun. A singular noun should be used instead.. - /// - internal static string UseSingularNounsError { - get { - return ResourceManager.GetString("UseSingularNounsError", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to UseSingularNouns. - /// - internal static string UseSingularNounsName { - get { - return ResourceManager.GetString("UseSingularNounsName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Missing '{0}' function. DSC Class must implement Get, Set and Test functions.. - /// - internal static string UseStandardDSCFunctionsInClassError { - get { - return ResourceManager.GetString("UseStandardDSCFunctionsInClassError", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Use Standard Get/Set/Test TargetResource functions in DSC Resource . - /// - internal static string UseStandardDSCFunctionsInResourceCommonName { - get { - return ResourceManager.GetString("UseStandardDSCFunctionsInResourceCommonName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to DSC Resource must implement Get, Set and Test-TargetResource functions. DSC Class must implement Get, Set and Test functions.. - /// - internal static string UseStandardDSCFunctionsInResourceDescription { - get { - return ResourceManager.GetString("UseStandardDSCFunctionsInResourceDescription", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Missing '{0}' function. DSC Resource must implement Get, Set and Test-TargetResource functions.. - /// - internal static string UseStandardDSCFunctionsInResourceError { - get { - return ResourceManager.GetString("UseStandardDSCFunctionsInResourceError", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to StandardDSCFunctionsInResource. - /// - internal static string UseStandardDSCFunctionsInResourceName { - get { - return ResourceManager.GetString("UseStandardDSCFunctionsInResourceName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Use SupportsShouldProcess. - /// - internal static string UseSupportsShouldProcessCommonName { - get { - return ResourceManager.GetString("UseSupportsShouldProcessCommonName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Commands typically provide Confirm and Whatif parameters to give more control on its execution in an interactive environment. In PowerShell, a command can use a SupportsShouldProcess attribute to provide this capability. Hence, manual addition of these parameters to a command is discouraged. If a commands need Confirm and Whatif parameters, then it should support ShouldProcess.. - /// - internal static string UseSupportsShouldProcessDescription { - get { - return ResourceManager.GetString("UseSupportsShouldProcessDescription", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Whatif and/or Confirm manually defined in function {0}. Instead, please use SupportsShouldProcess attribute.. - /// - internal static string UseSupportsShouldProcessError { - get { - return ResourceManager.GetString("UseSupportsShouldProcessError", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to UseSupportsShouldProcess. - /// - internal static string UseSupportsShouldProcessName { - get { - return ResourceManager.GetString("UseSupportsShouldProcessName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Use the *ToExport module manifest fields.. - /// - internal static string UseToExportFieldsInManifestCommonName { - get { - return ResourceManager.GetString("UseToExportFieldsInManifestCommonName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Replace {0} with {1}. - /// - internal static string UseToExportFieldsInManifestCorrectionDescription { - get { - return ResourceManager.GetString("UseToExportFieldsInManifestCorrectionDescription", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to In a module manifest, AliasesToExport, CmdletsToExport, FunctionsToExport and VariablesToExport fields should not use wildcards or $null in their entries. During module auto-discovery, if any of these entries are missing or $null or wildcard, PowerShell does some potentially expensive work to analyze the rest of the module.. - /// - internal static string UseToExportFieldsInManifestDescription { - get { - return ResourceManager.GetString("UseToExportFieldsInManifestDescription", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Do not use wildcard or $null in this field. Explicitly specify a list for {0}. . - /// - internal static string UseToExportFieldsInManifestError { - get { - return ResourceManager.GetString("UseToExportFieldsInManifestError", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to UseToExportFieldsInManifest. - /// - internal static string UseToExportFieldsInManifestName { - get { - return ResourceManager.GetString("UseToExportFieldsInManifestName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Use Type At Variable Assignment. - /// - internal static string UseTypeAtVariableAssignmentCommonName { - get { - return ResourceManager.GetString("UseTypeAtVariableAssignmentCommonName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Types should be specified at variable assignments to maintain readability and maintainability of script.. - /// - internal static string UseTypeAtVariableAssignmentDescription { - get { - return ResourceManager.GetString("UseTypeAtVariableAssignmentDescription", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Specify type at the assignment of variable '{0}'. - /// - internal static string UseTypeAtVariableAssignmentError { - get { - return ResourceManager.GetString("UseTypeAtVariableAssignmentError", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to UseTypeAtVariableAssignment. - /// - internal static string UseTypeAtVariableAssignmentName { - get { - return ResourceManager.GetString("UseTypeAtVariableAssignmentName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Use 'Using:' scope modifier in RunSpace ScriptBlocks. - /// - internal static string UseUsingScopeModifierInNewRunspacesCommonName { - get { - return ResourceManager.GetString("UseUsingScopeModifierInNewRunspacesCommonName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Replace {0} with {1}. - /// - internal static string UseUsingScopeModifierInNewRunspacesCorrectionDescription { - get { - return ResourceManager.GetString("UseUsingScopeModifierInNewRunspacesCorrectionDescription", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to If a ScriptBlock is intended to be run as a new RunSpace, variables inside it should use 'Using:' scope modifier, or be initialized within the ScriptBlock.. - /// - internal static string UseUsingScopeModifierInNewRunspacesDescription { - get { - return ResourceManager.GetString("UseUsingScopeModifierInNewRunspacesDescription", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to The variable '{0}' is not declared within this ScriptBlock, and is missing the 'Using:' scope modifier.. - /// - internal static string UseUsingScopeModifierInNewRunspacesError { - get { - return ResourceManager.GetString("UseUsingScopeModifierInNewRunspacesError", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to UseUsingScopeModifierInNewRunspaces. - /// - internal static string UseUsingScopeModifierInNewRunspacesName { - get { - return ResourceManager.GetString("UseUsingScopeModifierInNewRunspacesName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Use UTF8 Encoding For Help File. - /// - internal static string UseUTF8EncodingForHelpFileCommonName { - get { - return ResourceManager.GetString("UseUTF8EncodingForHelpFileCommonName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to PowerShell help file needs to use UTF8 Encoding.. - /// - internal static string UseUTF8EncodingForHelpFileDescription { - get { - return ResourceManager.GetString("UseUTF8EncodingForHelpFileDescription", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to File {0} has to use UTF8 instead of {1} encoding because it is a powershell help file.. - /// - internal static string UseUTF8EncodingForHelpFileError { - get { - return ResourceManager.GetString("UseUTF8EncodingForHelpFileError", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to UseUTF8EncodingForHelpFile. - /// - internal static string UseUTF8EncodingForHelpFileName { - get { - return ResourceManager.GetString("UseUTF8EncodingForHelpFileName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Use verbose message in DSC resource. - /// - internal static string UseVerboseMessageInDSCResourceCommonName { - get { - return ResourceManager.GetString("UseVerboseMessageInDSCResourceCommonName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to It is a best practice to emit informative, verbose messages in DSC resource functions. This helps in debugging issues when a DSC configuration is executed.. - /// - internal static string UseVerboseMessageInDSCResourceDescription { - get { - return ResourceManager.GetString("UseVerboseMessageInDSCResourceDescription", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to There is no call to Write-Verbose in DSC function '{0}'. If you are using Write-Verbose in a helper function, suppress this rule application.. - /// - internal static string UseVerboseMessageInDSCResourceErrorFunction { - get { - return ResourceManager.GetString("UseVerboseMessageInDSCResourceErrorFunction", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to UseVerboseMessageInDSCResource. - /// - internal static string UseVerboseMessageInDSCResourceName { - get { - return ResourceManager.GetString("UseVerboseMessageInDSCResourceName", resourceCulture); - } - } - } -} From 45edb8d9e06e6c6756e070513645ac22f813c682 Mon Sep 17 00:00:00 2001 From: Frode Flaten <3436158+fflaten@users.noreply.github.com> Date: Tue, 16 Jan 2024 23:30:20 +0100 Subject: [PATCH 28/42] Allow suppression of PSUseSingularNouns for specific function (#1903) * Add ruleId to PSUseSingularNouns * Update UseSingularNouns.md * Update UseSingularNouns.md --------- Co-authored-by: Christoph Bergmeister --- Rules/UseSingularNouns.cs | 1 + Tests/Rules/UseSingularNounsReservedVerbs.tests.ps1 | 12 ++++++++++++ docs/Rules/UseSingularNouns.md | 9 +++++++++ 3 files changed, 22 insertions(+) diff --git a/Rules/UseSingularNouns.cs b/Rules/UseSingularNouns.cs index de9264d35..218537459 100644 --- a/Rules/UseSingularNouns.cs +++ b/Rules/UseSingularNouns.cs @@ -88,6 +88,7 @@ public IEnumerable AnalyzeScript(Ast ast, string fileName) GetName(), DiagnosticSeverity.Warning, fileName, + funcAst.Name, suggestedCorrections: new CorrectionExtent[] { GetCorrection(pluralizer, extent, funcAst.Name, noun) }); } } diff --git a/Tests/Rules/UseSingularNounsReservedVerbs.tests.ps1 b/Tests/Rules/UseSingularNounsReservedVerbs.tests.ps1 index 534e6df4d..db1af36ce 100644 --- a/Tests/Rules/UseSingularNounsReservedVerbs.tests.ps1 +++ b/Tests/Rules/UseSingularNounsReservedVerbs.tests.ps1 @@ -86,6 +86,18 @@ Write-Output "Adding some data" $diagnostics.SuggestedCorrections.Text | Should -BeExactly $Correction } } + Context 'Suppression' { + It 'Can be suppressed by RuleSuppressionId' { + $scriptDef = @" +function Get-Elements { + [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('$nounViolationName', 'Get-Elements')] + param() +} +"@ + $warnings = @(Invoke-ScriptAnalyzer -ScriptDefinition $scriptDef) + $warnings.Count | Should -Be 0 + } + } } Describe "UseApprovedVerbs" { diff --git a/docs/Rules/UseSingularNouns.md b/docs/Rules/UseSingularNouns.md index 4e7576bf0..caf032e03 100644 --- a/docs/Rules/UseSingularNouns.md +++ b/docs/Rules/UseSingularNouns.md @@ -13,6 +13,15 @@ title: UseSingularNouns PowerShell team best practices state cmdlets should use singular nouns and not plurals. +Suppression allows to suppress just specific function names, for example + +``` +function Get-Elements { + [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseSingularNouns', 'Get-Elements')] + Param() +} +``` + ## How Change plurals to singular. From e22c65f0b0f4c2904e6f273b16098526ba6f4909 Mon Sep 17 00:00:00 2001 From: James Brundage Date: Tue, 16 Jan 2024 14:31:15 -0800 Subject: [PATCH 29/42] Adding ToString() methods to [CorrectionExtent] and [DiagnosticRecord] (#1946) * Adding DiagnosticRecord.ToString() (Fixes #1945) * Adding CorrectionExtent.ToString() (Fixes #1944) --------- Co-authored-by: James Brundage <@github.com> --- Engine/Generic/CorrectionExtent.cs | 8 ++++++++ Engine/Generic/DiagnosticRecord.cs | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/Engine/Generic/CorrectionExtent.cs b/Engine/Generic/CorrectionExtent.cs index caad49cdb..f92070844 100644 --- a/Engine/Generic/CorrectionExtent.cs +++ b/Engine/Generic/CorrectionExtent.cs @@ -104,5 +104,13 @@ public CorrectionExtent( { } + + /// + /// Outputs a CorrectionExtent as a string. + /// + /// Returns the text in a CorrectionExtent. + public override string ToString() { + return this.Text; + } } } diff --git a/Engine/Generic/DiagnosticRecord.cs b/Engine/Generic/DiagnosticRecord.cs index cd325ecf2..0673e1391 100644 --- a/Engine/Generic/DiagnosticRecord.cs +++ b/Engine/Generic/DiagnosticRecord.cs @@ -127,6 +127,14 @@ public DiagnosticRecord( RuleSuppressionID = ruleId; this.suggestedCorrections = suggestedCorrections; } + + /// + /// Outputs a DiagnosticRecord as a string. + /// + /// Returns the message in a DiagnosticRecord. + public override string ToString() { + return this.Message; + } } From 59190fe3ff4f26e8387243ec2928934a44543a96 Mon Sep 17 00:00:00 2001 From: Eli Arbel <496737+aelij@users.noreply.github.com> Date: Wed, 17 Jan 2024 00:31:45 +0200 Subject: [PATCH 30/42] Add PSNativeCommandUseErrorActionPreference preference variable (#1954) --- Engine/SpecialVars.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Engine/SpecialVars.cs b/Engine/SpecialVars.cs index 0b820c0d4..a8be18b92 100644 --- a/Engine/SpecialVars.cs +++ b/Engine/SpecialVars.cs @@ -92,6 +92,7 @@ static SpecialVars() internal const string ProgressPreference = "ProgressPreference"; internal const string InformationPreference = "InformationPreference"; internal const string ErrorView = "ErrorView"; + internal const string PSNativeCommandUseErrorActionPreference = "PSNativeCommandUseErrorActionPreference"; internal static readonly string[] PreferenceVariables = new string[] { @@ -103,7 +104,8 @@ static SpecialVars() ConfirmPreference, ProgressPreference, InformationPreference, - ErrorView + ErrorView, + PSNativeCommandUseErrorActionPreference, }; internal static readonly Type[] PreferenceVariableTypes = new Type[] @@ -117,6 +119,7 @@ static SpecialVars() /* ProgressPreference */ typeof(Enum), /* InformationPreference */ typeof(ActionPreference), /* ErrorView */ typeof(Enum), //ErrorView type not available on PS3 + /* PSNativeCommandUseErrorActionPreference */ typeof(bool), }; internal enum AutomaticVariable From 9314e69a24f1f98aa976ba0ac3a96784ed0956e9 Mon Sep 17 00:00:00 2001 From: Hubert Bukowski Date: Tue, 16 Jan 2024 23:32:10 +0100 Subject: [PATCH 31/42] Prevent NullReferenceException for null analysis type. (#1949) Many analysis objects here have null Type field value. This leads to premature exiting the method. --- Engine/VariableAnalysisBase.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Engine/VariableAnalysisBase.cs b/Engine/VariableAnalysisBase.cs index b55119d7a..77c421f3c 100644 --- a/Engine/VariableAnalysisBase.cs +++ b/Engine/VariableAnalysisBase.cs @@ -995,7 +995,7 @@ internal static Tuple, Dictionary String.Equals(item.Name, analysis.Type.FullName, StringComparison.OrdinalIgnoreCase)); + TypeDefinitionAst psClass = Classes.FirstOrDefault(item => String.Equals(item.Name, analysis.Type?.FullName, StringComparison.OrdinalIgnoreCase)); Type possibleType = AssignmentTarget.GetTypeFromMemberExpressionAst(memAst, analysis, psClass); #endif From da646722916d8a650a5e908b1b0001d8485c12fb Mon Sep 17 00:00:00 2001 From: Michael Van Leeuwen Date: Thu, 18 Jan 2024 10:18:07 -0800 Subject: [PATCH 32/42] Convert UseSingularNouns to configurable rule and add Windows to allowlist (#1858) * Add Windows to the UseSingularNouns allow list * Add test case for Windows verb * Refactor UseSingularNouns to configurable rule and add tests * Update UseSingularNouns docs with configuration information * Remove extra test code --------- Co-authored-by: Christoph Bergmeister --- Rules/UseSingularNouns.cs | 26 +++++++++-------- .../UseSingularNounsReservedVerbs.tests.ps1 | 29 ++++++++++++++++++- docs/Rules/README.md | 2 +- docs/Rules/UseSingularNouns.md | 21 ++++++++++++++ 4 files changed, 64 insertions(+), 14 deletions(-) diff --git a/Rules/UseSingularNouns.cs b/Rules/UseSingularNouns.cs index 218537459..21a6afa90 100644 --- a/Rules/UseSingularNouns.cs +++ b/Rules/UseSingularNouns.cs @@ -32,13 +32,15 @@ namespace Microsoft.Windows.PowerShell.ScriptAnalyzer.BuiltinRules #if !CORECLR [Export(typeof(IScriptRule))] #endif - public class CmdletSingularNoun : IScriptRule + public class CmdletSingularNoun : ConfigurableRule { + [ConfigurableRuleProperty(defaultValue: new string[] { "Data", "Windows" })] + public string[] NounAllowList { get; set; } - private readonly string[] nounAllowList = + public CmdletSingularNoun() { - "Data" - }; + Enable = true; + } /// /// Checks that all defined cmdlet use singular noun @@ -46,7 +48,7 @@ public class CmdletSingularNoun : IScriptRule /// /// /// - public IEnumerable AnalyzeScript(Ast ast, string fileName) + public override IEnumerable AnalyzeScript(Ast ast, string fileName) { if (ast == null) throw new ArgumentNullException(Strings.NullCommandInfoError); @@ -70,7 +72,7 @@ public IEnumerable AnalyzeScript(Ast ast, string fileName) if (pluralizer.CanOnlyBePlural(noun)) { - if (nounAllowList.Contains(noun, StringComparer.OrdinalIgnoreCase)) + if (NounAllowList.Contains(noun, StringComparer.OrdinalIgnoreCase)) { continue; } @@ -99,7 +101,7 @@ public IEnumerable AnalyzeScript(Ast ast, string fileName) /// GetName: Retrieves the name of this rule. /// /// The name of this rule - public string GetName() + public override string GetName() { return string.Format(CultureInfo.CurrentCulture, Strings.NameSpaceFormat, GetSourceName(), Strings.UseSingularNounsName); } @@ -108,7 +110,7 @@ public string GetName() /// GetName: Retrieves the common name of this rule. /// /// The common name of this rule - public string GetCommonName() + public override string GetCommonName() { return string.Format(CultureInfo.CurrentCulture, Strings.UseSingularNounsCommonName); } @@ -117,7 +119,7 @@ public string GetCommonName() /// GetDescription: Retrieves the description of this rule. /// /// The description of this rule - public string GetDescription() + public override string GetDescription() { return string.Format(CultureInfo.CurrentCulture, Strings.UseSingularNounsDescription); } @@ -125,7 +127,7 @@ public string GetDescription() /// /// GetSourceType: Retrieves the type of the rule: builtin, managed or module. /// - public SourceType GetSourceType() + public override SourceType GetSourceType() { return SourceType.Builtin; } @@ -134,7 +136,7 @@ public SourceType GetSourceType() /// GetSeverity: Retrieves the severity of the rule: error, warning of information. /// /// - public RuleSeverity GetSeverity() + public override RuleSeverity GetSeverity() { return RuleSeverity.Warning; } @@ -142,7 +144,7 @@ public RuleSeverity GetSeverity() /// /// GetSourceName: Retrieves the module/assembly name the rule is from. /// - public string GetSourceName() + public override string GetSourceName() { return string.Format(CultureInfo.CurrentCulture, Strings.SourceName); } diff --git a/Tests/Rules/UseSingularNounsReservedVerbs.tests.ps1 b/Tests/Rules/UseSingularNounsReservedVerbs.tests.ps1 index db1af36ce..6d4724236 100644 --- a/Tests/Rules/UseSingularNounsReservedVerbs.tests.ps1 +++ b/Tests/Rules/UseSingularNounsReservedVerbs.tests.ps1 @@ -32,7 +32,7 @@ Describe "UseSingularNouns" { Context "When function names have nouns from allowlist" { - It "ignores function name ending with Data" { + It "ignores function name ending with Data by default" { $nounViolationScript = @' Function Add-SomeData { @@ -44,6 +44,33 @@ Write-Output "Adding some data" -OutVariable violations $violations.Count | Should -Be 0 } + + It "ignores function name ending with Windows by default" { + $nounViolationScript = @' +Function Test-Windows +{ +Write-Output "Testing Microsoft Windows" +} +'@ + Invoke-ScriptAnalyzer -ScriptDefinition $nounViolationScript ` + -IncludeRule "PSUseSingularNouns" ` + -OutVariable violations + $violations.Count | Should -Be 0 + } + + It "ignores function names defined in settings" { + $nounViolationScript = @' +Function Get-Bananas +{ +Write-Output "Bananas" +} +'@ + Invoke-ScriptAnalyzer -ScriptDefinition $nounViolationScript -Settings @{ + IncludeRules = @("PSUseSingularNouns") + Rules = @{ PSUseSingularNouns = @{ NounAllowList = "Bananas" } } + } | Should -BeNullOrEmpty + } + } Context "When there are no violations" { diff --git a/docs/Rules/README.md b/docs/Rules/README.md index f5c8d8bd3..42c2003ad 100644 --- a/docs/Rules/README.md +++ b/docs/Rules/README.md @@ -75,7 +75,7 @@ The PSScriptAnalyzer contains the following rule definitions. | [UseProcessBlockForPipelineCommand](./UseProcessBlockForPipelineCommand.md) | Warning | Yes | | | [UsePSCredentialType](./UsePSCredentialType.md) | Warning | Yes | | | [UseShouldProcessForStateChangingFunctions](./UseShouldProcessForStateChangingFunctions.md) | Warning | Yes | | -| [UseSingularNouns](./UseSingularNouns.md) | Warning | Yes | | +| [UseSingularNouns](./UseSingularNouns.md) | Warning | Yes | Yes | | [UseSupportsShouldProcess](./UseSupportsShouldProcess.md) | Warning | Yes | | | [UseToExportFieldsInManifest](./UseToExportFieldsInManifest.md) | Warning | Yes | | | [UseUsingScopeModifierInNewRunspaces](./UseUsingScopeModifierInNewRunspaces.md) | Warning | Yes | | diff --git a/docs/Rules/UseSingularNouns.md b/docs/Rules/UseSingularNouns.md index caf032e03..387d48c2d 100644 --- a/docs/Rules/UseSingularNouns.md +++ b/docs/Rules/UseSingularNouns.md @@ -22,6 +22,27 @@ function Get-Elements { } ``` +## Configuration + +```powershell +Rules = @{ + UseSingularNouns = @{ + NounAllowList = 'Data', 'Windows', 'Foos' + Enable = $true + } +} +``` + +### Parameters + +#### `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 + +#### Enable: `bool` (Default value is `$true`) + +Enable or disable the rule during ScriptAnalyzer invocation. + ## How Change plurals to singular. From 2245064e0067a4a50310951fa8351b7b1819525b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 18 Jan 2024 10:44:22 -0800 Subject: [PATCH 33/42] Bump Newtonsoft.Json to 13.0.3 (#1866) * Bump Newtonsoft.Json from 12.0.3 to 13.0.2 Bumps [Newtonsoft.Json](https://github.com/JamesNK/Newtonsoft.Json) from 12.0.3 to 13.0.2. - [Release notes](https://github.com/JamesNK/Newtonsoft.Json/releases) - [Commits](https://github.com/JamesNK/Newtonsoft.Json/compare/12.0.3...13.0.2) --- updated-dependencies: - dependency-name: Newtonsoft.Json dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] * Apply suggestions from code review * Bump all version to 13.0.3 * Apply suggestions from code review --------- Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Christoph Bergmeister --- .../Microsoft.PowerShell.CrossCompatibility.csproj | 6 +++--- Rules/Rules.csproj | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/PSCompatibilityCollector/Microsoft.PowerShell.CrossCompatibility/Microsoft.PowerShell.CrossCompatibility.csproj b/PSCompatibilityCollector/Microsoft.PowerShell.CrossCompatibility/Microsoft.PowerShell.CrossCompatibility.csproj index eaa88be73..737af527f 100644 --- a/PSCompatibilityCollector/Microsoft.PowerShell.CrossCompatibility/Microsoft.PowerShell.CrossCompatibility.csproj +++ b/PSCompatibilityCollector/Microsoft.PowerShell.CrossCompatibility/Microsoft.PowerShell.CrossCompatibility.csproj @@ -11,15 +11,15 @@ - - + + - + diff --git a/Rules/Rules.csproj b/Rules/Rules.csproj index e3ab388c7..7a953d297 100644 --- a/Rules/Rules.csproj +++ b/Rules/Rules.csproj @@ -17,15 +17,15 @@ - - + + - + From cc2f9b7f17a44a68f30f76fe116a811718482161 Mon Sep 17 00:00:00 2001 From: Christoph Bergmeister Date: Thu, 18 Jan 2024 18:45:07 +0000 Subject: [PATCH 34/42] Use latest .NET 6.0 SDK patch version and update devcontainer to use .NET 6 as well (#1955) * Update global.json * Update README.md * Update Dockerfile * Update devcontainer.json * Update devcontainer.json * Update devcontainer.json * Update global.json --- .devcontainer/Dockerfile | 2 +- .devcontainer/devcontainer.json | 24 +++++++++++++----------- README.md | 3 +-- global.json | 2 +- 4 files changed, 16 insertions(+), 15 deletions(-) diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 06cc1380a..b731d046f 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -1,6 +1,6 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. -FROM mcr.microsoft.com/dotnet/core/sdk:3.1.419 +FROM mcr.microsoft.com/dotnet/sdk:6.0 RUN pwsh --command Install-Module platyPS,Pester -Force diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 0ee4c2049..d48d48c38 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,14 +1,16 @@ -// For format details, see https://aka.ms/vscode-remote/devcontainer.json or the definition README at -// https://github.com/microsoft/vscode-dev-containers/tree/master/containers/dotnetcore-3.0 +// For format details, see https://aka.ms/vscode-remote/devcontainer.json { - "name": "C# (.NET Core 3.1)", + "name": "C# (.NET 6.0)", "dockerFile": "Dockerfile", - "settings": { - "terminal.integrated.shell.linux": "/usr/bin/pwsh" - }, - "postCreateCommand": "dotnet restore", - "extensions": [ - "ms-dotnettools.csharp", - "ms-vscode.powershell-preview" - ] + "customizations": { + "vscode": { + "settings": { + "terminal.integrated.defaultProfile.linux": "pwsh" + }, + "extensions": [ + "ms-dotnettools.csharp", + "ms-vscode.powershell" + ] + } + } } diff --git a/README.md b/README.md index 0e82f34be..97c66848d 100644 --- a/README.md +++ b/README.md @@ -72,8 +72,7 @@ To install **PSScriptAnalyzer** from source code: ### Requirements -- [.NET 6.0.11 containing 6.0.403 SDK](https://dotnet.microsoft.com/en-us/download/dotnet/6.0) or - newer patch release +- [Latest .NET 6.0 SDK](https://dotnet.microsoft.com/en-us/download/dotnet/6.0) * If building for Windows PowerShell versions, then the .NET Framework 4.6.2 [targeting pack](https://dotnet.microsoft.com/en-us/download/dotnet-framework/net462) (also referred to as developer/targeting pack) need to be installed. This is only possible on Windows. * Optionally but recommended for development: [Visual Studio 2017/2019](https://www.visualstudio.com/downloads) - [Pester v5 PowerShell module, available on PowerShell Gallery](https://github.com/pester/Pester) diff --git a/global.json b/global.json index 6d86a5b04..1cec616b3 100644 --- a/global.json +++ b/global.json @@ -1,5 +1,5 @@ { "sdk": { - "version": "6.0.403" + "version": "6.0.418" } } From 1e79ca362d13adbeed95e6092b1b19cb7a38f32c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 18 Jan 2024 10:56:42 -0800 Subject: [PATCH 35/42] Bump Microsoft.Management.Infrastructure from 1.0.0 to 3.0.0 for PowerShell 7 only (#1947) * Bump Microsoft.Management.Infrastructure from 1.0.0 to 3.0.0 Bumps [Microsoft.Management.Infrastructure](https://github.com/PowerShell/MMI) from 1.0.0 to 3.0.0. - [Commits](https://github.com/PowerShell/MMI/commits) --- updated-dependencies: - dependency-name: Microsoft.Management.Infrastructure dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] * Update PSCompatibilityCollector/Microsoft.PowerShell.CrossCompatibility/Microsoft.PowerShell.CrossCompatibility.csproj --------- Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Christoph Bergmeister --- .../Microsoft.PowerShell.CrossCompatibility.csproj | 4 ++-- Rules/Rules.csproj | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/PSCompatibilityCollector/Microsoft.PowerShell.CrossCompatibility/Microsoft.PowerShell.CrossCompatibility.csproj b/PSCompatibilityCollector/Microsoft.PowerShell.CrossCompatibility/Microsoft.PowerShell.CrossCompatibility.csproj index 737af527f..20dc8d226 100644 --- a/PSCompatibilityCollector/Microsoft.PowerShell.CrossCompatibility/Microsoft.PowerShell.CrossCompatibility.csproj +++ b/PSCompatibilityCollector/Microsoft.PowerShell.CrossCompatibility/Microsoft.PowerShell.CrossCompatibility.csproj @@ -1,4 +1,4 @@ - + 1.21.0 @@ -14,7 +14,7 @@ - + diff --git a/Rules/Rules.csproj b/Rules/Rules.csproj index 7a953d297..9cd5a19bc 100644 --- a/Rules/Rules.csproj +++ b/Rules/Rules.csproj @@ -1,4 +1,4 @@ - + 1.21.0 @@ -20,7 +20,7 @@ - + From 5c32f5559d4096ae2dc0ffc0f9d59fcbfbd02ccb Mon Sep 17 00:00:00 2001 From: Christoph Bergmeister Date: Thu, 1 Feb 2024 17:35:40 +0000 Subject: [PATCH 36/42] Add common parameter ProgressAction (added in PS 7.4) to help test exclusion list --- Tests/Engine/ModuleHelp.Tests.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tests/Engine/ModuleHelp.Tests.ps1 b/Tests/Engine/ModuleHelp.Tests.ps1 index e2dbea8c4..85e93fe3e 100644 --- a/Tests/Engine/ModuleHelp.Tests.ps1 +++ b/Tests/Engine/ModuleHelp.Tests.ps1 @@ -175,7 +175,7 @@ Describe 'Cmdlet parameter help' { ) BEGIN { - $Common = 'Debug', 'ErrorAction', 'ErrorVariable', 'InformationAction', 'InformationVariable', 'OutBuffer', 'OutVariable', 'PipelineVariable', 'Verbose', 'WarningAction', 'WarningVariable' + $Common = 'Debug', 'ErrorAction', 'ErrorVariable', 'InformationAction', 'InformationVariable', 'OutBuffer', 'OutVariable', 'PipelineVariable', 'ProgressAction', 'Verbose', 'WarningAction', 'WarningVariable' $parameters = @() } PROCESS { From df3551eda2dce113e1eecf8a3ff03654c9bf24a4 Mon Sep 17 00:00:00 2001 From: Christoph Bergmeister Date: Tue, 13 Feb 2024 18:14:28 +0000 Subject: [PATCH 37/42] AvoidUsingPositionalParameter: Check if command has parameters to avoid having az in default CommandAllowList (#1850) * AvoidUsingPositionalParameter : Check if command has parameters * fix syntax * remove unneeded test * Update Rules/AvoidPositionalParameters.cs --- Engine/Helper.cs | 5 +++-- Rules/AvoidPositionalParameters.cs | 7 +++++-- Rules/UseCmdletCorrectly.cs | 2 +- docs/Rules/AvoidUsingPositionalParameters.md | 6 +++--- 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/Engine/Helper.cs b/Engine/Helper.cs index 528a3fe88..ded37b011 100644 --- a/Engine/Helper.cs +++ b/Engine/Helper.cs @@ -609,14 +609,15 @@ public bool HasSplattedVariable(CommandAst cmdAst) /// /// /// - public bool IsKnownCmdletFunctionOrExternalScript(CommandAst cmdAst) + public bool IsKnownCmdletFunctionOrExternalScript(CommandAst cmdAst, out CommandInfo commandInfo) { + commandInfo = null; if (cmdAst == null) { return false; } - var commandInfo = GetCommandInfo(cmdAst.GetCommandName()); + commandInfo = GetCommandInfo(cmdAst.GetCommandName()); if (commandInfo == null) { return false; diff --git a/Rules/AvoidPositionalParameters.cs b/Rules/AvoidPositionalParameters.cs index 3c6ec9626..2071baebd 100644 --- a/Rules/AvoidPositionalParameters.cs +++ b/Rules/AvoidPositionalParameters.cs @@ -6,6 +6,7 @@ using System.Management.Automation.Language; using Microsoft.Windows.PowerShell.ScriptAnalyzer.Generic; using System.Linq; +using System.Management.Automation; #if !CORECLR using System.ComponentModel.Composition; #endif @@ -21,7 +22,7 @@ namespace Microsoft.Windows.PowerShell.ScriptAnalyzer.BuiltinRules #endif public class AvoidPositionalParameters : ConfigurableRule { - [ConfigurableRuleProperty(defaultValue: new string[] { "az" })] + [ConfigurableRuleProperty(defaultValue: new string[] { })] public string[] CommandAllowList { get; set; } public AvoidPositionalParameters() @@ -61,9 +62,11 @@ public override IEnumerable AnalyzeScript(Ast ast, string file // MSDN: CommandAst.GetCommandName Method if (cmdAst.GetCommandName() == null) continue; - if ((Helper.Instance.IsKnownCmdletFunctionOrExternalScript(cmdAst) || declaredFunctionNames.Contains(cmdAst.GetCommandName())) && + if ((Helper.Instance.IsKnownCmdletFunctionOrExternalScript(cmdAst, out CommandInfo commandInfo) || declaredFunctionNames.Contains(cmdAst.GetCommandName())) && (Helper.Instance.PositionalParameterUsed(cmdAst, true))) { + if (commandInfo?.CommandType == CommandTypes.Application) continue; + PipelineAst parent = cmdAst.Parent as PipelineAst; string commandName = cmdAst.GetCommandName(); diff --git a/Rules/UseCmdletCorrectly.cs b/Rules/UseCmdletCorrectly.cs index 0239d95fc..ccec27e0b 100644 --- a/Rules/UseCmdletCorrectly.cs +++ b/Rules/UseCmdletCorrectly.cs @@ -100,7 +100,7 @@ private bool MandatoryParameterExists(CommandAst cmdAst) } // Positional parameters could be mandatory, so we assume all is well - if (Helper.Instance.PositionalParameterUsed(cmdAst) && Helper.Instance.IsKnownCmdletFunctionOrExternalScript(cmdAst)) + if (Helper.Instance.PositionalParameterUsed(cmdAst) && Helper.Instance.IsKnownCmdletFunctionOrExternalScript(cmdAst, out _)) { return true; } diff --git a/docs/Rules/AvoidUsingPositionalParameters.md b/docs/Rules/AvoidUsingPositionalParameters.md index 2d1dab690..5d1706a4b 100644 --- a/docs/Rules/AvoidUsingPositionalParameters.md +++ b/docs/Rules/AvoidUsingPositionalParameters.md @@ -25,7 +25,7 @@ supplied. A simple example where the risk of using positional parameters is negl ```powershell Rules = @{ PSAvoidUsingPositionalParameters = @{ - CommandAllowList = 'az', 'Join-Path' + CommandAllowList = 'Join-Path', 'MyCmdletOrScript' Enable = $true } } @@ -33,9 +33,9 @@ Rules = @{ ### Parameters -#### CommandAllowList: string[] (Default value is 'az') +#### CommandAllowList: string[] (Default value is @()') -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. +Commands or scripts to be excluded from this rule. #### Enable: bool (Default value is `$true`) From 9d57bad4903aa0e9a902b84bdc260b2f8c316684 Mon Sep 17 00:00:00 2001 From: Christoph Bergmeister Date: Tue, 13 Feb 2024 18:15:54 +0000 Subject: [PATCH 38/42] Bump version from 1.21.0 to 1.22.0 (#1965) --- Engine/Engine.csproj | 4 ++-- Engine/PSScriptAnalyzer.psd1 | 2 +- .../Microsoft.PowerShell.CrossCompatibility.csproj | 6 +++--- Rules/Rules.csproj | 4 ++-- docs/Cmdlets/Get-ScriptAnalyzerRule.md | 2 +- docs/Cmdlets/Invoke-Formatter.md | 2 +- docs/Cmdlets/Invoke-ScriptAnalyzer.md | 2 +- docs/Cmdlets/PSScriptAnalyzer.md | 4 ++-- docs/Rules/AlignAssignmentStatement.md | 2 +- docs/Rules/AvoidAssignmentToAutomaticVariable.md | 2 +- docs/Rules/AvoidDefaultValueForMandatoryParameter.md | 2 +- docs/Rules/AvoidDefaultValueSwitchParameter.md | 2 +- docs/Rules/AvoidExclaimOperator.md | 2 +- docs/Rules/AvoidGlobalAliases.md | 2 +- docs/Rules/AvoidGlobalFunctions.md | 2 +- docs/Rules/AvoidGlobalVars.md | 2 +- docs/Rules/AvoidInvokingEmptyMembers.md | 2 +- docs/Rules/AvoidLongLines.md | 2 +- docs/Rules/AvoidMultipleTypeAttributes.md | 2 +- docs/Rules/AvoidNullOrEmptyHelpMessageAttribute.md | 2 +- docs/Rules/AvoidOverwritingBuiltInCmdlets.md | 2 +- docs/Rules/AvoidSemicolonsAsLineTerminators.md | 2 +- docs/Rules/AvoidShouldContinueWithoutForce.md | 2 +- docs/Rules/AvoidTrailingWhitespace.md | 2 +- docs/Rules/AvoidUsingBrokenHashAlgorithms.md | 2 +- docs/Rules/AvoidUsingCmdletAliases.md | 2 +- docs/Rules/AvoidUsingComputerNameHardcoded.md | 2 +- docs/Rules/AvoidUsingConvertToSecureStringWithPlainText.md | 2 +- docs/Rules/AvoidUsingDeprecatedManifestFields.md | 2 +- docs/Rules/AvoidUsingDoubleQuotesForConstantString.md | 2 +- docs/Rules/AvoidUsingEmptyCatchBlock.md | 2 +- docs/Rules/AvoidUsingInvokeExpression.md | 2 +- docs/Rules/AvoidUsingPlainTextForPassword.md | 2 +- docs/Rules/AvoidUsingPositionalParameters.md | 2 +- docs/Rules/AvoidUsingUsernameAndPasswordParams.md | 2 +- docs/Rules/AvoidUsingWMICmdlet.md | 2 +- docs/Rules/AvoidUsingWriteHost.md | 2 +- docs/Rules/DSCDscExamplesPresent.md | 2 +- docs/Rules/DSCDscTestsPresent.md | 2 +- docs/Rules/DSCReturnCorrectTypesForDSCFunctions.md | 2 +- docs/Rules/DSCStandardDSCFunctionsInResource.md | 2 +- docs/Rules/DSCUseIdenticalMandatoryParametersForDSC.md | 2 +- docs/Rules/DSCUseIdenticalParametersForDSC.md | 2 +- docs/Rules/DSCUseVerboseMessageInDSCResource.md | 2 +- docs/Rules/MisleadingBacktick.md | 2 +- docs/Rules/MissingModuleManifestField.md | 2 +- docs/Rules/PlaceCloseBrace.md | 2 +- docs/Rules/PlaceOpenBrace.md | 2 +- docs/Rules/PossibleIncorrectComparisonWithNull.md | 2 +- docs/Rules/PossibleIncorrectUsageOfAssignmentOperator.md | 2 +- docs/Rules/PossibleIncorrectUsageOfRedirectionOperator.md | 2 +- docs/Rules/ProvideCommentHelp.md | 2 +- docs/Rules/README.md | 2 +- docs/Rules/ReservedCmdletChar.md | 2 +- docs/Rules/ReservedParams.md | 2 +- docs/Rules/ReviewUnusedParameter.md | 2 +- docs/Rules/ShouldProcess.md | 2 +- docs/Rules/UseApprovedVerbs.md | 2 +- docs/Rules/UseBOMForUnicodeEncodedFile.md | 2 +- docs/Rules/UseCmdletCorrectly.md | 2 +- docs/Rules/UseCompatibleCmdlets.md | 2 +- docs/Rules/UseCompatibleCommands.md | 2 +- docs/Rules/UseCompatibleSyntax.md | 2 +- docs/Rules/UseCompatibleTypes.md | 2 +- docs/Rules/UseConsistentIndentation.md | 2 +- docs/Rules/UseConsistentWhitespace.md | 2 +- docs/Rules/UseCorrectCasing.md | 2 +- docs/Rules/UseDeclaredVarsMoreThanAssignments.md | 2 +- docs/Rules/UseLiteralInitializerForHashtable.md | 2 +- docs/Rules/UseOutputTypeCorrectly.md | 2 +- docs/Rules/UsePSCredentialType.md | 2 +- docs/Rules/UseProcessBlockForPipelineCommand.md | 2 +- docs/Rules/UseShouldProcessForStateChangingFunctions.md | 2 +- docs/Rules/UseSingularNouns.md | 2 +- docs/Rules/UseSupportsShouldProcess.md | 2 +- docs/Rules/UseToExportFieldsInManifest.md | 2 +- docs/Rules/UseUTF8EncodingForHelpFile.md | 2 +- docs/Rules/UseUsingScopeModifierInNewRunspaces.md | 2 +- 78 files changed, 83 insertions(+), 83 deletions(-) diff --git a/Engine/Engine.csproj b/Engine/Engine.csproj index a22df13ee..860700b0b 100644 --- a/Engine/Engine.csproj +++ b/Engine/Engine.csproj @@ -1,10 +1,10 @@  - 1.21.0 + 1.22.0 net6;net462 Microsoft.Windows.PowerShell.ScriptAnalyzer - 1.21.0 + 1.22.0 Engine Microsoft.Windows.PowerShell.ScriptAnalyzer 9.0 diff --git a/Engine/PSScriptAnalyzer.psd1 b/Engine/PSScriptAnalyzer.psd1 index f3692b483..feae6fba4 100644 --- a/Engine/PSScriptAnalyzer.psd1 +++ b/Engine/PSScriptAnalyzer.psd1 @@ -11,7 +11,7 @@ Author = 'Microsoft Corporation' RootModule = 'PSScriptAnalyzer.psm1' # Version number of this module. -ModuleVersion = '1.21.0' +ModuleVersion = '1.22.0' # ID used to uniquely identify this module GUID = 'd6245802-193d-4068-a631-8863a4342a18' diff --git a/PSCompatibilityCollector/Microsoft.PowerShell.CrossCompatibility/Microsoft.PowerShell.CrossCompatibility.csproj b/PSCompatibilityCollector/Microsoft.PowerShell.CrossCompatibility/Microsoft.PowerShell.CrossCompatibility.csproj index 20dc8d226..20240cc7c 100644 --- a/PSCompatibilityCollector/Microsoft.PowerShell.CrossCompatibility/Microsoft.PowerShell.CrossCompatibility.csproj +++ b/PSCompatibilityCollector/Microsoft.PowerShell.CrossCompatibility/Microsoft.PowerShell.CrossCompatibility.csproj @@ -1,9 +1,9 @@ - + - 1.21.0 + 1.22.0 netstandard2.0;net462 - 1.21.0 + 1.22.0 diff --git a/Rules/Rules.csproj b/Rules/Rules.csproj index 9cd5a19bc..a9497824d 100644 --- a/Rules/Rules.csproj +++ b/Rules/Rules.csproj @@ -1,10 +1,10 @@ - 1.21.0 + 1.22.0 net6;net462 Microsoft.Windows.PowerShell.ScriptAnalyzer.BuiltinRules - 1.21.0 + 1.22.0 Rules Microsoft.Windows.PowerShell.ScriptAnalyzer true diff --git a/docs/Cmdlets/Get-ScriptAnalyzerRule.md b/docs/Cmdlets/Get-ScriptAnalyzerRule.md index 64bd7307f..90366c5b0 100644 --- a/docs/Cmdlets/Get-ScriptAnalyzerRule.md +++ b/docs/Cmdlets/Get-ScriptAnalyzerRule.md @@ -1,7 +1,7 @@ --- external help file: Microsoft.Windows.PowerShell.ScriptAnalyzer.dll-Help.xml Module Name: PSScriptAnalyzer -ms.custom: PSSA v1.21.0 +ms.custom: PSSA v1.22.0 ms.date: 10/07/2021 online version: https://learn.microsoft.com/powershell/module/psscriptanalyzer/get-scriptanalyzerrule?view=ps-modules&wt.mc_id=ps-gethelp schema: 2.0.0 diff --git a/docs/Cmdlets/Invoke-Formatter.md b/docs/Cmdlets/Invoke-Formatter.md index 91dc68add..88dd320ae 100644 --- a/docs/Cmdlets/Invoke-Formatter.md +++ b/docs/Cmdlets/Invoke-Formatter.md @@ -1,7 +1,7 @@ --- external help file: Microsoft.Windows.PowerShell.ScriptAnalyzer.dll-Help.xml Module Name: PSScriptAnalyzer -ms.custom: PSSA v1.21.0 +ms.custom: PSSA v1.22.0 ms.date: 10/07/2021 online version: https://learn.microsoft.com/powershell/module/psscriptanalyzer/invoke-formatter?view=ps-modules&wt.mc_id=ps-gethelp schema: 2.0.0 diff --git a/docs/Cmdlets/Invoke-ScriptAnalyzer.md b/docs/Cmdlets/Invoke-ScriptAnalyzer.md index 4605d1d89..9d0195c86 100644 --- a/docs/Cmdlets/Invoke-ScriptAnalyzer.md +++ b/docs/Cmdlets/Invoke-ScriptAnalyzer.md @@ -1,7 +1,7 @@ --- external help file: Microsoft.Windows.PowerShell.ScriptAnalyzer.dll-Help.xml Module Name: PSScriptAnalyzer -ms.custom: PSSA v1.21.0 +ms.custom: PSSA v1.22.0 ms.date: 10/07/2021 online version: https://learn.microsoft.com/powershell/module/psscriptanalyzer/invoke-scriptanalyzer?view=ps-modules&wt.mc_id=ps-gethelp schema: 2.0.0 diff --git a/docs/Cmdlets/PSScriptAnalyzer.md b/docs/Cmdlets/PSScriptAnalyzer.md index 1db78a547..b7267e8b5 100644 --- a/docs/Cmdlets/PSScriptAnalyzer.md +++ b/docs/Cmdlets/PSScriptAnalyzer.md @@ -1,10 +1,10 @@ --- Download Help Link: https://aka.ms/ps-modules-help -Help Version: 1.21.0 +Help Version: 1.22.0 Locale: en-US Module Guid: d6245802-193d-4068-a631-8863a4342a18 Module Name: PSScriptAnalyzer -ms.custom: PSSA v1.21.0 +ms.custom: PSSA v1.22.0 ms.date: 10/07/2021 --- diff --git a/docs/Rules/AlignAssignmentStatement.md b/docs/Rules/AlignAssignmentStatement.md index 21d5cfbc7..e41bff7a1 100644 --- a/docs/Rules/AlignAssignmentStatement.md +++ b/docs/Rules/AlignAssignmentStatement.md @@ -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 diff --git a/docs/Rules/AvoidAssignmentToAutomaticVariable.md b/docs/Rules/AvoidAssignmentToAutomaticVariable.md index 7a978e32a..572e9eb3a 100644 --- a/docs/Rules/AvoidAssignmentToAutomaticVariable.md +++ b/docs/Rules/AvoidAssignmentToAutomaticVariable.md @@ -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 diff --git a/docs/Rules/AvoidDefaultValueForMandatoryParameter.md b/docs/Rules/AvoidDefaultValueForMandatoryParameter.md index 71a82605f..ac5fdfc9c 100644 --- a/docs/Rules/AvoidDefaultValueForMandatoryParameter.md +++ b/docs/Rules/AvoidDefaultValueForMandatoryParameter.md @@ -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 diff --git a/docs/Rules/AvoidDefaultValueSwitchParameter.md b/docs/Rules/AvoidDefaultValueSwitchParameter.md index f08ac7732..74e76bdc6 100644 --- a/docs/Rules/AvoidDefaultValueSwitchParameter.md +++ b/docs/Rules/AvoidDefaultValueSwitchParameter.md @@ -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 diff --git a/docs/Rules/AvoidExclaimOperator.md b/docs/Rules/AvoidExclaimOperator.md index 5f858feca..5ef833fc0 100644 --- a/docs/Rules/AvoidExclaimOperator.md +++ b/docs/Rules/AvoidExclaimOperator.md @@ -1,6 +1,6 @@ --- description: Avoid exclaim operator -ms.custom: PSSA v1.21.0 +ms.custom: PSSA v1.22.0 ms.date: 06/14/2023 ms.topic: reference title: AvoidExclaimOperator diff --git a/docs/Rules/AvoidGlobalAliases.md b/docs/Rules/AvoidGlobalAliases.md index 9b9463196..36c581ca6 100644 --- a/docs/Rules/AvoidGlobalAliases.md +++ b/docs/Rules/AvoidGlobalAliases.md @@ -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 diff --git a/docs/Rules/AvoidGlobalFunctions.md b/docs/Rules/AvoidGlobalFunctions.md index cf4ee8fad..ef267ef8b 100644 --- a/docs/Rules/AvoidGlobalFunctions.md +++ b/docs/Rules/AvoidGlobalFunctions.md @@ -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 diff --git a/docs/Rules/AvoidGlobalVars.md b/docs/Rules/AvoidGlobalVars.md index 54da52443..0edcd4753 100644 --- a/docs/Rules/AvoidGlobalVars.md +++ b/docs/Rules/AvoidGlobalVars.md @@ -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 diff --git a/docs/Rules/AvoidInvokingEmptyMembers.md b/docs/Rules/AvoidInvokingEmptyMembers.md index 88665f1af..d512601ad 100644 --- a/docs/Rules/AvoidInvokingEmptyMembers.md +++ b/docs/Rules/AvoidInvokingEmptyMembers.md @@ -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 diff --git a/docs/Rules/AvoidLongLines.md b/docs/Rules/AvoidLongLines.md index eab82ad64..2dd94369a 100644 --- a/docs/Rules/AvoidLongLines.md +++ b/docs/Rules/AvoidLongLines.md @@ -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 diff --git a/docs/Rules/AvoidMultipleTypeAttributes.md b/docs/Rules/AvoidMultipleTypeAttributes.md index 5e5dbea69..f97d183c0 100644 --- a/docs/Rules/AvoidMultipleTypeAttributes.md +++ b/docs/Rules/AvoidMultipleTypeAttributes.md @@ -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 diff --git a/docs/Rules/AvoidNullOrEmptyHelpMessageAttribute.md b/docs/Rules/AvoidNullOrEmptyHelpMessageAttribute.md index 4ba4d8e9c..cee57e0e2 100644 --- a/docs/Rules/AvoidNullOrEmptyHelpMessageAttribute.md +++ b/docs/Rules/AvoidNullOrEmptyHelpMessageAttribute.md @@ -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 diff --git a/docs/Rules/AvoidOverwritingBuiltInCmdlets.md b/docs/Rules/AvoidOverwritingBuiltInCmdlets.md index 7ac93454e..cd7f9c3a6 100644 --- a/docs/Rules/AvoidOverwritingBuiltInCmdlets.md +++ b/docs/Rules/AvoidOverwritingBuiltInCmdlets.md @@ -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 diff --git a/docs/Rules/AvoidSemicolonsAsLineTerminators.md b/docs/Rules/AvoidSemicolonsAsLineTerminators.md index 0a496678c..f6d0d69b7 100644 --- a/docs/Rules/AvoidSemicolonsAsLineTerminators.md +++ b/docs/Rules/AvoidSemicolonsAsLineTerminators.md @@ -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 diff --git a/docs/Rules/AvoidShouldContinueWithoutForce.md b/docs/Rules/AvoidShouldContinueWithoutForce.md index 1ffd4ed7b..dba5e6857 100644 --- a/docs/Rules/AvoidShouldContinueWithoutForce.md +++ b/docs/Rules/AvoidShouldContinueWithoutForce.md @@ -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 diff --git a/docs/Rules/AvoidTrailingWhitespace.md b/docs/Rules/AvoidTrailingWhitespace.md index 2067cee75..9740d429c 100644 --- a/docs/Rules/AvoidTrailingWhitespace.md +++ b/docs/Rules/AvoidTrailingWhitespace.md @@ -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 diff --git a/docs/Rules/AvoidUsingBrokenHashAlgorithms.md b/docs/Rules/AvoidUsingBrokenHashAlgorithms.md index 52510a5e3..a8fc60dc1 100644 --- a/docs/Rules/AvoidUsingBrokenHashAlgorithms.md +++ b/docs/Rules/AvoidUsingBrokenHashAlgorithms.md @@ -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 diff --git a/docs/Rules/AvoidUsingCmdletAliases.md b/docs/Rules/AvoidUsingCmdletAliases.md index 87c13b33c..25adb3767 100644 --- a/docs/Rules/AvoidUsingCmdletAliases.md +++ b/docs/Rules/AvoidUsingCmdletAliases.md @@ -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 diff --git a/docs/Rules/AvoidUsingComputerNameHardcoded.md b/docs/Rules/AvoidUsingComputerNameHardcoded.md index 6ff30b54a..f15b69c06 100644 --- a/docs/Rules/AvoidUsingComputerNameHardcoded.md +++ b/docs/Rules/AvoidUsingComputerNameHardcoded.md @@ -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 diff --git a/docs/Rules/AvoidUsingConvertToSecureStringWithPlainText.md b/docs/Rules/AvoidUsingConvertToSecureStringWithPlainText.md index 3c651a400..fa6a0df0e 100644 --- a/docs/Rules/AvoidUsingConvertToSecureStringWithPlainText.md +++ b/docs/Rules/AvoidUsingConvertToSecureStringWithPlainText.md @@ -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 diff --git a/docs/Rules/AvoidUsingDeprecatedManifestFields.md b/docs/Rules/AvoidUsingDeprecatedManifestFields.md index bac27c065..32bc4d5b5 100644 --- a/docs/Rules/AvoidUsingDeprecatedManifestFields.md +++ b/docs/Rules/AvoidUsingDeprecatedManifestFields.md @@ -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 diff --git a/docs/Rules/AvoidUsingDoubleQuotesForConstantString.md b/docs/Rules/AvoidUsingDoubleQuotesForConstantString.md index ab732fc48..002a72aca 100644 --- a/docs/Rules/AvoidUsingDoubleQuotesForConstantString.md +++ b/docs/Rules/AvoidUsingDoubleQuotesForConstantString.md @@ -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 diff --git a/docs/Rules/AvoidUsingEmptyCatchBlock.md b/docs/Rules/AvoidUsingEmptyCatchBlock.md index 0d0749f06..8c944563f 100644 --- a/docs/Rules/AvoidUsingEmptyCatchBlock.md +++ b/docs/Rules/AvoidUsingEmptyCatchBlock.md @@ -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 diff --git a/docs/Rules/AvoidUsingInvokeExpression.md b/docs/Rules/AvoidUsingInvokeExpression.md index de35d16a4..570b51ac4 100644 --- a/docs/Rules/AvoidUsingInvokeExpression.md +++ b/docs/Rules/AvoidUsingInvokeExpression.md @@ -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 diff --git a/docs/Rules/AvoidUsingPlainTextForPassword.md b/docs/Rules/AvoidUsingPlainTextForPassword.md index 2d53fbbbe..3d2b9f6e0 100644 --- a/docs/Rules/AvoidUsingPlainTextForPassword.md +++ b/docs/Rules/AvoidUsingPlainTextForPassword.md @@ -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 diff --git a/docs/Rules/AvoidUsingPositionalParameters.md b/docs/Rules/AvoidUsingPositionalParameters.md index 5d1706a4b..0078ffd70 100644 --- a/docs/Rules/AvoidUsingPositionalParameters.md +++ b/docs/Rules/AvoidUsingPositionalParameters.md @@ -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 diff --git a/docs/Rules/AvoidUsingUsernameAndPasswordParams.md b/docs/Rules/AvoidUsingUsernameAndPasswordParams.md index f7c634ff2..b37bbfd42 100644 --- a/docs/Rules/AvoidUsingUsernameAndPasswordParams.md +++ b/docs/Rules/AvoidUsingUsernameAndPasswordParams.md @@ -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 diff --git a/docs/Rules/AvoidUsingWMICmdlet.md b/docs/Rules/AvoidUsingWMICmdlet.md index f1e633fe7..47888b361 100644 --- a/docs/Rules/AvoidUsingWMICmdlet.md +++ b/docs/Rules/AvoidUsingWMICmdlet.md @@ -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 diff --git a/docs/Rules/AvoidUsingWriteHost.md b/docs/Rules/AvoidUsingWriteHost.md index 31396af81..930202d4f 100644 --- a/docs/Rules/AvoidUsingWriteHost.md +++ b/docs/Rules/AvoidUsingWriteHost.md @@ -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 diff --git a/docs/Rules/DSCDscExamplesPresent.md b/docs/Rules/DSCDscExamplesPresent.md index a4ab2c792..aaf84d185 100644 --- a/docs/Rules/DSCDscExamplesPresent.md +++ b/docs/Rules/DSCDscExamplesPresent.md @@ -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 diff --git a/docs/Rules/DSCDscTestsPresent.md b/docs/Rules/DSCDscTestsPresent.md index f96ecbc77..22eca027f 100644 --- a/docs/Rules/DSCDscTestsPresent.md +++ b/docs/Rules/DSCDscTestsPresent.md @@ -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 diff --git a/docs/Rules/DSCReturnCorrectTypesForDSCFunctions.md b/docs/Rules/DSCReturnCorrectTypesForDSCFunctions.md index 2b0a4e058..882a492ca 100644 --- a/docs/Rules/DSCReturnCorrectTypesForDSCFunctions.md +++ b/docs/Rules/DSCReturnCorrectTypesForDSCFunctions.md @@ -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 diff --git a/docs/Rules/DSCStandardDSCFunctionsInResource.md b/docs/Rules/DSCStandardDSCFunctionsInResource.md index 9fbc2c672..6280e412c 100644 --- a/docs/Rules/DSCStandardDSCFunctionsInResource.md +++ b/docs/Rules/DSCStandardDSCFunctionsInResource.md @@ -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 diff --git a/docs/Rules/DSCUseIdenticalMandatoryParametersForDSC.md b/docs/Rules/DSCUseIdenticalMandatoryParametersForDSC.md index 65a612712..2c6f04709 100644 --- a/docs/Rules/DSCUseIdenticalMandatoryParametersForDSC.md +++ b/docs/Rules/DSCUseIdenticalMandatoryParametersForDSC.md @@ -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 diff --git a/docs/Rules/DSCUseIdenticalParametersForDSC.md b/docs/Rules/DSCUseIdenticalParametersForDSC.md index ea72db0ba..2497f41ad 100644 --- a/docs/Rules/DSCUseIdenticalParametersForDSC.md +++ b/docs/Rules/DSCUseIdenticalParametersForDSC.md @@ -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 diff --git a/docs/Rules/DSCUseVerboseMessageInDSCResource.md b/docs/Rules/DSCUseVerboseMessageInDSCResource.md index 0af52de06..49ef63ed4 100644 --- a/docs/Rules/DSCUseVerboseMessageInDSCResource.md +++ b/docs/Rules/DSCUseVerboseMessageInDSCResource.md @@ -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 diff --git a/docs/Rules/MisleadingBacktick.md b/docs/Rules/MisleadingBacktick.md index 02ec622dc..3194e706f 100644 --- a/docs/Rules/MisleadingBacktick.md +++ b/docs/Rules/MisleadingBacktick.md @@ -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 diff --git a/docs/Rules/MissingModuleManifestField.md b/docs/Rules/MissingModuleManifestField.md index a508e7191..efcf70af1 100644 --- a/docs/Rules/MissingModuleManifestField.md +++ b/docs/Rules/MissingModuleManifestField.md @@ -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 diff --git a/docs/Rules/PlaceCloseBrace.md b/docs/Rules/PlaceCloseBrace.md index 11eefc9d8..d181eebd9 100644 --- a/docs/Rules/PlaceCloseBrace.md +++ b/docs/Rules/PlaceCloseBrace.md @@ -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 diff --git a/docs/Rules/PlaceOpenBrace.md b/docs/Rules/PlaceOpenBrace.md index b3e48e0ce..bc3e4b5e2 100644 --- a/docs/Rules/PlaceOpenBrace.md +++ b/docs/Rules/PlaceOpenBrace.md @@ -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 diff --git a/docs/Rules/PossibleIncorrectComparisonWithNull.md b/docs/Rules/PossibleIncorrectComparisonWithNull.md index 1c9ea8d24..d3c62321b 100644 --- a/docs/Rules/PossibleIncorrectComparisonWithNull.md +++ b/docs/Rules/PossibleIncorrectComparisonWithNull.md @@ -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 diff --git a/docs/Rules/PossibleIncorrectUsageOfAssignmentOperator.md b/docs/Rules/PossibleIncorrectUsageOfAssignmentOperator.md index 7981512ff..8d046e302 100644 --- a/docs/Rules/PossibleIncorrectUsageOfAssignmentOperator.md +++ b/docs/Rules/PossibleIncorrectUsageOfAssignmentOperator.md @@ -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 diff --git a/docs/Rules/PossibleIncorrectUsageOfRedirectionOperator.md b/docs/Rules/PossibleIncorrectUsageOfRedirectionOperator.md index 759252cd3..cfd00c05b 100644 --- a/docs/Rules/PossibleIncorrectUsageOfRedirectionOperator.md +++ b/docs/Rules/PossibleIncorrectUsageOfRedirectionOperator.md @@ -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 diff --git a/docs/Rules/ProvideCommentHelp.md b/docs/Rules/ProvideCommentHelp.md index e8a45b152..c6e373f36 100644 --- a/docs/Rules/ProvideCommentHelp.md +++ b/docs/Rules/ProvideCommentHelp.md @@ -1,6 +1,6 @@ --- description: Basic Comment Help -ms.custom: PSSA v1.21.0 +ms.custom: PSSA v1.22.0 ms.date: 06/28/2023 ms.topic: reference title: ProvideCommentHelp diff --git a/docs/Rules/README.md b/docs/Rules/README.md index 42c2003ad..ccfaa71ea 100644 --- a/docs/Rules/README.md +++ b/docs/Rules/README.md @@ -1,6 +1,6 @@ --- description: List of PSScriptAnalyzer rules -ms.custom: PSSA v1.21.0 +ms.custom: PSSA v1.22.0 ms.date: 06/28/2023 ms.topic: reference title: List of PSScriptAnalyzer rules diff --git a/docs/Rules/ReservedCmdletChar.md b/docs/Rules/ReservedCmdletChar.md index 2fc57ca3e..e4195d42b 100644 --- a/docs/Rules/ReservedCmdletChar.md +++ b/docs/Rules/ReservedCmdletChar.md @@ -1,6 +1,6 @@ --- description: Reserved Cmdlet Chars -ms.custom: PSSA v1.21.0 +ms.custom: PSSA v1.22.0 ms.date: 06/28/2023 ms.topic: reference title: ReservedCmdletChar diff --git a/docs/Rules/ReservedParams.md b/docs/Rules/ReservedParams.md index 2a254683f..2d38c1af2 100644 --- a/docs/Rules/ReservedParams.md +++ b/docs/Rules/ReservedParams.md @@ -1,6 +1,6 @@ --- description: Reserved Parameters -ms.custom: PSSA v1.21.0 +ms.custom: PSSA v1.22.0 ms.date: 06/28/2023 ms.topic: reference title: ReservedParams diff --git a/docs/Rules/ReviewUnusedParameter.md b/docs/Rules/ReviewUnusedParameter.md index 2408c5535..c955760d6 100644 --- a/docs/Rules/ReviewUnusedParameter.md +++ b/docs/Rules/ReviewUnusedParameter.md @@ -1,6 +1,6 @@ --- description: ReviewUnusedParameter -ms.custom: PSSA v1.21.0 +ms.custom: PSSA v1.22.0 ms.date: 06/28/2023 ms.topic: reference title: ReviewUnusedParameter diff --git a/docs/Rules/ShouldProcess.md b/docs/Rules/ShouldProcess.md index d35ca8d40..6746c3621 100644 --- a/docs/Rules/ShouldProcess.md +++ b/docs/Rules/ShouldProcess.md @@ -1,6 +1,6 @@ --- description: Should Process -ms.custom: PSSA v1.21.0 +ms.custom: PSSA v1.22.0 ms.date: 06/28/2023 ms.topic: reference title: ShouldProcess diff --git a/docs/Rules/UseApprovedVerbs.md b/docs/Rules/UseApprovedVerbs.md index 2f51bfdb4..f4d685585 100644 --- a/docs/Rules/UseApprovedVerbs.md +++ b/docs/Rules/UseApprovedVerbs.md @@ -1,6 +1,6 @@ --- description: Cmdlet Verbs -ms.custom: PSSA v1.21.0 +ms.custom: PSSA v1.22.0 ms.date: 06/28/2023 ms.topic: reference title: UseApprovedVerbs diff --git a/docs/Rules/UseBOMForUnicodeEncodedFile.md b/docs/Rules/UseBOMForUnicodeEncodedFile.md index 118158773..2d174f99e 100644 --- a/docs/Rules/UseBOMForUnicodeEncodedFile.md +++ b/docs/Rules/UseBOMForUnicodeEncodedFile.md @@ -1,6 +1,6 @@ --- description: Use BOM encoding for non-ASCII files -ms.custom: PSSA v1.21.0 +ms.custom: PSSA v1.22.0 ms.date: 06/28/2023 ms.topic: reference title: UseBOMForUnicodeEncodedFile diff --git a/docs/Rules/UseCmdletCorrectly.md b/docs/Rules/UseCmdletCorrectly.md index 205c6a971..39de79c5c 100644 --- a/docs/Rules/UseCmdletCorrectly.md +++ b/docs/Rules/UseCmdletCorrectly.md @@ -1,6 +1,6 @@ --- description: Use Cmdlet Correctly -ms.custom: PSSA v1.21.0 +ms.custom: PSSA v1.22.0 ms.date: 06/28/2023 ms.topic: reference title: UseCmdletCorrectly diff --git a/docs/Rules/UseCompatibleCmdlets.md b/docs/Rules/UseCompatibleCmdlets.md index 93be36a34..a340a6869 100644 --- a/docs/Rules/UseCompatibleCmdlets.md +++ b/docs/Rules/UseCompatibleCmdlets.md @@ -1,6 +1,6 @@ --- description: Use compatible cmdlets -ms.custom: PSSA v1.21.0 +ms.custom: PSSA v1.22.0 ms.date: 06/28/2023 ms.topic: reference title: UseCompatibleCmdlets diff --git a/docs/Rules/UseCompatibleCommands.md b/docs/Rules/UseCompatibleCommands.md index 1fb47eae7..6e0714f2f 100644 --- a/docs/Rules/UseCompatibleCommands.md +++ b/docs/Rules/UseCompatibleCommands.md @@ -1,6 +1,6 @@ --- description: Use compatible commands -ms.custom: PSSA v1.21.0 +ms.custom: PSSA v1.22.0 ms.date: 06/28/2023 ms.topic: reference title: UseCompatibleCommands diff --git a/docs/Rules/UseCompatibleSyntax.md b/docs/Rules/UseCompatibleSyntax.md index 71974b62a..ebea10c22 100644 --- a/docs/Rules/UseCompatibleSyntax.md +++ b/docs/Rules/UseCompatibleSyntax.md @@ -1,6 +1,6 @@ --- description: Use compatible syntax -ms.custom: PSSA v1.21.0 +ms.custom: PSSA v1.22.0 ms.date: 06/28/2023 ms.topic: reference title: UseCompatibleSyntax diff --git a/docs/Rules/UseCompatibleTypes.md b/docs/Rules/UseCompatibleTypes.md index 8917ef5eb..72927d140 100644 --- a/docs/Rules/UseCompatibleTypes.md +++ b/docs/Rules/UseCompatibleTypes.md @@ -1,6 +1,6 @@ --- description: Use compatible types -ms.custom: PSSA v1.21.0 +ms.custom: PSSA v1.22.0 ms.date: 06/28/2023 ms.topic: reference title: UseCompatibleTypes diff --git a/docs/Rules/UseConsistentIndentation.md b/docs/Rules/UseConsistentIndentation.md index f9b5d2d81..fa331a74f 100644 --- a/docs/Rules/UseConsistentIndentation.md +++ b/docs/Rules/UseConsistentIndentation.md @@ -1,6 +1,6 @@ --- description: Use consistent indentation -ms.custom: PSSA v1.21.0 +ms.custom: PSSA v1.22.0 ms.date: 06/28/2023 ms.topic: reference title: UseConsistentIndentation diff --git a/docs/Rules/UseConsistentWhitespace.md b/docs/Rules/UseConsistentWhitespace.md index 76119293d..1841ed0f5 100644 --- a/docs/Rules/UseConsistentWhitespace.md +++ b/docs/Rules/UseConsistentWhitespace.md @@ -1,6 +1,6 @@ --- description: Use whitespaces -ms.custom: PSSA v1.21.0 +ms.custom: PSSA v1.22.0 ms.date: 06/28/2023 ms.topic: reference title: UseConsistentWhitespace diff --git a/docs/Rules/UseCorrectCasing.md b/docs/Rules/UseCorrectCasing.md index 7fa3cc5b3..c39c08875 100644 --- a/docs/Rules/UseCorrectCasing.md +++ b/docs/Rules/UseCorrectCasing.md @@ -1,6 +1,6 @@ --- description: Use exact casing of cmdlet/function/parameter name. -ms.custom: PSSA v1.21.0 +ms.custom: PSSA v1.22.0 ms.date: 06/28/2023 ms.topic: reference title: UseCorrectCasing diff --git a/docs/Rules/UseDeclaredVarsMoreThanAssignments.md b/docs/Rules/UseDeclaredVarsMoreThanAssignments.md index 080fbb671..482105db4 100644 --- a/docs/Rules/UseDeclaredVarsMoreThanAssignments.md +++ b/docs/Rules/UseDeclaredVarsMoreThanAssignments.md @@ -1,6 +1,6 @@ --- description: Extra Variables -ms.custom: PSSA v1.21.0 +ms.custom: PSSA v1.22.0 ms.date: 06/28/2023 ms.topic: reference title: UseDeclaredVarsMoreThanAssignments diff --git a/docs/Rules/UseLiteralInitializerForHashtable.md b/docs/Rules/UseLiteralInitializerForHashtable.md index 31462c743..bb180d832 100644 --- a/docs/Rules/UseLiteralInitializerForHashtable.md +++ b/docs/Rules/UseLiteralInitializerForHashtable.md @@ -1,6 +1,6 @@ --- description: Create hashtables with literal initializers -ms.custom: PSSA v1.21.0 +ms.custom: PSSA v1.22.0 ms.date: 06/28/2023 ms.topic: reference title: UseLiteralInitializerForHashtable diff --git a/docs/Rules/UseOutputTypeCorrectly.md b/docs/Rules/UseOutputTypeCorrectly.md index 4ce9994da..01895c17d 100644 --- a/docs/Rules/UseOutputTypeCorrectly.md +++ b/docs/Rules/UseOutputTypeCorrectly.md @@ -1,6 +1,6 @@ --- description: Use OutputType Correctly -ms.custom: PSSA v1.21.0 +ms.custom: PSSA v1.22.0 ms.date: 06/28/2023 ms.topic: reference title: UseOutputTypeCorrectly diff --git a/docs/Rules/UsePSCredentialType.md b/docs/Rules/UsePSCredentialType.md index 79e1a194b..c3c2dc7f1 100644 --- a/docs/Rules/UsePSCredentialType.md +++ b/docs/Rules/UsePSCredentialType.md @@ -1,6 +1,6 @@ --- description: Use PSCredential type. -ms.custom: PSSA v1.21.0 +ms.custom: PSSA v1.22.0 ms.date: 06/28/2023 ms.topic: reference title: UsePSCredentialType diff --git a/docs/Rules/UseProcessBlockForPipelineCommand.md b/docs/Rules/UseProcessBlockForPipelineCommand.md index bcf11a8b4..d74da5a71 100644 --- a/docs/Rules/UseProcessBlockForPipelineCommand.md +++ b/docs/Rules/UseProcessBlockForPipelineCommand.md @@ -1,6 +1,6 @@ --- description: Use process block for command that accepts input from pipeline. -ms.custom: PSSA v1.21.0 +ms.custom: PSSA v1.22.0 ms.date: 06/28/2023 ms.topic: reference title: UseProcessBlockForPipelineCommand diff --git a/docs/Rules/UseShouldProcessForStateChangingFunctions.md b/docs/Rules/UseShouldProcessForStateChangingFunctions.md index 45017dba8..5c63d150d 100644 --- a/docs/Rules/UseShouldProcessForStateChangingFunctions.md +++ b/docs/Rules/UseShouldProcessForStateChangingFunctions.md @@ -1,6 +1,6 @@ --- description: Use ShouldProcess For State Changing Functions -ms.custom: PSSA v1.21.0 +ms.custom: PSSA v1.22.0 ms.date: 06/28/2023 ms.topic: reference title: UseShouldProcessForStateChangingFunctions diff --git a/docs/Rules/UseSingularNouns.md b/docs/Rules/UseSingularNouns.md index 387d48c2d..6d1379664 100644 --- a/docs/Rules/UseSingularNouns.md +++ b/docs/Rules/UseSingularNouns.md @@ -1,6 +1,6 @@ --- description: Cmdlet Singular Noun -ms.custom: PSSA v1.21.0 +ms.custom: PSSA v1.22.0 ms.date: 06/28/2023 ms.topic: reference title: UseSingularNouns diff --git a/docs/Rules/UseSupportsShouldProcess.md b/docs/Rules/UseSupportsShouldProcess.md index 9d894b85b..40767e060 100644 --- a/docs/Rules/UseSupportsShouldProcess.md +++ b/docs/Rules/UseSupportsShouldProcess.md @@ -1,6 +1,6 @@ --- description: Use SupportsShouldProcess -ms.custom: PSSA v1.21.0 +ms.custom: PSSA v1.22.0 ms.date: 06/28/2023 ms.topic: reference title: UseSupportsShouldProcess diff --git a/docs/Rules/UseToExportFieldsInManifest.md b/docs/Rules/UseToExportFieldsInManifest.md index dcbf890b7..5a4c87c73 100644 --- a/docs/Rules/UseToExportFieldsInManifest.md +++ b/docs/Rules/UseToExportFieldsInManifest.md @@ -1,6 +1,6 @@ --- description: Use the *ToExport module manifest fields. -ms.custom: PSSA v1.21.0 +ms.custom: PSSA v1.22.0 ms.date: 06/28/2023 ms.topic: reference title: UseToExportFieldsInManifest diff --git a/docs/Rules/UseUTF8EncodingForHelpFile.md b/docs/Rules/UseUTF8EncodingForHelpFile.md index 56b6f0010..8f7ab429c 100644 --- a/docs/Rules/UseUTF8EncodingForHelpFile.md +++ b/docs/Rules/UseUTF8EncodingForHelpFile.md @@ -1,6 +1,6 @@ --- description: Use UTF8 Encoding For Help File -ms.custom: PSSA v1.21.0 +ms.custom: PSSA v1.22.0 ms.date: 06/28/2023 ms.topic: reference title: UseUTF8EncodingForHelpFile diff --git a/docs/Rules/UseUsingScopeModifierInNewRunspaces.md b/docs/Rules/UseUsingScopeModifierInNewRunspaces.md index 88769d80b..86a76561c 100644 --- a/docs/Rules/UseUsingScopeModifierInNewRunspaces.md +++ b/docs/Rules/UseUsingScopeModifierInNewRunspaces.md @@ -1,6 +1,6 @@ --- description: Use 'Using:' scope modifier in RunSpace ScriptBlocks -ms.custom: PSSA v1.21.0 +ms.custom: PSSA v1.22.0 ms.date: 06/28/2023 ms.topic: reference title: UseUsingScopeModifierInNewRunspaces From f15cdbf5fd3e271eb280f60a796fdc6a3224feb6 Mon Sep 17 00:00:00 2001 From: Christoph Bergmeister Date: Tue, 13 Feb 2024 18:16:40 +0000 Subject: [PATCH 39/42] Remove Appveyor badge (#1962) --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index 97c66848d..c61522134 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,6 @@ [![Build Status](https://dev.azure.com/powershell/psscriptanalyzer/_apis/build/status/psscriptanalyzer-ci?branchName=master)](https://dev.azure.com/powershell/psscriptanalyzer/_build/latest?definitionId=80&branchName=master) -[![Build status](https://ci.appveyor.com/api/projects/status/h5mot3vqtvxw5d7l/branch/master?svg=true)](https://ci.appveyor.com/project/PowerShell/psscriptanalyzer/branch/master) [![Join the chat at https://gitter.im/PowerShell/PSScriptAnalyzer](https://badges.gitter.im/PowerShell/PSScriptAnalyzer.svg)](https://gitter.im/PowerShell/PSScriptAnalyzer?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) ## Table of Contents From 6cb66c14c6cff69cc88f4a3f45676b79d652338b Mon Sep 17 00:00:00 2001 From: Christoph Bergmeister Date: Tue, 13 Feb 2024 18:20:35 +0000 Subject: [PATCH 40/42] Do not hard code common parameters in module help test any more (#1963) --- Tests/Engine/ModuleHelp.Tests.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tests/Engine/ModuleHelp.Tests.ps1 b/Tests/Engine/ModuleHelp.Tests.ps1 index 85e93fe3e..ac40dcf94 100644 --- a/Tests/Engine/ModuleHelp.Tests.ps1 +++ b/Tests/Engine/ModuleHelp.Tests.ps1 @@ -175,7 +175,7 @@ Describe 'Cmdlet parameter help' { ) BEGIN { - $Common = 'Debug', 'ErrorAction', 'ErrorVariable', 'InformationAction', 'InformationVariable', 'OutBuffer', 'OutVariable', 'PipelineVariable', 'ProgressAction', 'Verbose', 'WarningAction', 'WarningVariable' + $Common = [System.Management.Automation.PSCmdlet]::CommonParameters $parameters = @() } PROCESS { From c06e0052d14902bb94f5eb082a9553db559b1bfc Mon Sep 17 00:00:00 2001 From: Friedrich Weinmann Date: Tue, 13 Feb 2024 19:23:10 +0100 Subject: [PATCH 41/42] PSReviewUnusedParameter: Add CommandsToTraverse option (#1921) * Added command traversal option Explicitly included Where-Object and ForEach-Object scriptblocks to also be searched for variable use * Command traversal check no longer case sensitive * Extended tests for selective command traversal * Rename setting to CommandsToTraverse * Added docs for new configuration: CommandsToTraverse --- Rules/ReviewUnusedParameter.cs | 91 ++++++++++++++++++++- Tests/Rules/ReviewUnusedParameter.tests.ps1 | 26 +++++- docs/Rules/ReviewUnusedParameter.md | 18 ++++ 3 files changed, 130 insertions(+), 5 deletions(-) diff --git a/Rules/ReviewUnusedParameter.cs b/Rules/ReviewUnusedParameter.cs index ffaaa1334..f13584fed 100644 --- a/Rules/ReviewUnusedParameter.cs +++ b/Rules/ReviewUnusedParameter.cs @@ -21,8 +21,60 @@ namespace Microsoft.Windows.PowerShell.ScriptAnalyzer.BuiltinRules #endif public class ReviewUnusedParameter : IScriptRule { + private readonly string TraverseArgName = "CommandsToTraverse"; + public List TraverseCommands { get; private set; } + + /// + /// Configure the rule. + /// + /// Sets the list of commands to traverse of this rule + /// + private void SetProperties() + { + TraverseCommands = new List() { "Where-Object", "ForEach-Object" }; + + Dictionary ruleArgs = Helper.Instance.GetRuleArguments(GetName()); + if (ruleArgs == null) + { + return; + } + + if (!ruleArgs.TryGetValue(TraverseArgName, out object obj)) + { + return; + } + IEnumerable commands = obj as IEnumerable; + if (commands == null) + { + // try with enumerable objects + var enumerableObjs = obj as IEnumerable; + if (enumerableObjs == null) + { + return; + } + foreach (var x in enumerableObjs) + { + var y = x as string; + if (y == null) + { + return; + } + else + { + TraverseCommands.Add(y); + } + } + } + else + { + TraverseCommands.AddRange(commands); + } + } + public IEnumerable AnalyzeScript(Ast ast, string fileName) { + SetProperties(); + if (ast == null) { throw new ArgumentNullException(Strings.NullAstErrorMessage); @@ -46,10 +98,7 @@ public IEnumerable AnalyzeScript(Ast ast, string fileName) IEnumerable parameterAsts = scriptBlockAst.FindAll(oneAst => oneAst is ParameterAst, false); // list all variables - IDictionary variableCount = scriptBlockAst.FindAll(oneAst => oneAst is VariableExpressionAst, false) - .Select(variableExpressionAst => ((VariableExpressionAst)variableExpressionAst).VariablePath.UserPath) - .GroupBy(variableName => variableName, StringComparer.OrdinalIgnoreCase) - .ToDictionary(variableName => variableName.Key, variableName => variableName.Count(), StringComparer.OrdinalIgnoreCase); + IDictionary variableCount = GetVariableCount(scriptBlockAst); foreach (ParameterAst parameterAst in parameterAsts) { @@ -164,5 +213,39 @@ public string GetSourceName() { return string.Format(CultureInfo.CurrentCulture, Strings.SourceName); } + + /// + /// Returns a dictionary including all variables in the scriptblock and their count + /// + /// The scriptblock ast to scan + /// Previously generated data. New findings are added to any existing dictionary if present + /// a dictionary including all variables in the scriptblock and their count + IDictionary GetVariableCount(ScriptBlockAst ast, Dictionary data = null) + { + Dictionary content = data; + if (null == data) + content = new Dictionary(StringComparer.OrdinalIgnoreCase); + IDictionary result = ast.FindAll(oneAst => oneAst is VariableExpressionAst, false) + .Select(variableExpressionAst => ((VariableExpressionAst)variableExpressionAst).VariablePath.UserPath) + .GroupBy(variableName => variableName, StringComparer.OrdinalIgnoreCase) + .ToDictionary(variableName => variableName.Key, variableName => variableName.Count(), StringComparer.OrdinalIgnoreCase); + + foreach (string key in result.Keys) + { + if (content.ContainsKey(key)) + content[key] = content[key] + result[key]; + else + content[key] = result[key]; + } + + IEnumerable foundScriptBlocks = ast.FindAll(oneAst => oneAst is ScriptBlockExpressionAst, false) + .Where(oneAst => oneAst?.Parent is CommandAst && ((CommandAst)oneAst.Parent).CommandElements[0] is StringConstantExpressionAst && TraverseCommands.Contains(((StringConstantExpressionAst)((CommandAst)oneAst.Parent).CommandElements[0]).Value, StringComparer.OrdinalIgnoreCase)) + .Select(oneAst => ((ScriptBlockExpressionAst)oneAst).ScriptBlock); + foreach (Ast astItem in foundScriptBlocks) + if (astItem != ast) + GetVariableCount((ScriptBlockAst)astItem, content); + + return content; + } } } diff --git a/Tests/Rules/ReviewUnusedParameter.tests.ps1 b/Tests/Rules/ReviewUnusedParameter.tests.ps1 index 0249f9743..59d8b160d 100644 --- a/Tests/Rules/ReviewUnusedParameter.tests.ps1 +++ b/Tests/Rules/ReviewUnusedParameter.tests.ps1 @@ -32,6 +32,12 @@ Describe "ReviewUnusedParameter" { $Violations.Count | Should -Be 1 } + It "doesn't traverse scriptblock scope for a random command" { + $ScriptDefinition = '{ param ($Param1) 1..3 | Invoke-Parallel { $Param1 }}' + $Violations = Invoke-ScriptAnalyzer -ScriptDefinition $ScriptDefinition -IncludeRule $RuleName + $Violations.Count | Should -Be 1 + } + It "violations have correct rule and severity" { $ScriptDefinition = 'function BadFunc1 { param ($Param1, $Param2) $Param1}' $Violations = Invoke-ScriptAnalyzer -ScriptDefinition $ScriptDefinition -IncludeRule $RuleName @@ -81,6 +87,24 @@ Describe "ReviewUnusedParameter" { $ScriptDefinition = 'function foo { param ($Param1, $param2) $param1; $Param2}' $Violations = Invoke-ScriptAnalyzer -ScriptDefinition $ScriptDefinition -IncludeRule $RuleName $Violations.Count | Should -Be 0 + } + + It "does traverse scriptblock scope for Foreach-Object" { + $ScriptDefinition = '{ param ($Param1) 1..3 | ForEach-Object { $Param1 }}' + $Violations = Invoke-ScriptAnalyzer -ScriptDefinition $ScriptDefinition -IncludeRule $RuleName + $Violations.Count | Should -Be 0 + } + + It "does traverse scriptblock scope for commands added to the traversal list" { + $ScriptDefinition = '{ param ($Param1) Invoke-PSFProtectedCommand { $Param1 } }' + $Violations = Invoke-ScriptAnalyzer -ScriptDefinition $ScriptDefinition -IncludeRule $RuleName -Settings @{ + Rules = @{ + PSReviewUnusedParameter = @{ + CommandsToTraverse = @('Invoke-PSFProtectedCommand') + } + } + } + $Violations.Count | Should -Be 0 } } -} +} \ No newline at end of file diff --git a/docs/Rules/ReviewUnusedParameter.md b/docs/Rules/ReviewUnusedParameter.md index c955760d6..1673bb5a3 100644 --- a/docs/Rules/ReviewUnusedParameter.md +++ b/docs/Rules/ReviewUnusedParameter.md @@ -14,6 +14,24 @@ title: ReviewUnusedParameter This rule identifies parameters declared in a script, scriptblock, or function scope that have not 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')`| + +```powershell +@{ + Rules = @{ + ReviewUnusedParameter = @{ + CommandsToTraverse = @( + 'Invoke-PSFProtectedCommand' + ) + } + } +} +``` + ## How Consider removing the unused parameter. From c085ee3499b3e2150549180147aa82177cb12581 Mon Sep 17 00:00:00 2001 From: Michael Van Leeuwen Date: Tue, 13 Feb 2024 10:26:59 -0800 Subject: [PATCH 42/42] Add AvoidUsingAllowUnencryptedAuthentication (#1857) * Add AvoidUsingAllowUnencryptedAuthentication rule * Add AvoidUsingAllowUnencryptedAuthentication docs and tests * Update docs/Rules/AvoidUsingAllowUnencryptedAuthentication.md Co-authored-by: Christoph Bergmeister * Fix code review suggestions * Fix md code styling * bump rule count in tests again * Update docs/Rules/AvoidUsingAllowUnencryptedAuthentication.md --------- Co-authored-by: Christoph Bergmeister Co-authored-by: Christoph Bergmeister --- ...voidUsingAllowUnencryptedAuthentication.cs | 117 ++++++++++++++++++ Rules/Strings.resx | 12 ++ Tests/Engine/GetScriptAnalyzerRule.tests.ps1 | 2 +- ...ngAllowUnencryptedAuthentication.tests.ps1 | 38 ++++++ ...voidUsingAllowUnencryptedAuthentication.md | 35 ++++++ docs/Rules/README.md | 1 + 6 files changed, 204 insertions(+), 1 deletion(-) create mode 100644 Rules/AvoidUsingAllowUnencryptedAuthentication.cs create mode 100644 Tests/Rules/AvoidUsingAllowUnencryptedAuthentication.tests.ps1 create mode 100644 docs/Rules/AvoidUsingAllowUnencryptedAuthentication.md diff --git a/Rules/AvoidUsingAllowUnencryptedAuthentication.cs b/Rules/AvoidUsingAllowUnencryptedAuthentication.cs new file mode 100644 index 000000000..955de8113 --- /dev/null +++ b/Rules/AvoidUsingAllowUnencryptedAuthentication.cs @@ -0,0 +1,117 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Management.Automation.Language; +using Microsoft.Windows.PowerShell.ScriptAnalyzer.Generic; +#if !CORECLR +using System.ComponentModel.Composition; +#endif +using System.Globalization; + +namespace Microsoft.Windows.PowerShell.ScriptAnalyzer.BuiltinRules +{ + /// + /// AvoidUsingAllowUnencryptedAuthentication: Avoid sending credentials and secrets over unencrypted connections. + /// +#if !CORECLR +[Export(typeof(IScriptRule))] +#endif + public class AvoidUsingAllowUnencryptedAuthentication : AvoidParameterGeneric + { + /// + /// Condition on the cmdlet that must be satisfied for the error to be raised + /// + /// + /// + public override bool CommandCondition(CommandAst CmdAst) + { + return true; + } + + /// + /// Condition on the parameter that must be satisfied for the error to be raised. + /// + /// + /// + /// + public override bool ParameterCondition(CommandAst CmdAst, CommandElementAst CeAst) + { + return CeAst is CommandParameterAst && String.Equals((CeAst as CommandParameterAst).ParameterName, "AllowUnencryptedAuthentication", StringComparison.OrdinalIgnoreCase); + } + + /// + /// Retrieves the error message + /// + /// + /// + /// + public override string GetError(string fileName, CommandAst cmdAst) + { + return String.Format(CultureInfo.CurrentCulture, Strings.AvoidUsingAllowUnencryptedAuthenticationError); + } + + /// + /// GetName: Retrieves the name of this rule. + /// + /// The name of this rule + public override string GetName() + { + return string.Format(CultureInfo.CurrentCulture, Strings.NameSpaceFormat, GetSourceName(), Strings.AvoidUsingAllowUnencryptedAuthenticationName); + } + + /// + /// GetCommonName: Retrieves the common name of this rule. + /// + /// The common name of this rule + public override string GetCommonName() + { + return string.Format(CultureInfo.CurrentCulture, Strings.AvoidUsingAllowUnencryptedAuthenticationCommonName); + } + + /// + /// GetDescription: Retrieves the description of this rule. + /// + /// The description of this rule + public override string GetDescription() + { + return string.Format(CultureInfo.CurrentCulture, Strings.AvoidUsingAllowUnencryptedAuthenticationDescription); + } + + /// + /// GetSourceType: Retrieves the type of the rule: builtin, managed or module. + /// + public override SourceType GetSourceType() + { + return SourceType.Builtin; + } + + /// + /// GetSeverity: Retrieves the severity of the rule: error, warning or information. + /// + /// + public override RuleSeverity GetSeverity() + { + return RuleSeverity.Warning; + } + + /// + /// DiagnosticSeverity: Retrieves the severity of the rule of type DiagnosticSeverity: error, warning or information. + /// + /// + public override DiagnosticSeverity GetDiagnosticSeverity() + { + return DiagnosticSeverity.Warning; + } + + /// + /// GetSourceName: Retrieves the module/assembly name the rule is from. + /// + public override string GetSourceName() + { + return string.Format(CultureInfo.CurrentCulture, Strings.SourceName); + } + } +} diff --git a/Rules/Strings.resx b/Rules/Strings.resx index 479ca1f7a..ff75828cf 100644 --- a/Rules/Strings.resx +++ b/Rules/Strings.resx @@ -1206,4 +1206,16 @@ Replace ! with -not + + Avoid AllowUnencryptedAuthentication Switch + + + Avoid sending credentials and secrets over unencrypted connections. + + + The insecure AllowUsingUnencryptedAuthentication switch was used. This should be avoided except for compatability with legacy systems. + + + AvoidUsingAllowUnencryptedAuthentication + \ No newline at end of file diff --git a/Tests/Engine/GetScriptAnalyzerRule.tests.ps1 b/Tests/Engine/GetScriptAnalyzerRule.tests.ps1 index 960a2fcd5..93824060a 100644 --- a/Tests/Engine/GetScriptAnalyzerRule.tests.ps1 +++ b/Tests/Engine/GetScriptAnalyzerRule.tests.ps1 @@ -63,7 +63,7 @@ Describe "Test Name parameters" { It "get Rules with no parameters supplied" { $defaultRules = Get-ScriptAnalyzerRule - $expectedNumRules = 69 + $expectedNumRules = 70 if ($PSVersionTable.PSVersion.Major -le 4) { # for PSv3 PSAvoidGlobalAliases is not shipped because diff --git a/Tests/Rules/AvoidUsingAllowUnencryptedAuthentication.tests.ps1 b/Tests/Rules/AvoidUsingAllowUnencryptedAuthentication.tests.ps1 new file mode 100644 index 000000000..ca89b280c --- /dev/null +++ b/Tests/Rules/AvoidUsingAllowUnencryptedAuthentication.tests.ps1 @@ -0,0 +1,38 @@ +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. + +BeforeAll { + $settings = @{ + IncludeRules = @('PSAvoidUsingAllowUnencryptedAuthentication') + Rules = @{ + PSAvoidUsingAllowUnencryptedAuthentication = @{ + Enable = $true + } + } + } +} + +Describe "AvoidUsingAllowUnencryptedAuthentication" { + Context "When there are violations" { + It "detects unencrypted authentication violations" { + (Invoke-ScriptAnalyzer -ScriptDefinition 'Invoke-WebRequest foo -AllowUnencryptedAuthentication' -Settings $settings).Count | Should -Be 1 + (Invoke-ScriptAnalyzer -ScriptDefinition 'Invoke-RestMethod foo -AllowUnencryptedAuthentication' -Settings $settings).Count | Should -Be 1 + (Invoke-ScriptAnalyzer -ScriptDefinition 'iwr foo -AllowUnencryptedAuthentication' -Settings $settings).Count | Should -Be 1 + } + + It "detects arbitrary cmdlets" { + (Invoke-ScriptAnalyzer -ScriptDefinition 'Invoke-CustomWebRequest foo -AllowUnencryptedAuthentication' -Settings $settings).Count | Should -Be 1 + } + + } + + Context "When there are no violations" { + It "does not flag safe usage" { + (Invoke-ScriptAnalyzer -ScriptDefinition 'Invoke-WebRequest foo' -Settings $settings).Count | Should -Be 0 + } + + It "does not flag cases with unrelated parameters" { + (Invoke-ScriptAnalyzer -ScriptDefinition 'Invoke-WebRequest foo -Method Get' -Settings $settings).Count | Should -Be 0 + } + } +} \ No newline at end of file diff --git a/docs/Rules/AvoidUsingAllowUnencryptedAuthentication.md b/docs/Rules/AvoidUsingAllowUnencryptedAuthentication.md new file mode 100644 index 000000000..c30b69844 --- /dev/null +++ b/docs/Rules/AvoidUsingAllowUnencryptedAuthentication.md @@ -0,0 +1,35 @@ +--- +description: Avoid sending credentials and secrets over unencrypted connections +ms.custom: PSSA v1.22.0 +ms.date: 11/06/2022 +ms.topic: reference +title: AvoidUsingAllowUnencryptedAuthentication +--- +# AvoidUsingAllowUnencryptedAuthentication + +**Severity Level: Warning** + +## Description + +Avoid using the `AllowUnencryptedAuthentication` switch on `Invoke-WebRequest`, `Invoke-RestMethod`, and other webrequest cmdlets, which sends credentials and secrets over unencrypted connections. +This should be avoided except for compatability with legacy systems. + +For more details, see the documentation warning [here](https://learn.microsoft.com/powershell/module/microsoft.powershell.utility/invoke-webrequest#-allowunencryptedauthentication). + +## How + +Avoid using the `AllowUnencryptedAuthentication` switch. + +## Example 1 + +### Wrong + +```powershell +Invoke-WebRequest foo -AllowUnencryptedAuthentication +``` + +### Correct + +```powershell +Invoke-WebRequest foo +``` \ No newline at end of file diff --git a/docs/Rules/README.md b/docs/Rules/README.md index ccfaa71ea..ded305e89 100644 --- a/docs/Rules/README.md +++ b/docs/Rules/README.md @@ -27,6 +27,7 @@ The PSScriptAnalyzer contains the following rule definitions. | [AvoidSemicolonsAsLineTerminators](./AvoidSemicolonsAsLineTerminators.md) | Warning | No | | | [AvoidShouldContinueWithoutForce](./AvoidShouldContinueWithoutForce.md) | Warning | Yes | | | [AvoidTrailingWhitespace](./AvoidTrailingWhitespace.md) | Warning | Yes | | +| [AvoidUsingAllowUnencryptedAuthentication](./AvoidUsingAllowUnencryptedAuthentication.md) | Warning | Yes | | | [AvoidUsingBrokenHashAlgorithms](./AvoidUsingBrokenHashAlgorithms.md) | Warning | Yes | | | [AvoidUsingCmdletAliases](./AvoidUsingCmdletAliases.md) | Warning | Yes | Yes2 | | [AvoidUsingComputerNameHardcoded](./AvoidUsingComputerNameHardcoded.md) | Error | Yes | |