Small cleanup of style and junk comments.
This commit is contained in:
parent
34b312b45e
commit
ed188ee9be
|
@ -59,3 +59,4 @@ protected:
|
|||
|
||||
MessageSet _messages;
|
||||
}
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ import analysis.helpers;
|
|||
|
||||
|
||||
/**
|
||||
* Checks for duplicate attributes such as @property, @safe,
|
||||
* Checks for duplicate attributes such as @property, @safe,
|
||||
* @trusted, @system, pure, and nothrow
|
||||
*/
|
||||
class DuplicateAttributeCheck : BaseAnalyzer
|
||||
|
|
|
@ -59,3 +59,4 @@ class EnumArrayLiteralCheck : BaseAnalyzer
|
|||
autoDec.accept(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -44,7 +44,7 @@ S after(S)(S value, S separator)
|
|||
}
|
||||
|
||||
/**
|
||||
* This assert function will analyze the passed in code, get the warnings,
|
||||
* This assert function will analyze the passed in code, get the warnings,
|
||||
* and make sure they match the warnings in the comments. Warnings are
|
||||
* marked like so: // [warn]: Failed to do somethings.
|
||||
*/
|
||||
|
@ -100,8 +100,8 @@ void assertAnalyzerWarnings(string code, analysis.run.AnalyzerCheck analyzers, s
|
|||
if (lineNo !in warnings)
|
||||
{
|
||||
string errors = "Expected warning:\n%s\nFrom source code at (%s:?):\n%s".format(
|
||||
messages[lineNo],
|
||||
lineNo,
|
||||
messages[lineNo],
|
||||
lineNo,
|
||||
codeLines[lineNo - line]
|
||||
);
|
||||
throw new core.exception.AssertError(errors, file, lineNo);
|
||||
|
@ -110,9 +110,9 @@ void assertAnalyzerWarnings(string code, analysis.run.AnalyzerCheck analyzers, s
|
|||
else if (warnings[lineNo] != messages[lineNo])
|
||||
{
|
||||
string errors = "Expected warning:\n%s\nBut was:\n%s\nFrom source code at (%s:?):\n%s".format(
|
||||
messages[lineNo],
|
||||
warnings[lineNo],
|
||||
lineNo,
|
||||
messages[lineNo],
|
||||
warnings[lineNo],
|
||||
lineNo,
|
||||
codeLines[lineNo - line]
|
||||
);
|
||||
throw new core.exception.AssertError(errors, file, lineNo);
|
||||
|
@ -127,8 +127,8 @@ void assertAnalyzerWarnings(string code, analysis.run.AnalyzerCheck analyzers, s
|
|||
if (lineNo !in messages)
|
||||
{
|
||||
unexpectedWarnings ~= "%s\nFrom source code at (%s:?):\n%s".format(
|
||||
warning,
|
||||
lineNo,
|
||||
warning,
|
||||
lineNo,
|
||||
codeLines[lineNo - line]
|
||||
);
|
||||
}
|
||||
|
@ -140,4 +140,3 @@ void assertAnalyzerWarnings(string code, analysis.run.AnalyzerCheck analyzers, s
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -52,24 +52,17 @@ 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
|
||||
}
|
||||
|
||||
if(person == "unknown") // ok
|
||||
{
|
||||
if (person == "unknown") // ok
|
||||
person = "ricky"; // not same
|
||||
}
|
||||
else
|
||||
{
|
||||
person = "bobby"; // not same
|
||||
}
|
||||
}
|
||||
}c, analysis.run.AnalyzerCheck.if_else_same_check);
|
||||
stderr.writeln("Unittest for IfElseSameCheck passed.");
|
||||
}
|
||||
|
||||
|
|
|
@ -58,3 +58,4 @@ unittest
|
|||
|
||||
stderr.writeln("Unittest for NumberStyleCheck passed.");
|
||||
}
|
||||
|
||||
|
|
|
@ -116,7 +116,7 @@ unittest
|
|||
return 0;
|
||||
}
|
||||
|
||||
string toString()// [warn]: opCmp, toHash, opEquals, and toString should be declared const
|
||||
string toString() // [warn]: opCmp, toHash, opEquals, and toString should be declared const
|
||||
{
|
||||
return "Dog";
|
||||
}
|
||||
|
|
|
@ -4,3 +4,4 @@ public import analysis.style;
|
|||
public import analysis.enumarrayliteral;
|
||||
public import analysis.pokemon;
|
||||
public import analysis.base;
|
||||
|
||||
|
|
|
@ -73,19 +73,19 @@ unittest
|
|||
{
|
||||
// ...
|
||||
}
|
||||
catch(AssertError err) //ok
|
||||
catch (AssertError err) //ok
|
||||
{
|
||||
|
||||
}
|
||||
catch(Exception err) // ok
|
||||
catch (Exception err) // ok
|
||||
{
|
||||
|
||||
}
|
||||
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
|
||||
{
|
||||
|
||||
}
|
||||
|
@ -97,3 +97,4 @@ unittest
|
|||
|
||||
stderr.writeln("Unittest for PokemonExceptionCheck passed.");
|
||||
}
|
||||
|
||||
|
|
|
@ -139,8 +139,8 @@ unittest
|
|||
data = data[1 .. 3]; // ok
|
||||
data = data[3 .. 1]; // [warn]: 3 is larger than 1. This slice is likely incorrect.
|
||||
|
||||
foreach(n; 1 .. 3) { } // ok
|
||||
foreach(n; 3 .. 1) { } // [warn]: 3 is larger than 1. Did you mean to use 'foreach_reverse( ... ; 1 .. 3)'?
|
||||
foreach (n; 1 .. 3) { } // ok
|
||||
foreach (n; 3 .. 1) { } // [warn]: 3 is larger than 1. Did you mean to use 'foreach_reverse( ... ; 1 .. 3)'?
|
||||
}
|
||||
}c, analysis.run.AnalyzerCheck.backwards_range_check);
|
||||
|
||||
|
|
|
@ -114,7 +114,7 @@ string[] analyze(string fileName, ubyte[] code, AnalyzerCheck analyzers, bool st
|
|||
}
|
||||
|
||||
MessageSet set = new MessageSet;
|
||||
foreach(check; checks)
|
||||
foreach (check; checks)
|
||||
foreach (message; check.messages)
|
||||
set.insert(message);
|
||||
|
||||
|
|
|
@ -335,3 +335,4 @@ class UnusedVariableCheck : BaseAnalyzer
|
|||
|
||||
bool blockStatementIntroducesScope = true;
|
||||
}
|
||||
|
||||
|
|
|
@ -1519,3 +1519,4 @@ class XMLPrinter : ASTVisitor
|
|||
|
||||
File output;
|
||||
}
|
||||
|
||||
|
|
1
ctags.d
1
ctags.d
|
@ -168,3 +168,4 @@ class CTagsPrinter : ASTVisitor
|
|||
int suppressDepth;
|
||||
string context;
|
||||
}
|
||||
|
||||
|
|
|
@ -343,7 +343,7 @@ class Formatter(Sink)
|
|||
void format(const IdentifierChain identifierChain)
|
||||
{
|
||||
bool first = true;
|
||||
foreach(ident; identifierChain.identifiers)
|
||||
foreach (ident; identifierChain.identifiers)
|
||||
{
|
||||
if (!first)
|
||||
sink.put(".");
|
||||
|
@ -358,7 +358,7 @@ class Formatter(Sink)
|
|||
void format(const IdentifierOrTemplateChain identifierOrTemplateChain)
|
||||
{
|
||||
bool first = true;
|
||||
foreach(ident; identifierOrTemplateChain.identifiersOrTemplateInstances)
|
||||
foreach (ident; identifierOrTemplateChain.identifiersOrTemplateInstances)
|
||||
{
|
||||
if (!first)
|
||||
sink.put(".");
|
||||
|
@ -832,3 +832,4 @@ private:
|
|||
IndentStyle style;
|
||||
Sink sink;
|
||||
}
|
||||
|
||||
|
|
|
@ -53,7 +53,7 @@ html { background-color: #fdf6e3; color: #002b36; }
|
|||
writeSpan("cons", t.text.replace("<", "<"));
|
||||
else
|
||||
{
|
||||
version(Windows)
|
||||
version (Windows)
|
||||
{
|
||||
// Stupid Windows automatically does a LF → CRLF, so
|
||||
// CRLF → CRCRLF, which is obviously wrong.
|
||||
|
@ -70,8 +70,9 @@ html { background-color: #fdf6e3; color: #002b36; }
|
|||
|
||||
void writeSpan(string cssClass, string value)
|
||||
{
|
||||
version(Windows)
|
||||
version (Windows)
|
||||
stdout.write(`<span class="`, cssClass, `">`, value.replace("&", "&").replace("<", "<").replace("\r", ""), `</span>`);
|
||||
else
|
||||
stdout.write(`<span class="`, cssClass, `">`, value.replace("&", "&").replace("<", "<"), `</span>`);
|
||||
}
|
||||
|
||||
|
|
3
stats.d
3
stats.d
|
@ -11,7 +11,7 @@ import std.d.lexer;
|
|||
|
||||
pure nothrow bool isLineOfCode(IdType t)
|
||||
{
|
||||
switch(t)
|
||||
switch (t)
|
||||
{
|
||||
case tok!";":
|
||||
case tok!"while":
|
||||
|
@ -52,3 +52,4 @@ ulong printLineCount(Tokens)(File output, string fileName, ref Tokens tokens)
|
|||
output.writefln("%s:\t%d", fileName, count);
|
||||
return count;
|
||||
}
|
||||
|
||||
|
|
|
@ -4614,3 +4614,4 @@ version(none) struct TemplateAllocator
|
|||
}
|
||||
static shared TemplateAllocator it;
|
||||
}
|
||||
|
||||
|
|
|
@ -2147,3 +2147,4 @@ immutable HtmlEntity[] characterEntities = [
|
|||
HtmlEntity("zwj", "\u200D"),
|
||||
HtmlEntity("zwnj", "\u200C")
|
||||
];
|
||||
|
||||
|
|
|
@ -1199,9 +1199,9 @@ public struct DLexer
|
|||
Token lexTokenString() pure
|
||||
{
|
||||
mixin (tokenStart);
|
||||
assert(range.front == 'q');
|
||||
assert (range.front == 'q');
|
||||
range.popFront();
|
||||
assert(range.front == '{');
|
||||
assert (range.front == '{');
|
||||
range.popFront();
|
||||
auto app = appender!string();
|
||||
app.put("q{");
|
||||
|
@ -1679,7 +1679,7 @@ public:
|
|||
free(cast(void*) prev.bytes.ptr);
|
||||
free(cast(void*) prev);
|
||||
}
|
||||
foreach(nodePointer; buckets)
|
||||
foreach (nodePointer; buckets)
|
||||
{
|
||||
Node* currentNode = nodePointer;
|
||||
while (currentNode !is null)
|
||||
|
@ -1956,15 +1956,16 @@ unittest
|
|||
// valid
|
||||
enum hex = ['0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f','A','B','C','D','E','F'];
|
||||
auto source = "";
|
||||
foreach(h1; hex)
|
||||
foreach(h2; hex)
|
||||
foreach (h1; hex)
|
||||
foreach (h2; hex)
|
||||
source ~= "'\\x" ~ h1 ~ h2 ~ "'";
|
||||
assert(toks(source).filter!(t => t.type != tok!"characterLiteral").empty);
|
||||
assert (toks(source).filter!(t => t.type != tok!"characterLiteral").empty);
|
||||
|
||||
// invalid
|
||||
assert(toks(`'\x'`).messages[0] == DLexer.Message(1,4,"Error: 2 hex digits expected.",true));
|
||||
assert(toks(`'\x_'`).messages[0] == DLexer.Message(1,4,"Error: 2 hex digits expected.",true));
|
||||
assert(toks(`'\xA'`).messages[0] == DLexer.Message(1,5,"Error: 2 hex digits expected.",true));
|
||||
assert(toks(`'\xAY'`).messages[0] == DLexer.Message(1,5,"Error: 2 hex digits expected.",true));
|
||||
assert(toks(`'\xXX'`).messages[0] == DLexer.Message(1,4,"Error: 2 hex digits expected.",true));
|
||||
assert (toks(`'\x'`).messages[0] == DLexer.Message(1,4,"Error: 2 hex digits expected.",true));
|
||||
assert (toks(`'\x_'`).messages[0] == DLexer.Message(1,4,"Error: 2 hex digits expected.",true));
|
||||
assert (toks(`'\xA'`).messages[0] == DLexer.Message(1,5,"Error: 2 hex digits expected.",true));
|
||||
assert (toks(`'\xAY'`).messages[0] == DLexer.Message(1,5,"Error: 2 hex digits expected.",true));
|
||||
assert (toks(`'\xXX'`).messages[0] == DLexer.Message(1,4,"Error: 2 hex digits expected.",true));
|
||||
}
|
||||
|
||||
|
|
|
@ -1259,7 +1259,7 @@ class ClassFive(A, B) : Super if (someTest()) {}}c;
|
|||
assert (classZero.structBody is null);
|
||||
|
||||
auto classOne = p.parseClassDeclaration();
|
||||
assert (classOne.name.text == "ClassOne"); // FIXME classOne.name.text is "ClassZero" on my machine TM
|
||||
assert (classOne.name.text == "ClassOne");
|
||||
assert (classOne.structBody.declarations.length == 0);
|
||||
assert (classOne.baseClassList is null);
|
||||
assert (classOne.constraint is null);
|
||||
|
@ -1412,7 +1412,7 @@ class ClassFive(A, B) : Super if (someTest()) {}}c;
|
|||
trueDeclarations ~= dec;
|
||||
node.trueDeclarations = ownArray(trueDeclarations);
|
||||
|
||||
if(currentIs(tok!"else"))
|
||||
if (currentIs(tok!"else"))
|
||||
advance();
|
||||
else
|
||||
return node;
|
||||
|
@ -1491,7 +1491,7 @@ class ClassFive(A, B) : Super if (someTest()) {}}c;
|
|||
if (node.parameters is null) return null;
|
||||
|
||||
MemberFunctionAttribute[] memberFunctionAttributes;
|
||||
while(moreTokens() && currentIsMemberFunctionAttribute())
|
||||
while (moreTokens() && currentIsMemberFunctionAttribute())
|
||||
memberFunctionAttributes ~= parseMemberFunctionAttribute();
|
||||
node.memberFunctionAttributes = ownArray(memberFunctionAttributes);
|
||||
|
||||
|
@ -1995,7 +1995,7 @@ class ClassFive(A, B) : Super if (someTest()) {}}c;
|
|||
else
|
||||
{
|
||||
MemberFunctionAttribute[] memberFunctionAttributes;
|
||||
while(moreTokens() && currentIsMemberFunctionAttribute())
|
||||
while (moreTokens() && currentIsMemberFunctionAttribute())
|
||||
memberFunctionAttributes ~= parseMemberFunctionAttribute();
|
||||
node.memberFunctionAttributes = ownArray(memberFunctionAttributes);
|
||||
node.functionBody = parseFunctionBody();
|
||||
|
@ -2544,7 +2544,7 @@ body {} // six
|
|||
if (isAuto)
|
||||
goto functionName;
|
||||
|
||||
while(moreTokens() && currentIsMemberFunctionAttribute())
|
||||
while (moreTokens() && currentIsMemberFunctionAttribute())
|
||||
memberFunctionAttributes ~= parseMemberFunctionAttribute();
|
||||
|
||||
node.returnType = type is null ? parseType() : type;
|
||||
|
@ -2571,7 +2571,7 @@ body {} // six
|
|||
node.parameters = parseParameters();
|
||||
if (node.parameters is null) return null;
|
||||
|
||||
while(moreTokens() && currentIsMemberFunctionAttribute())
|
||||
while (moreTokens() && currentIsMemberFunctionAttribute())
|
||||
memberFunctionAttributes ~= parseMemberFunctionAttribute();
|
||||
|
||||
if (isTemplate && currentIs(tok!"if"))
|
||||
|
@ -3434,7 +3434,7 @@ invariant() foo();
|
|||
{
|
||||
advance();
|
||||
node.hasPlusPlus = true;
|
||||
version(DIP61) if (currentIs(tok!","))
|
||||
version (DIP61) if (currentIs(tok!","))
|
||||
{
|
||||
advance();
|
||||
node.identifierChain = parseIdentifierChain();
|
||||
|
@ -5226,7 +5226,7 @@ q{(int a, ...)
|
|||
node.templateAliasParameter = parseTemplateAliasParameter();
|
||||
break;
|
||||
case tok!"identifier":
|
||||
if(peekIs(tok!"..."))
|
||||
if (peekIs(tok!"..."))
|
||||
node.templateTupleParameter = parseTemplateTupleParameter();
|
||||
else if (peekIsOneOf(tok!":", tok!"=", tok!",", tok!")"))
|
||||
node.templateTypeParameter = parseTemplateTypeParameter();
|
||||
|
@ -5536,7 +5536,7 @@ q{(int a, ...)
|
|||
{
|
||||
mixin(traceEnterAndExit!(__FUNCTION__));
|
||||
auto node = allocate!Type;
|
||||
switch(current.type)
|
||||
switch (current.type)
|
||||
{
|
||||
case tok!"const":
|
||||
case tok!"immutable":
|
||||
|
@ -5753,7 +5753,7 @@ q{(int a, ...)
|
|||
{
|
||||
mixin(traceEnterAndExit!(__FUNCTION__));
|
||||
auto node = allocate!TypeSuffix;
|
||||
switch(current.type)
|
||||
switch (current.type)
|
||||
{
|
||||
case tok!"*":
|
||||
node.star = true;
|
||||
|
@ -6100,7 +6100,7 @@ q{doStuff(5)}c;
|
|||
node.comment = comment;
|
||||
|
||||
Declarator[] declarators;
|
||||
while(true)
|
||||
while (true)
|
||||
{
|
||||
auto declarator = parseDeclarator();
|
||||
if (declarator is null) return null;
|
||||
|
@ -6344,7 +6344,7 @@ protected:
|
|||
mixin(traceEnterAndExit!(__FUNCTION__));
|
||||
auto i = index;
|
||||
scope(exit) index = i;
|
||||
assert(currentIs(L));
|
||||
assert (currentIs(L));
|
||||
advance();
|
||||
while (moreTokens()) switch (current.type)
|
||||
{
|
||||
|
@ -6685,7 +6685,7 @@ protected:
|
|||
|
||||
void skip(alias O, alias C)()
|
||||
{
|
||||
assert(currentIs(O), current().text);
|
||||
assert (currentIs(O), current().text);
|
||||
advance();
|
||||
int depth = 1;
|
||||
while (moreTokens())
|
||||
|
@ -7018,3 +7018,4 @@ protected:
|
|||
int _traceDepth;
|
||||
string comment;
|
||||
}
|
||||
|
||||
|
|
|
@ -173,9 +173,9 @@ unittest
|
|||
enum tok(string token) = TokenId!(IdType, ["foo"], ["bar"], ["doo"], token);
|
||||
alias str = tokenStringRepresentation!(IdType, ["foo"], ["bar"], ["doo"]);
|
||||
|
||||
static assert(str(tok!"foo") == "foo");
|
||||
static assert(str(tok!"bar") == "bar");
|
||||
static assert(str(tok!"doo") == "doo");
|
||||
static assert (str(tok!"foo") == "foo");
|
||||
static assert (str(tok!"bar") == "bar");
|
||||
static assert (str(tok!"doo") == "doo");
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -772,3 +772,4 @@ struct LexerRange
|
|||
*/
|
||||
size_t line;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue