Skip to content

Commit 1c34b25

Browse files
author
Kapil Borle
committed
Override configurerule in PlaceOpenBrace rule
1 parent 5a92bc4 commit 1c34b25

File tree

1 file changed

+20
-15
lines changed

1 file changed

+20
-15
lines changed

Rules/PlaceOpenBrace.cs

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -57,21 +57,6 @@ public override IEnumerable<DiagnosticRecord> AnalyzeScript(Ast ast, string file
5757
if (!IsRuleConfigured)
5858
{
5959
ConfigureRule();
60-
if (OnSameLine)
61-
{
62-
// findViolations = this.FindViolationsForBraceShouldBeOnSameLine;
63-
violationFinders.Add(FindViolationsForBraceShouldBeOnSameLine);
64-
}
65-
else
66-
{
67-
// findViolations = this.FindViolationsForBraceShouldNotBeOnSameLine;
68-
violationFinders.Add(FindViolationsForBraceShouldNotBeOnSameLine);
69-
}
70-
71-
if (NewLineAfter)
72-
{
73-
violationFinders.Add(FindViolationsForNoNewLineAfterBrace);
74-
}
7560
}
7661

7762
var diagnosticRecords = new List<DiagnosticRecord>();
@@ -90,6 +75,26 @@ public override IEnumerable<DiagnosticRecord> AnalyzeScript(Ast ast, string file
9075
return diagnosticRecords;
9176
}
9277

78+
public override void ConfigureRule()
79+
{
80+
base.ConfigureRule();
81+
if (OnSameLine)
82+
{
83+
// findViolations = this.FindViolationsForBraceShouldBeOnSameLine;
84+
violationFinders.Add(FindViolationsForBraceShouldBeOnSameLine);
85+
}
86+
else
87+
{
88+
// findViolations = this.FindViolationsForBraceShouldNotBeOnSameLine;
89+
violationFinders.Add(FindViolationsForBraceShouldNotBeOnSameLine);
90+
}
91+
92+
if (NewLineAfter)
93+
{
94+
violationFinders.Add(FindViolationsForNoNewLineAfterBrace);
95+
}
96+
}
97+
9398
private IEnumerable<DiagnosticRecord> FindViolationsForBraceShouldBeOnSameLine(
9499
Token[] tokens,
95100
string fileName)

0 commit comments

Comments
 (0)