Allow duplicate braces in allman style (#449)
This commit is contained in:
parent
8a53adc22a
commit
345f26465c
|
@ -40,12 +40,18 @@ class AllManCheck : BaseAnalyzer
|
||||||
// ignore struct initialization
|
// ignore struct initialization
|
||||||
if (tokens[i-1].type == tok!"=")
|
if (tokens[i-1].type == tok!"=")
|
||||||
continue;
|
continue;
|
||||||
|
// ignore duplicate braces
|
||||||
|
if (tokens[i-1].type == tok!"{" && tokens[i - 2].line != curLine)
|
||||||
|
continue;
|
||||||
// ignore inline { } braces
|
// ignore inline { } braces
|
||||||
if (curLine != tokens[i + 1].line)
|
if (curLine != tokens[i + 1].line)
|
||||||
addErrorMessage(tokens[i].line, tokens[i].column, KEY, MESSAGE);
|
addErrorMessage(tokens[i].line, tokens[i].column, KEY, MESSAGE);
|
||||||
}
|
}
|
||||||
if (tokens[i].type == tok!"}" && curLine == prevTokenLine)
|
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
|
// ignore inline { } braces
|
||||||
if (!tokens[0 .. i].retro.until!(t => t.line != curLine).canFind!(t => t.type == tok!"{"))
|
if (!tokens[0 .. i].retro.until!(t => t.line != curLine).canFind!(t => t.type == tok!"{"))
|
||||||
addErrorMessage(tokens[i].line, tokens[i].column, KEY, MESSAGE);
|
addErrorMessage(tokens[i].line, tokens[i].column, KEY, MESSAGE);
|
||||||
|
@ -129,5 +135,13 @@ unittest
|
||||||
}
|
}
|
||||||
}, sac);
|
}, sac);
|
||||||
|
|
||||||
|
// allow duplicate braces
|
||||||
|
assertAnalyzerWarnings(q{
|
||||||
|
unittest
|
||||||
|
{{
|
||||||
|
}}
|
||||||
|
}, sac);
|
||||||
|
|
||||||
|
|
||||||
stderr.writeln("Unittest for Allman passed.");
|
stderr.writeln("Unittest for Allman passed.");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue