Skip to content

Commit 7b7d7dd

Browse files
author
Kapil Borle
committed
Add documentation for IgnoreOneLineBlock switch
1 parent 9e3c1d6 commit 7b7d7dd

File tree

4 files changed

+29
-1
lines changed

4 files changed

+29
-1
lines changed

RuleDocumentation/PlaceCloseBrace.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ Close brace placement should follow a consistent style. It should be on a new li
1212
PSPlaceCloseBrace = @{
1313
Enable = $true
1414
NoEmptyLineBefore = $false
15+
IgnoreOneLineBlock = $true
1516
}
1617
}
1718
```
@@ -23,3 +24,8 @@ Enable or disable the rule during ScriptAnalyzer invocation.
2324

2425
#### NoEmptyLineBefore: bool (Default value is `$false`)
2526
Create violation if there is an empty line before a close brace.
27+
28+
#### IgnoreOneLineBlock: bool (Default value is `$true`)
29+
Indicates if close braces in a one line block should be ignored or not.
30+
E.g. $x = if ($true) { "blah" } else { "blah blah" }
31+
In the above example, if the property is set to true then the rule will not fire a violation.

RuleDocumentation/PlaceOpenBrace.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ Open brace placement should follow a consistent style. It can either follow KR s
1313
Enable = $true
1414
OnSameLine = $true
1515
NewLineAfter = $true
16+
IgnoreOneLineBlock = $true
1617
}
1718
}
1819
```
@@ -27,3 +28,8 @@ Provide an option to enforce the open brace to be on the same line as preceding
2728

2829
#### NewLineAfter: bool (Default value is `$true`)
2930
Enforce a new line character after an open brace. The default value is true.
31+
32+
#### IgnoreOneLineBlock: bool (Default value is `$true`)
33+
Indicates if open braces in a one line block should be ignored or not.
34+
E.g. $x = if ($true) { "blah" } else { "blah blah" }
35+
In the above example, if the property is set to true then the rule will not fire a violation.

Rules/PlaceCloseBrace.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,14 @@ public class PlaceCloseBrace : ConfigurableRule
3636
[ConfigurableRuleProperty(defaultValue:false)]
3737
public bool NoEmptyLineBefore { get; protected set; }
3838

39+
/// <summary>
40+
/// Indicates if close braces in a one line block should be ignored or not.
41+
/// E.g. $x = if ($true) { "blah" } else { "blah blah" }
42+
/// In the above example, if the property is set to true then the rule will
43+
/// not fire a violation.
44+
///
45+
/// Default value if true.
46+
/// </summary>
3947
[ConfigurableRuleProperty(defaultValue: true)]
4048
public bool IgnoreOneLineBlock { get; protected set; }
4149

@@ -70,7 +78,7 @@ public override IEnumerable<DiagnosticRecord> AnalyzeScript(Ast ast, string file
7078
var tokenOps = new TokenOperations(tokens, ast);
7179
tokensToIgnore = new HashSet<Token> (tokenOps.GetCloseBracesInCommandElements());
7280

73-
// Ignore open braces that are part of a one line if-else statement
81+
// Ignore close braces that are part of a one line if-else statement
7482
// E.g. $x = if ($true) { "blah" } else { "blah blah" }
7583
if (IgnoreOneLineBlock)
7684
{

Rules/PlaceOpenBrace.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,14 @@ public class PlaceOpenBrace : ConfigurableRule
4545
[ConfigurableRuleProperty(defaultValue: true)]
4646
public bool NewLineAfter { get; protected set; }
4747

48+
/// <summary>
49+
/// Indicates if open braces in a one line block should be ignored or not.
50+
/// E.g. $x = if ($true) { "blah" } else { "blah blah" }
51+
/// In the above example, if the property is set to true then the rule will
52+
/// not fire a violation.
53+
///
54+
/// Default value if true.
55+
/// </summary>
4856
[ConfigurableRuleProperty(defaultValue: true)]
4957
public bool IgnoreOneLineBlock { get; protected set; }
5058

0 commit comments

Comments
 (0)