Skip to content

Commit

Permalink
Update tests and documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
Jaykul committed Aug 17, 2021
1 parent 9a232ae commit df1e30d
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 2 deletions.
1 change: 1 addition & 0 deletions RuleDocumentation/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
|[UseApprovedVerbs](./UseApprovedVerbs.md) | Warning | |
|[UseBOMForUnicodeEncodedFile](./UseBOMForUnicodeEncodedFile.md) | Warning | |
|[UseCmdletCorrectly](./UseCmdletCorrectly.md) | Warning | |
|[UseConsistentCasing](./UseConsistentCasing.md) | Information | |
|[UseCorrectCasing](./UseCorrectCasing.md) | Information | |
|[UseDeclaredVarsMoreThanAssignments](./UseDeclaredVarsMoreThanAssignments.md) | Warning | |
|[UseLiteralInitializerForHashtable](./UseLiteralInitializerForHashtable.md) | Warning | |
Expand Down
25 changes: 25 additions & 0 deletions RuleDocumentation/UseConsistentCasing.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# UseConsistentCasing

**Severity Level: Information**

## Description

This is a style/formatting rule. PowerShell is case insensitive where applicable. The casing of keywords and operators does not matter but this rule ensures the use of lowercase for consistency and also because it helps distinguish keywords from commands (e.g. `foreach` is a keyword, but `ForEach-Object` is the command) and parameters (which should start with a capital letter).

## How

Use lowercase for language keywords and operators of the cmdlet and its parameters.

## Example

### Wrong

``` PowerShell
ForEach($file IN Get-ChildItem) { $file }
```

### Correct

``` PowerShell
foreach($file in Get-ChildItem) { $file }
```
4 changes: 2 additions & 2 deletions Tests/Engine/GetScriptAnalyzerRule.tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ Describe "Test Name parameters" {

It "get Rules with no parameters supplied" {
$defaultRules = Get-ScriptAnalyzerRule
$expectedNumRules = 65
$expectedNumRules = 66
if ($PSVersionTable.PSVersion.Major -le 4)
{
# for PSv3 PSAvoidGlobalAliases is not shipped because
Expand Down Expand Up @@ -159,7 +159,7 @@ Describe "TestSeverity" {

It "filters rules based on multiple severity inputs"{
$rules = Get-ScriptAnalyzerRule -Severity Error,Information
$rules.Count | Should -Be 18
$rules.Count | Should -Be 19
}

It "takes lower case inputs" {
Expand Down

0 comments on commit df1e30d

Please sign in to comment.