> ## Documentation Index
> Fetch the complete documentation index at: https://tally.wharflab.com/llms.txt
> Use this file to discover all available pages before exploring further.

# powershell/PSAvoidUsingDoubleQuotesForConstantString

> Avoid using double quotes if the string is constant.

`powershell/PSAvoidUsingDoubleQuotesForConstantString` is a PSScriptAnalyzer diagnostic emitted by tally for PowerShell snippets embedded in
Dockerfiles.

| Property | Value            |
| -------- | ---------------- |
| Severity | Information      |
| Category | PSScriptAnalyzer |
| Auto-fix | No               |

## Description

Single quotes should be used when the value of a string is constant. A constant string doesn't
contain variables or expressions intended to insert values into the string, such as
`"$PID-$(hostname)"`).

This makes the intent clearer that the string is a constant and makes it easier to use some special
characters such as `$` within that string expression without needing to escape them.

There are exceptions to that when double quoted strings are more readable. For example, when the
string value itself must contain a single quote or other special characters, such as newline
(``"`n"``), are already being escaped. The rule does not warn in these cases.

## Examples

### Problematic code

```powershell theme={null}
$constantValue = "I Love PowerShell"
```

### Correct code

```powershell theme={null}
$constantValue = 'I Love PowerShell'
```

## Source

This rule documentation is adapted from Microsoft's PSScriptAnalyzer documentation for
[AvoidUsingDoubleQuotesForConstantString](https://github.com/MicrosoftDocs/PowerShell-Docs-Modules/blob/main/reference/docs-conceptual/PSScriptAnalyzer/Rules/AvoidUsingDoubleQuotesForConstantString.md),
licensed under [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/).
