Skip to content
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

Add CheckInnerBrace and CheckPipe options to PSUseConsistentWhitespace #1092

Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
7e740b2
Check for 1 whitespace AFTER curly brace in new InnerCurly option
bergmeister Sep 25, 2018
cebbaad
check for one space in closing of inner brace
bergmeister Sep 25, 2018
5f444bd
add check for pipes. TODO: messages
bergmeister Sep 25, 2018
1052423
Merge branch 'development' of https://github.com/PowerShell/PSScriptA…
bergmeister Oct 3, 2018
1fbb541
Merge branch 'development' into UseConsistenWhiteSpace_InnerCurlyAndPipe
bergmeister Nov 2, 2018
60885b0
update settings files and add first set of tests for curly braces. TO…
bergmeister Nov 3, 2018
692969e
fix new line handling for innerbrace
bergmeister Nov 3, 2018
5ab67c1
fix suggested corrections and add another test case for inner brace
bergmeister Nov 3, 2018
a4f5c8d
order settings alphabetically and add tests for checkpipe
bergmeister Nov 3, 2018
b45cce5
fix test that returned 2 warnings now due to checkinnerbrace
bergmeister Nov 3, 2018
0668df9
fix innerPipe and write documentation
bergmeister Nov 3, 2018
d74412e
tweak backtick scenarios
bergmeister Nov 3, 2018
43b5882
fix 1 failing test
bergmeister Nov 3, 2018
73edc10
customise warning messages
bergmeister Nov 3, 2018
6b362d9
swap messages to be correct
bergmeister Nov 3, 2018
c872d1c
Merge branch 'development' of https://github.com/PowerShell/PSScriptA…
bergmeister Dec 19, 2018
ff3e3d1
add more test cases and fix small bug whereby the missing space befor…
bergmeister Dec 19, 2018
e4d6879
enforce whitespace also if there is more than 1 curly brace. TODO: ad…
bergmeister Dec 19, 2018
fb57292
add test cases for nested parenthesis and add validation to test help…
bergmeister Dec 19, 2018
196b112
add test case for more than 1 space inside curly braces and tidy up t…
bergmeister Dec 19, 2018
0bc8a97
Merge branch 'development' of https://github.com/PowerShell/PSScriptA…
bergmeister Jan 9, 2019
d15ba9d
Merge branch 'development' of https://github.com/PowerShell/PSScriptA…
bergmeister Jan 15, 2019
c46ae83
Merge branch 'development' of https://github.com/PowerShell/PSScriptA…
bergmeister Jan 15, 2019
59963b2
Merge branch 'development' into UseConsistenWhiteSpace_InnerCurlyAndPipe
bergmeister Mar 1, 2019
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
12 changes: 7 additions & 5 deletions Engine/Settings/CodeFormatting.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,13 @@
}

PSUseConsistentWhitespace = @{
Enable = $true
CheckOpenBrace = $true
CheckOpenParen = $true
CheckOperator = $true
CheckSeparator = $true
Enable = $true
CheckInnerBrace = $true
CheckOpenBrace = $true
CheckOpenParen = $true
CheckOperator = $true
CheckPipe = $true
CheckSeparator = $true
}

PSAlignAssignmentStatement = @{
Expand Down
12 changes: 7 additions & 5 deletions Engine/Settings/CodeFormattingAllman.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,13 @@
}

PSUseConsistentWhitespace = @{
Enable = $true
CheckOpenBrace = $true
CheckOpenParen = $true
CheckOperator = $true
CheckSeparator = $true
Enable = $true
CheckInnerBrace = $true
CheckOpenBrace = $true
CheckOpenParen = $true
CheckOperator = $true
CheckPipe = $true
CheckSeparator = $true
}

PSAlignAssignmentStatement = @{
Expand Down
2 changes: 2 additions & 0 deletions Engine/Settings/CodeFormattingOTBS.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,11 @@

PSUseConsistentWhitespace = @{
Enable = $true
CheckInnerBrace = $true
CheckOpenBrace = $true
CheckOpenParen = $true
CheckOperator = $true
CheckPipe = $true
CheckSeparator = $true
}

Expand Down
12 changes: 7 additions & 5 deletions Engine/Settings/CodeFormattingStroustrup.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,13 @@
}

