Skip to content

(GH-70) Add AvoidSemiColonsAsLineTerminators #86

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
---
description: Avoid semicolons as line terminators
ms.custom: PSSA v1.21.0
ms.date: 07/25/2022
ms.topic: reference
title: AvoidSemicolonsAsLineTerminators
---

# AvoidSemicolonsAsLineTerminators

**Severity Level: Warning**

## Description

Lines should not end with a semicolon.

> [!NOTE]
> This rule is not enabled by default. The user needs to enable it through settings.

## Example

### Wrong

```powershell
Install-Module -Name PSScriptAnalyzer; $a = 1 + $b;
```

```powershell
Install-Module -Name PSScriptAnalyzer;
$a = 1 + $b
```

### Correct

```powershell
Install-Module -Name PSScriptAnalyzer; $a = 1 + $b
```

```powershell
Install-Module -Name PSScriptAnalyzer
$a = 1 + $b
```

## Configuration

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

### Parameters

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

Enable or disable the rule during ScriptAnalyzer invocation.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ The PSScriptAnalyzer contains the following rule definitions.
| [AvoidMultipleTypeAttributes<sup>1</sup>](./AvoidMultipleTypeAttributes.md) | Warning | Yes | |
| [AvoidNullOrEmptyHelpMessageAttribute](./AvoidNullOrEmptyHelpMessageAttribute.md) | Warning | Yes | |
| [AvoidOverwritingBuiltInCmdlets](./AvoidOverwritingBuiltInCmdlets.md) | Warning | Yes | Yes |
| [AvoidSemicolonsAsLineTerminators](./AvoidSemicolonsAsLineTerminators.md) | Warning | No | |
| [AvoidShouldContinueWithoutForce](./AvoidShouldContinueWithoutForce.md) | Warning | Yes | |
| [AvoidTrailingWhitespace](./AvoidTrailingWhitespace.md) | Warning | Yes | |
| [AvoidUsingCmdletAliases](./AvoidUsingCmdletAliases.md) | Warning | Yes | Yes<sup>2</sup> |
Expand Down
2 changes: 2 additions & 0 deletions reference/docs-conceptual/toc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ items:
href: PSScriptAnalyzer/Rules/AvoidNullOrEmptyHelpMessageAttribute.md
- name: AvoidOverwritingBuiltInCmdlets
href: PSScriptAnalyzer/Rules/AvoidOverwritingBuiltInCmdlets.md
- name: AvoidSemicolonsAsLineTerminators
href: PSScriptAnalyzer/Rules/AvoidSemicolonsAsLineTerminators.md
- name: AvoidShouldContinueWithoutForce
href: PSScriptAnalyzer/Rules/AvoidShouldContinueWithoutForce.md
- name: AvoidTrailingWhitespace
Expand Down