From ff37192e945c9083d313ddc8924ef433e193f9c7 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Mon, 4 Aug 2014 12:03:37 +0200 Subject: BasicStyleCheck: Dividers are exactly 80 slashes. --- src/CheckBasicStyle.lua | 18 +++++++++++++++++- src/Mobs/Enderman.cpp | 2 +- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/CheckBasicStyle.lua b/src/CheckBasicStyle.lua index 13a6d15d2..c743a84a5 100644 --- a/src/CheckBasicStyle.lua +++ b/src/CheckBasicStyle.lua @@ -10,11 +10,12 @@ Checks that all source files (*.cpp, *.h) use the basic style requirements of th - Spaces after comma, not before - Opening braces not at the end of a code line - Spaces after if, for, while + - Line dividers (////...) exactly 80 slashes - (TODO) Spaces before *, /, & - (TODO) Hex numbers with even digit length - (TODO) Hex numbers in lowercase - - (TODO) Line dividers (////...) exactly 80 slashes - (TODO) Not using "* "-style doxy comment continuation lines + - (TODO) Multi-level indent change Violations that cannot be checked easily: - Spaces around "+" (there are things like "a++", "++a", "a += 1", "X+", "stack +1" and ascii-drawn tables) @@ -165,6 +166,21 @@ local function ProcessFile(a_FileName) for _, pat in ipairs(g_ViolationPatterns) do ReportViolationIfFound(a_Line, a_FileName, lineCounter, pat[1], pat[2]) end + + local dividerStart, dividerEnd = a_Line:find("/////*") + if (dividerStart) then + if (dividerEnd ~= dividerStart + 79) then + ReportViolation(a_FileName, lineCounter, 1, 80, "Divider comment should have exactly 80 slashes") + end + if (dividerStart > 1) then + if ( + (a_Line:sub(1, dividerStart - 1) ~= string.rep("\t", dividerStart - 1)) or -- The divider should have only indent in front of it + (a_Line:len() > dividerEnd + 1) -- The divider should have no other text following it + ) then + ReportViolation(a_FileName, lineCounter, 1, 80, "Divider comment shouldn't have any extra text around it") + end + end + end lineCounter = lineCounter + 1 end diff --git a/src/Mobs/Enderman.cpp b/src/Mobs/Enderman.cpp index 0a1b6491a..51255beb3 100644 --- a/src/Mobs/Enderman.cpp +++ b/src/Mobs/Enderman.cpp @@ -8,7 +8,7 @@ -/////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cPlayerLookCheck class cPlayerLookCheck : public cPlayerListCallback -- cgit v1.2.3