PSUseConsistentWhitespace = @{
Enable = $true
CheckOpenBrace = $true
CheckOpenParen = $true
CheckOperator = $true
CheckSeparator = $true
Enable = $true
CheckInnerBrace = $true
CheckOpenBrace = $true
CheckOpenParen = $true
CheckOperator = $true
CheckPipe = $true
CheckSeparator = $true
}

PSAlignAssignmentStatement = @{
Expand Down
16 changes: 12 additions & 4 deletions RuleDocumentation/UseConsistentWhitespace.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,26 @@

Enable or disable the rule during ScriptAnalyzer invocation.

#### CheckInnerBrace: bool (Default value is `$true`)

Checks if there is a space after the opening brace and a space before the closing brace. E.g. `if ($true) { foo }` instead of `if ($true) {bar}`.

#### CheckOpenBrace: bool (Default value is `$true`)

Checks if there is a space between a keyword and its corresponding open brace. E.g. `foo { }`.
Checks if there is a space between a keyword and its corresponding open brace. E.g. `foo { }` instead of `foo{ }`.

#### CheckOpenParen: bool (Default value is `$true`)

Checks if there is space between a keyword and its corresponding open parenthesis. E.g. `if (true)`.
Checks if there is space between a keyword and its corresponding open parenthesis. E.g. `if (true)` instead of `if(true)`.

#### CheckOperator: bool (Default value is `$true`)

Checks if a binary or unary operator is surrounded on both sides by a space. E.g. `$x = 1`.
Checks if a binary or unary operator is surrounded on both sides by a space. E.g. `$x = 1` instead of `$x=1`.

#### CheckSeparator: bool (Default value is `$true`)

Checks if a comma or a semicolon is followed by a space. E.g. `@(1, 2, 3)` or `@{a = 1; b = 2}`.
Checks if a comma or a semicolon is followed by a space. E.g. `@(1, 2, 3)` or `@{a = 1; b = 2}` instead of `@(1,2,3)` or `@{a = 1;b = 2}`.

#### CheckPipe: bool (Default value is `$true`)

Checks if a pipe is surrounded on both sides by a space. E.g. `foo | bar` instead of `foo|bar`.
47 changes: 41 additions & 6 deletions Rules/Strings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 13 additions & 1 deletion Rules/Strings.resx
Original file line number Diff line number Diff line change
Expand Up @@ -906,7 +906,7 @@
<data name="UseConsistentWhitespaceDescription" xml:space="preserve">
<value>Check for whitespace between keyword and open paren/curly, around assigment operator ('='), around arithmetic operators and after separators (',' and ';')</value>
</data>
<data name="UseConsistentWhitespaceErrorBeforeBrace" xml:space="preserve">
<data name="UseConsistentWhitespaceErrorBeforeOpeningBrace" xml:space="preserve">
<value>Use space before open brace.</value>
</data>
<data name="UseConsistentWhitespaceErrorBeforeParen" xml:space="preserve">
Expand Down Expand Up @@ -990,4 +990,16 @@
<data name="PossibleIncorrectUsageOfRedirectionOperatorName" xml:space="preserve">
<value>PossibleIncorrectUsageOfRedirectionOperator</value>
</data>
<data name="UseConsistentWhitespaceErrorAfterOpeningBrace" xml:space="preserve">
<value>Use space after open brace.</value>
</data>
<data name="UseConsistentWhitespaceErrorBeforeClosingInnerBrace" xml:space="preserve">
<value>Use space before closing brace.</value>
</data>
<data name="UseConsistentWhitespaceErrorSpaceAfterPipe" xml:space="preserve">
<value>Use space after pipe.</value>
</data>
<data name="UseConsistentWhitespaceErrorSpaceBeforePipe" xml:space="preserve">
<value>Use space before pipe.</value>
</data>
</root>
Loading