diff vera/rules/T018.tcl @ 510:6ec510722582

CMake: enable vera++ as code checking, closes #603
author David Demelier <markand@malikania.fr>
date Thu, 19 Oct 2017 13:01:39 +0200
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/vera/rules/T018.tcl	Thu Oct 19 13:01:39 2017 +0200
@@ -0,0 +1,23 @@
+#!/usr/bin/tclsh
+# using namespace are not allowed in header files
+
+foreach fileName [getSourceFileNames] {
+    set extension [file extension $fileName]
+    if {[lsearch {.h .hh .hpp .hxx .ipp} $extension] != -1} {
+
+        set state "start"
+        foreach token [getTokens $fileName 1 0 -1 -1 {using namespace identifier}] {
+            set type [lindex $token 3]
+
+            if {$state == "using" && $type == "namespace"} {
+                report $fileName $usingLine "using namespace not allowed in header file"
+            }
+
+            if {$type == "using"} {
+                set usingLine [lindex $token 1]
+            }
+
+            set state $type
+        }
+    }
+}