Skip to content

Commit c6934de

Browse files
(GH-70) Add AvoidSemiColonsAsLineTerminators (#86)
This change adds the new `AvoidSemiColonsAsLineTerminators` rule documentation to PSScriptAnalyzer. - Resolves #70 - Fixes AB#4588
1 parent ac69690 commit c6934de

File tree

3 files changed

+61
-0
lines changed

3 files changed

+61
-0
lines changed
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
---
2+
description: Avoid semicolons as line terminators
3+
ms.custom: PSSA v1.21.0
4+
ms.date: 07/25/2022
5+
ms.topic: reference
6+
title: AvoidSemicolonsAsLineTerminators
7+
---
8+
9+
# AvoidSemicolonsAsLineTerminators
10+
11+
**Severity Level: Warning**
12+
13+
## Description
14+
15+
Lines should not end with a semicolon.
16+
17+
> [!NOTE]
18+
> This rule is not enabled by default. The user needs to enable it through settings.
19+
20+
## Example
21+
22+
### Wrong
23+
24+
```powershell
25+
Install-Module -Name PSScriptAnalyzer; $a = 1 + $b;
26+
```
27+
28+
```powershell
29+
Install-Module -Name PSScriptAnalyzer;
30+
$a = 1 + $b
31+
```
32+
33+
### Correct
34+
35+
```powershell
36+
Install-Module -Name PSScriptAnalyzer; $a = 1 + $b
37+
```
38+
39+
```powershell
40+
Install-Module -Name PSScriptAnalyzer
41+
$a = 1 + $b
42+
```
43+
44+
## Configuration
45+
46+
```powershell
47+
Rules = @{
48+
PSAvoidSemicolonsAsLineTerminators = @{
49+
Enable = $true
50+
}
51+
}
52+
```
53+
54+
### Parameters
55+
56+
#### Enable: bool (Default value is `$false`)
57+
58+
Enable or disable the rule during ScriptAnalyzer invocation.

reference/docs-conceptual/PSScriptAnalyzer/Rules/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ The PSScriptAnalyzer contains the following rule definitions.
2323
| [AvoidMultipleTypeAttributes<sup>1</sup>](./AvoidMultipleTypeAttributes.md) | Warning | Yes | |
2424
| [AvoidNullOrEmptyHelpMessageAttribute](./AvoidNullOrEmptyHelpMessageAttribute.md) | Warning | Yes | |
2525
| [AvoidOverwritingBuiltInCmdlets](./AvoidOverwritingBuiltInCmdlets.md) | Warning | Yes | Yes |
26+
| [AvoidSemicolonsAsLineTerminators](./AvoidSemicolonsAsLineTerminators.md) | Warning | No | |
2627
| [AvoidShouldContinueWithoutForce](./AvoidShouldContinueWithoutForce.md) | Warning | Yes | |
2728
| [AvoidTrailingWhitespace](./AvoidTrailingWhitespace.md) | Warning | Yes | |
2829
| [AvoidUsingCmdletAliases](./AvoidUsingCmdletAliases.md) | Warning | Yes | Yes<sup>2</sup> |

reference/docs-conceptual/toc.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ items:
6565
href: PSScriptAnalyzer/Rules/AvoidNullOrEmptyHelpMessageAttribute.md
6666
- name: AvoidOverwritingBuiltInCmdlets
6767
href: PSScriptAnalyzer/Rules/AvoidOverwritingBuiltInCmdlets.md
68+
- name: AvoidSemicolonsAsLineTerminators
69+
href: PSScriptAnalyzer/Rules/AvoidSemicolonsAsLineTerminators.md
6870
- name: AvoidShouldContinueWithoutForce
6971
href: PSScriptAnalyzer/Rules/AvoidShouldContinueWithoutForce.md
7072
- name: AvoidTrailingWhitespace

0 commit comments

Comments
 (0)