Skip to content

Commit

Permalink
Change double quotes to single in docs where possible (PowerShell#1911)
Browse files Browse the repository at this point in the history
  • Loading branch information
sdwheeler committed May 7, 2023
1 parent a289e7f commit 76e1bbf
Show file tree
Hide file tree
Showing 23 changed files with 59 additions and 59 deletions.
8 changes: 4 additions & 4 deletions docs/Rules/AlignAssignmentStatement.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,17 @@ 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'
}
```

Alignment in this case would look like the following.

```powershell
$hashtable = @{
property1 = "value"
anotherProperty = "another value"
property1 = 'value'
anotherProperty = 'another value'
}
```

Expand Down
2 changes: 1 addition & 1 deletion docs/Rules/AvoidGlobalAliases.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions docs/Rules/AvoidInvokingEmptyMembers.md
Original file line number Diff line number Diff line change
Expand Up @@ -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')
```
6 changes: 3 additions & 3 deletions docs/Rules/AvoidOverwritingBuiltInCmdlets.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ following your settings file.
@{
'Rules' = @{
'PSAvoidOverwritingBuiltInCmdlets' = @{
'PowerShellVersion' = @("core-6.1.0-windows")
'PowerShellVersion' = @('core-6.1.0-windows')
}
}
}
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions docs/Rules/AvoidShouldContinueWithoutForce.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Function Test-ShouldContinue
$MyString = 'blah'
)
if ($PsCmdlet.ShouldContinue("ShouldContinue Query", "ShouldContinue Caption"))
if ($PsCmdlet.ShouldContinue('ShouldContinue Query', 'ShouldContinue Caption'))
{
...
}
Expand All @@ -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'))
{
...
}
Expand Down
4 changes: 2 additions & 2 deletions docs/Rules/AvoidUsingComputerNameHardcoded.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
```

Expand All @@ -45,7 +45,7 @@ Function Invoke-MyCommand ($ComputerName)
```powershell
Function Invoke-MyLocalCommand ()
{
Invoke-Command -Port 343 -ComputerName "hardcodelocalhostname"
Invoke-Command -Port 343 -ComputerName 'hardcodelocalhostname'
}
```

Expand Down
4 changes: 2 additions & 2 deletions docs/Rules/AvoidUsingConvertToSecureStringWithPlainText.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```
4 changes: 2 additions & 2 deletions docs/Rules/AvoidUsingEmptyCatchBlock.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ try
}
catch [DivideByZeroException]
{
Write-Error "DivideByZeroException"
Write-Error 'DivideByZeroException'
}
try
Expand All @@ -50,6 +50,6 @@ try
}
catch [DivideByZeroException]
{
throw "DivideByZeroException"
throw 'DivideByZeroException'
}
```
2 changes: 1 addition & 1 deletion docs/Rules/AvoidUsingInvokeExpression.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Remove the use of `Invoke-Expression`.
### Wrong

```powershell
Invoke-Expression "Get-Process"
Invoke-Expression 'Get-Process'
```

### Correct
Expand Down
4 changes: 2 additions & 2 deletions docs/Rules/AvoidUsingWMICmdlet.md
Original file line number Diff line number Diff line change
Expand Up @@ -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' }
```
8 changes: 4 additions & 4 deletions docs/Rules/AvoidUsingWriteHost.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand All @@ -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
}
Expand All @@ -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'
}
```
2 changes: 1 addition & 1 deletion docs/Rules/DSCUseVerboseMessageInDSCResource.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ Function Test-Function
{
[CmdletBinding()]
Param()
Write-Verbose "Verbose output"
Write-Verbose 'Verbose output'
...
}
```
2 changes: 1 addition & 1 deletion docs/Rules/PlaceCloseBrace.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`)
Expand Down
2 changes: 1 addition & 1 deletion docs/Rules/PlaceOpenBrace.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
2 changes: 1 addition & 1 deletion docs/Rules/ProvideCommentHelp.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Rules = @{
ExportedOnly = $false
BlockComment = $true
VSCodeSnippetCorrection = $false
Placement = "before"
Placement = 'before'
}
}
```
Expand Down
4 changes: 2 additions & 2 deletions docs/Rules/ShouldProcess.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ function Set-File
[Parameter(Mandatory=$true)]
$Path
)
"String" | Out-File -FilePath $Path
'String' | Out-File -FilePath $Path
}
```

Expand All @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion docs/Rules/UseCompatibleCmdlets.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ the following your settings file:
@{
'Rules' = @{
'PSUseCompatibleCmdlets' = @{
'compatibility' = @("core-6.1.0-windows")
'compatibility' = @('core-6.1.0-windows')
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions docs/Rules/UseCompatibleCommands.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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')]
```
6 changes: 3 additions & 3 deletions docs/Rules/UseCompatibleSyntax.md
Original file line number Diff line number Diff line change
Expand Up @@ -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'
)
}
}
Expand Down
14 changes: 7 additions & 7 deletions docs/Rules/UseCompatibleTypes.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down Expand Up @@ -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
-------- -------- ---------- ---- -------
Expand All @@ -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')]
```
8 changes: 4 additions & 4 deletions docs/Rules/UseDeclaredVarsMoreThanAssignments.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
}
```
Expand All @@ -39,7 +39,7 @@ function Test
```powershell
function Test
{
$declaredVar = "Declared just for fun"
$declaredVar = 'Declared just for fun'
Write-Output $declaredVar
}
```
Expand Down
2 changes: 1 addition & 1 deletion docs/Rules/UseOutputTypeCorrectly.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,6 @@ function Get-Foo
Param(
)
return "four"
return 'four'
}
```
Loading

0 comments on commit 76e1bbf

Please sign in to comment.