fix #452 - false pos for namz style for VariableDecl with the "enum" storage class

This commit is contained in:
Basile Burg 2017-08-06 02:09:06 +02:00
parent 55ecfbe479
commit 511cee29dc
No known key found for this signature in database
GPG Key ID: 1868039F415CB8CF
1 changed files with 5 additions and 10 deletions

View File

@ -70,17 +70,11 @@ final class StyleChecker : BaseAnalyzer
override void visit(const VariableDeclaration vd) override void visit(const VariableDeclaration vd)
{ {
import std.algorithm.iteration : filter;
varIsEnum = !vd.storageClasses.filter!(a => a.token == tok!"enum").empty;
vd.accept(this); vd.accept(this);
} }
override void visit(const Declarator dec) override void visit(const Declarator dec)
{ {
if (varIsEnum)
checkAggregateName("Variable", dec.name);
else
checkLowercaseName("Variable", dec.name); checkLowercaseName("Variable", dec.name);
} }
@ -143,8 +137,6 @@ final class StyleChecker : BaseAnalyzer
aggregateType ~ " name '" ~ name.text ~ "' does not match style guidelines."); aggregateType ~ " name '" ~ name.text ~ "' does not match style guidelines.");
} }
bool varIsEnum;
bool[] _winStyles = [false]; bool[] _winStyles = [false];
bool winStyle() bool winStyle()
@ -183,7 +175,10 @@ unittest
interface puma {} // [warn]: Interface name 'puma' does not match style guidelines. interface puma {} // [warn]: Interface name 'puma' does not match style guidelines.
struct dog {} // [warn]: Struct name 'dog' does not match style guidelines. struct dog {} // [warn]: Struct name 'dog' does not match style guidelines.
enum racoon { a } // [warn]: Enum name 'racoon' does not match style guidelines. enum racoon { a } // [warn]: Enum name 'racoon' does not match style guidelines.
enum bool Something = false; enum bool something = false;
enum bool someThing = false;
enum Cat { fritz, }
enum Cat = Cat.fritz;
}c, sac); }c, sac);
assertAnalyzerWarnings(q{ assertAnalyzerWarnings(q{