Skip to content

Commit 4a71560

Browse files
committed
tweaked regular expressions for LeftCurlyCheck
1 parent cda6de3 commit 4a71560

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

checkstyle/checks/LeftCurlyCheck.hx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -197,10 +197,12 @@ class LeftCurlyCheck extends Check {
197197
@SuppressWarnings("checkstyle:BlockFormat")
198198
function checkLeftCurly(line:String, pos:Position) {
199199
var lineLength:Int = line.length;
200-
line = StringTools.trim(line);
201200

202-
var curlyAtEOL:Bool = ~/^.+\{\}?([ \t]*|[ \t]*\/\/.*)$/.match(line);
203-
var curlyOnNL:Bool = ~/^\{\}?/.match(line);
201+
// must have at least one non whitespace character before curly
202+
// and only whitespace, } or // + comment after curly
203+
var curlyAtEOL:Bool = ~/^\s*\S.*\{\}?\s*(|\/\/.*)$/.match(line);
204+
// must have only whitespace before curly
205+
var curlyOnNL:Bool = ~/^\s*\{\}?/.match(line);
204206

205207
try {
206208
if (curlyAtEOL) {

0 commit comments

Comments
 (0)