Allow duplicate braces in allman style (#449)

This commit is contained in:
Sebastian Wilzbach 2017-06-13 15:37:53 +02:00 committed by Basile Burg
parent 8a53adc22a
commit 345f26465c
1 changed files with 14 additions and 0 deletions

View File

@ -40,12 +40,18 @@ class AllManCheck : BaseAnalyzer
// ignore struct initialization
if (tokens[i-1].type == tok!"=")
continue;
// ignore duplicate braces
if (tokens[i-1].type == tok!"{" && tokens[i - 2].line != curLine)
continue;
// ignore inline { } braces
if (curLine != tokens[i + 1].line)
addErrorMessage(tokens[i].line, tokens[i].column, KEY, MESSAGE);
}
if (tokens[i].type == tok!"}" && curLine == prevTokenLine)
{
// ignore duplicate braces
if (tokens[i-1].type == tok!"}" && tokens[i - 2].line != curLine)
continue;
// ignore inline { } braces
if (!tokens[0 .. i].retro.until!(t => t.line != curLine).canFind!(t => t.type == tok!"{"))
addErrorMessage(tokens[i].line, tokens[i].column, KEY, MESSAGE);
@ -129,5 +135,13 @@ unittest
}
}, sac);
// allow duplicate braces
assertAnalyzerWarnings(q{
unittest
{{
}}
}, sac);
stderr.writeln("Unittest for Allman passed.");
}