From 74e087aac300ebde463029bf60a0df25e9ca73d2 Mon Sep 17 00:00:00 2001 From: Matthew Brennan Jones Date: Wed, 25 Jun 2014 10:37:30 -0700 Subject: [PATCH] Made warning and test messages more consistent. Made all warnings end in a period. Made all names have single quotes. Made all test success messages the same. --- analysis/constructors.d | 4 ++-- analysis/del.d | 8 ++++---- analysis/duplicate_attribute.d | 18 +++++++++--------- analysis/fish.d | 18 +++++++++--------- analysis/ifelsesame.d | 6 +++--- analysis/linespan.d | 2 +- analysis/numbers.d | 8 ++++---- analysis/objectconst.d | 12 ++++++------ analysis/opequals_without_tohash.d | 12 ++++++------ analysis/pokemon.d | 8 ++++---- analysis/style.d | 18 +++++++++--------- std/d/parser.d | 24 ++++++++++++------------ 12 files changed, 69 insertions(+), 69 deletions(-) diff --git a/analysis/constructors.d b/analysis/constructors.d index 2d38e82..023d69b 100644 --- a/analysis/constructors.d +++ b/analysis/constructors.d @@ -30,7 +30,7 @@ class ConstructorCheck : BaseAnalyzer addErrorMessage(classDeclaration.name.line, classDeclaration.name.column, "This class has a zero-argument" ~ " constructor as well as a constructor with one default" - ~ " argument. This can be confusing"); + ~ " argument. This can be confusing."); } hasDefaultArgConstructor = oldHasDefault; hasNoArgConstructor = oldHasNoArg; @@ -91,7 +91,7 @@ private: unittest { assertAnalyzerWarnings(q{ - class Cat // [warn]: This class has a zero-argument constructor as well as a constructor with one default argument. This can be confusing + class Cat // [warn]: This class has a zero-argument constructor as well as a constructor with one default argument. This can be confusing. { this() {} this(string name = "kittie") {} diff --git a/analysis/del.d b/analysis/del.d index d6120f9..c564265 100644 --- a/analysis/del.d +++ b/analysis/del.d @@ -12,7 +12,7 @@ import analysis.base; import analysis.helpers; /** - * Checks for use of the deprecated "delete" keyword + * Checks for use of the deprecated 'delete' keyword */ class DeleteCheck : BaseAnalyzer { @@ -25,7 +25,7 @@ class DeleteCheck : BaseAnalyzer override void visit(const DeleteExpression d) { - addErrorMessage(d.line, d.column, "Avoid using the delete keyword"); + addErrorMessage(d.line, d.column, "Avoid using the 'delete' keyword."); d.accept(this); } } @@ -36,10 +36,10 @@ unittest void testDelete() { int[int] data = [1 : 2]; - delete data[1]; // [warn]: Avoid using the delete keyword + delete data[1]; // [warn]: Avoid using the 'delete' keyword. auto a = new Class(); - delete a; // [warn]: Avoid using the delete keyword + delete a; // [warn]: Avoid using the 'delete' keyword. } }c, analysis.run.AnalyzerCheck.delete_check); diff --git a/analysis/duplicate_attribute.d b/analysis/duplicate_attribute.d index c36041e..d958221 100644 --- a/analysis/duplicate_attribute.d +++ b/analysis/duplicate_attribute.d @@ -90,7 +90,7 @@ class DuplicateAttributeCheck : BaseAnalyzer // Already has that attribute if (hasAttribute) { - string message = "The attribute '%s' is duplicated.".format(attributeName); + string message = "Attribute '%s' is duplicated.".format(attributeName); addErrorMessage(line, column, message); } @@ -169,25 +169,25 @@ unittest } // Duplicate before - @property @property bool aaa() // [warn]: The attribute 'property' is duplicated. + @property @property bool aaa() // [warn]: Attribute 'property' is duplicated. { return false; } // Duplicate after - bool bbb() @safe @safe // [warn]: The attribute 'safe' is duplicated. + bool bbb() @safe @safe // [warn]: Attribute 'safe' is duplicated. { return false; } // Duplicate before and after - @system bool ccc() @system // [warn]: The attribute 'system' is duplicated. + @system bool ccc() @system // [warn]: Attribute 'system' is duplicated. { return false; } // Duplicate before and after - @trusted bool ddd() @trusted // [warn]: The attribute 'trusted' is duplicated. + @trusted bool ddd() @trusted // [warn]: Attribute 'trusted' is duplicated. { return false; } @@ -200,24 +200,24 @@ unittest return false; } - pure pure bool bbb() // [warn]: The attribute 'pure' is duplicated. + pure pure bool bbb() // [warn]: Attribute 'pure' is duplicated. { return false; } // FIXME: There is no way to get the line/column number of the attribute like this - bool ccc() pure pure // FIXME: [warn]: The attribute 'pure' is duplicated. + bool ccc() pure pure // FIXME: [warn]: Attribute 'pure' is duplicated. { return false; } - nothrow nothrow bool ddd() // [warn]: The attribute 'nothrow' is duplicated. + nothrow nothrow bool ddd() // [warn]: Attribute 'nothrow' is duplicated. { return false; } // FIXME: There is no way to get the line/column number of the attribute like this - bool eee() nothrow nothrow // FIXME: [warn]: The attribute 'nothrow' is duplicated. + bool eee() nothrow nothrow // FIXME: [warn]: Attribute 'nothrow' is duplicated. { return false; } diff --git a/analysis/fish.d b/analysis/fish.d index c81fc9e..1802e8f 100644 --- a/analysis/fish.d +++ b/analysis/fish.d @@ -34,7 +34,7 @@ class FloatOperatorCheck : BaseAnalyzer || r.operator == tok!"!>=" || r.operator == tok!"!<=") { - addErrorMessage(r.line, r.column, "Avoid using the deprecated floating-point operators"); + addErrorMessage(r.line, r.column, "Avoid using the deprecated floating-point operators."); } r.accept(this); } @@ -47,14 +47,14 @@ unittest { float z = 1.5f; bool a; - a = z !<>= z; // [warn]: Avoid using the deprecated floating-point operators - a = z !<> z; // [warn]: Avoid using the deprecated floating-point operators - a = z <> z; // [warn]: Avoid using the deprecated floating-point operators - a = z <>= z; // [warn]: Avoid using the deprecated floating-point operators - a = z !> z; // [warn]: Avoid using the deprecated floating-point operators - a = z !>= z; // [warn]: Avoid using the deprecated floating-point operators - a = z !< z; // [warn]: Avoid using the deprecated floating-point operators - a = z !<= z; // [warn]: Avoid using the deprecated floating-point operators + a = z !<>= z; // [warn]: Avoid using the deprecated floating-point operators. + a = z !<> z; // [warn]: Avoid using the deprecated floating-point operators. + a = z <> z; // [warn]: Avoid using the deprecated floating-point operators. + a = z <>= z; // [warn]: Avoid using the deprecated floating-point operators. + a = z !> z; // [warn]: Avoid using the deprecated floating-point operators. + a = z !>= z; // [warn]: Avoid using the deprecated floating-point operators. + a = z !< z; // [warn]: Avoid using the deprecated floating-point operators. + a = z !<= z; // [warn]: Avoid using the deprecated floating-point operators. } }c, analysis.run.AnalyzerCheck.float_operator_check); diff --git a/analysis/ifelsesame.d b/analysis/ifelsesame.d index 078d946..c454343 100644 --- a/analysis/ifelsesame.d +++ b/analysis/ifelsesame.d @@ -29,7 +29,7 @@ class IfElseSameCheck : BaseAnalyzer { if (ifStatement.thenStatement == ifStatement.elseStatement) addErrorMessage(ifStatement.line, ifStatement.column, - "\"Else\" branch is identical to \"Then\" branch."); + "'Else' branch is identical to 'Then' branch."); ifStatement.accept(this); } @@ -40,7 +40,7 @@ class IfElseSameCheck : BaseAnalyzer && e.ternaryExpression == assignExpression.ternaryExpression) { addErrorMessage(assignExpression.line, assignExpression.column, - "Left side of assignment operatior is identical to the right side"); + "Left side of assignment operatior is identical to the right side."); } assignExpression.accept(this); } @@ -52,7 +52,7 @@ unittest void testSizeT() { string person = "unknown"; - if (person == "unknown") // [warn]: "Else" branch is identical to "Then" branch. + if (person == "unknown") // [warn]: 'Else' branch is identical to 'Then' branch. person = "bobrick"; // same else person = "bobrick"; // same diff --git a/analysis/linespan.d b/analysis/linespan.d index fd5541e..91a605a 100644 --- a/analysis/linespan.d +++ b/analysis/linespan.d @@ -76,6 +76,6 @@ unittest l.addLine(35); foreach (i; 33 .. 43) assert (l.containsLine(i)); - stderr.writeln("Unittest for LineSpans passed"); + stderr.writeln("Unittest for LineSpans passed."); } diff --git a/analysis/numbers.d b/analysis/numbers.d index 6791f92..0e16fb6 100644 --- a/analysis/numbers.d +++ b/analysis/numbers.d @@ -32,7 +32,7 @@ class NumberStyleCheck : BaseAnalyzer || !t.text.matchFirst(badDecimalRegex).empty)) { addErrorMessage(t.line, t.column, - "Use underscores to improve number constant readability"); + "Use underscores to improve number constant readability."); } } @@ -50,9 +50,9 @@ unittest a = 10; // ok a = 100; // ok a = 1000; // FIXME: boom - a = 10000; // [warn]: Use underscores to improve number constant readability - a = 100000; // [warn]: Use underscores to improve number constant readability - a = 1000000; // [warn]: Use underscores to improve number constant readability + a = 10000; // [warn]: Use underscores to improve number constant readability. + a = 100000; // [warn]: Use underscores to improve number constant readability. + a = 1000000; // [warn]: Use underscores to improve number constant readability. } }c, analysis.run.AnalyzerCheck.number_style_check); diff --git a/analysis/objectconst.d b/analysis/objectconst.d index ea4cb25..70f117a 100644 --- a/analysis/objectconst.d +++ b/analysis/objectconst.d @@ -38,8 +38,8 @@ class ObjectConstCheck : BaseAnalyzer && !hasConst(d.functionDeclaration.memberFunctionAttributes))) { addErrorMessage(d.functionDeclaration.name.line, - d.functionDeclaration.name.column, "opCmp, toHash, opEquals," - ~ " and toString should be declared const"); + d.functionDeclaration.name.column, "Methods 'opCmp', 'toHash'," + ~ " 'opEquals', and 'toString' should be declared const."); } d.accept(this); } @@ -101,22 +101,22 @@ unittest // Will warn, because none are const class Dog { - bool opEquals(Object a, Object b) // [warn]: opCmp, toHash, opEquals, and toString should be declared const + bool opEquals(Object a, Object b) // [warn]: Methods 'opCmp', 'toHash', 'opEquals', and 'toString' should be declared const. { return true; } - int opCmp(Object o) // [warn]: opCmp, toHash, opEquals, and toString should be declared const + int opCmp(Object o) // [warn]: Methods 'opCmp', 'toHash', 'opEquals', and 'toString' should be declared const. { return 1; } - hash_t toHash() // [warn]: opCmp, toHash, opEquals, and toString should be declared const + hash_t toHash() // [warn]: Methods 'opCmp', 'toHash', 'opEquals', and 'toString' should be declared const. { return 0; } - string toString() // [warn]: opCmp, toHash, opEquals, and toString should be declared const + string toString() // [warn]: Methods 'opCmp', 'toHash', 'opEquals', and 'toString' should be declared const. { return "Dog"; } diff --git a/analysis/opequals_without_tohash.d b/analysis/opequals_without_tohash.d index fe27ca1..8e844f1 100644 --- a/analysis/opequals_without_tohash.d +++ b/analysis/opequals_without_tohash.d @@ -66,13 +66,13 @@ class OpEqualsWithoutToHashCheck : BaseAnalyzer // Warn if has opEquals, but not toHash if (hasOpEquals && !hasToHash) { - string message = "Has method opEquals, but not toHash"; + string message = "Has method 'opEquals', but not 'toHash'."; addErrorMessage(name.line, name.column, message); } // Warn if has toHash, but not opEquals else if (!hasOpEquals && hasToHash) { - string message = "Has method toHash, but not opEquals"; + string message = "Has method 'toHash', but not 'opEquals'."; addErrorMessage(name.line, name.column, message); } } @@ -96,7 +96,7 @@ unittest } // Fail on class opEquals - class Rabbit // [warn]: Has method opEquals, but not toHash + class Rabbit // [warn]: Has method 'opEquals', but not 'toHash'. { const bool opEquals(Object a, Object b) { @@ -105,7 +105,7 @@ unittest } // Fail on class toHash - class Kangaroo // [warn]: Has method toHash, but not opEquals + class Kangaroo // [warn]: Has method 'toHash', but not 'opEquals'. { override const hash_t toHash() { @@ -114,7 +114,7 @@ unittest } // Fail on struct opEquals - struct Tarantula // [warn]: Has method opEquals, but not toHash + struct Tarantula // [warn]: Has method 'opEquals', but not 'toHash'. { const bool opEquals(Object a, Object b) { @@ -123,7 +123,7 @@ unittest } // Fail on struct toHash - struct Puma // [warn]: Has method toHash, but not opEquals + struct Puma // [warn]: Has method 'toHash', but not 'opEquals'. { const nothrow @safe hash_t toHash() { diff --git a/analysis/pokemon.d b/analysis/pokemon.d index 9a8bf17..7c66924 100644 --- a/analysis/pokemon.d +++ b/analysis/pokemon.d @@ -25,7 +25,7 @@ import analysis.helpers; */ class PokemonExceptionCheck : BaseAnalyzer { - enum message = "Catching Error or Throwable is almost always a bad idea"; + enum message = "Catching Error or Throwable is almost always a bad idea."; alias visit = BaseAnalyzer.visit; @@ -81,15 +81,15 @@ unittest { } - catch (Error err) // [warn]: Catching Error or Throwable is almost always a bad idea + catch (Error err) // [warn]: Catching Error or Throwable is almost always a bad idea. { } - catch (Throwable err) // [warn]: Catching Error or Throwable is almost always a bad idea + catch (Throwable err) // [warn]: Catching Error or Throwable is almost always a bad idea. { } - catch // [warn]: Catching Error or Throwable is almost always a bad idea + catch // [warn]: Catching Error or Throwable is almost always a bad idea. { } } diff --git a/analysis/style.d b/analysis/style.d index 24fd1af..66d3225 100644 --- a/analysis/style.d +++ b/analysis/style.d @@ -36,7 +36,7 @@ class StyleChecker : BaseAnalyzer { if (part.text.matchFirst(moduleNameRegex).length == 0) addErrorMessage(part.line, part.column, "Module/package name '" - ~ part.text ~ "' does not match style guidelines"); + ~ part.text ~ "' does not match style guidelines."); } } @@ -53,8 +53,8 @@ class StyleChecker : BaseAnalyzer void checkLowercaseName(string type, ref const Token name) { if (name.text.matchFirst(varFunNameRegex).length == 0) - addErrorMessage(name.line, name.column, type ~ " name " - ~ name.text ~ " does not match style guidelines"); + addErrorMessage(name.line, name.column, type ~ " name '" + ~ name.text ~ "' does not match style guidelines."); } override void visit(const ClassDeclaration dec) @@ -87,24 +87,24 @@ class StyleChecker : BaseAnalyzer { if (name.text.matchFirst(aggregateNameRegex).length == 0) addErrorMessage(name.line, name.column, aggregateType - ~ " name '" ~ name.text ~ "' does not match style guidelines"); + ~ " name '" ~ name.text ~ "' does not match style guidelines."); } } unittest { assertAnalyzerWarnings(q{ - module AMODULE; // [warn]: Module/package name 'AMODULE' does not match style guidelines + module AMODULE; // [warn]: Module/package name 'AMODULE' does not match style guidelines. bool A_VARIABLE; // FIXME: bool a_variable; // ok bool aVariable; // ok void A_FUNCTION() {} // FIXME: - class cat {} // [warn]: Class name 'cat' 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 - enum racoon {} // [warn]: Enum name 'racoon' does not match style guidelines + class cat {} // [warn]: Class name 'cat' 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. + enum racoon {} // [warn]: Enum name 'racoon' does not match style guidelines. }c, analysis.run.AnalyzerCheck.style_check); stderr.writeln("Unittest for StyleChecker passed."); diff --git a/std/d/parser.d b/std/d/parser.d index 7f10434..f626162 100644 --- a/std/d/parser.d +++ b/std/d/parser.d @@ -133,7 +133,7 @@ alias core.sys.posix.stdio.fileno fileno; assert (d !is null); assert (p.errorCount == 0); - stderr.writeln("Unittest for parseAliasDeclaration() passed."); + stderr.writeln("Unittest for parseAliasDeclaration passed."); } /** @@ -168,7 +168,7 @@ alias core.sys.posix.stdio.fileno fileno; auto initializer = p.parseAliasInitializer(); assert (initializer !is null); assert (p.errorCount == 0); - stderr.writeln("Unittest for parseAliasInitializer() passed."); + stderr.writeln("Unittest for parseAliasInitializer passed."); } /** @@ -197,7 +197,7 @@ alias core.sys.posix.stdio.fileno fileno; auto aliasThis = p.parseAliasThisDeclaration(); assert (aliasThis !is null); assert (p.errorCount == 0); - stderr.writeln("Unittest for parseAliasThisDeclaration() passed."); + stderr.writeln("Unittest for parseAliasThisDeclaration passed."); } /** @@ -231,7 +231,7 @@ alias core.sys.posix.stdio.fileno fileno; attribute = p.parseAlignAttribute(); assert (attribute !is null); assert (p.errorCount == 0); - stderr.writeln("Unittest for parseAlignAttribute() passed."); + stderr.writeln("Unittest for parseAlignAttribute passed."); } /** @@ -1146,7 +1146,7 @@ incorrect; assert (nine is null); assert (p.errorCount > 0); - stderr.writeln("Unittest for parseCastQualifier() passed."); + stderr.writeln("Unittest for parseCastQualifier passed."); } /** @@ -1298,7 +1298,7 @@ class ClassFive(A, B) : Super if (someTest()) {}}c; assert (classFour.structBody.declarations.length == 0, to!string(classFour.structBody.declarations.length)); - stderr.writeln("Unittest for parseClassDeclaration() passed."); + stderr.writeln("Unittest for parseClassDeclaration passed."); } /** @@ -2027,7 +2027,7 @@ class ClassFive(A, B) : Super if (someTest()) {}}c; assert (d !is null); assert (d.functionBody !is null); assert (p.errorCount == 0); - stderr.writeln("Unittest for parseDestructor() passed."); + stderr.writeln("Unittest for parseDestructor passed."); } /** @@ -2486,7 +2486,7 @@ body {} // six assert (functionBodySix.outStatement is null); assert (functionBodySix.bodyStatement !is null); - stderr.writeln("Unittest for parseFunctionBody() passed."); + stderr.writeln("Unittest for parseFunctionBody passed."); } /** @@ -3025,7 +3025,7 @@ import core.stdc.stdio, std.string : KeepTerminator; assert (seven.importBindings !is null); assert (p.errorCount == 0); - stderr.writeln("Unittest for parseImportDeclaration() passed."); + stderr.writeln("Unittest for parseImportDeclaration passed."); } /** @@ -3216,7 +3216,7 @@ interface "Four" assert (four is null); assert (p.errorCount > 0); - stderr.writeln("Unittest for parseInterfaceDeclaration() passed."); + stderr.writeln("Unittest for parseInterfaceDeclaration passed."); } /** @@ -4134,7 +4134,7 @@ q{(int a, ...) assert (!params3.parameters[0].vararg); assert (params3.parameters[0].type !is null); - stderr.writeln("Unittest for parseParameters() passed."); + stderr.writeln("Unittest for parseParameters passed."); } /** @@ -6067,7 +6067,7 @@ q{doStuff(5)}c; auto unary = p.parseUnaryExpression(); assert (unary !is null); assert (unary.functionCallExpression !is null); - stderr.writeln("Unittest for parseUnaryExpression() passed."); + stderr.writeln("Unittest for parseUnaryExpression passed."); } /**