Module: check_mk
Branch: master
Commit: ef38929cc70c4c5ab0408cb4a0999c92c2c01385
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=ef38929cc70c4c…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Tue Mar 1 15:04:25 2011 +0100
validator: added new check for catching development debug statements like prints
---
doc/helpers/validate_checks | 22 ++++++++++++++++++++++
1 files changed, 22 insertions(+), 0 deletions(-)
diff --git a/doc/helpers/validate_checks b/doc/helpers/validate_checks
index 68bba37..2aa0978 100755
--- a/doc/helpers/validate_checks
+++ b/doc/helpers/validate_checks
@@ -163,6 +163,7 @@ TESTS = {
'reindent': C_OK,
'global_vars': C_OK,
'linelength': C_OK,
+ 'debug': C_OK,
}
WEIGHT = {
@@ -170,6 +171,7 @@ WEIGHT = {
'global_vars': 2,
'reindent': 2,
'linelength': 2,
+ 'debug': 10,
}
manpage = {}
@@ -227,6 +229,26 @@ def verify_reindent(check):
f.close()
return not r.run()
+# Debug:
+# - are there 'print' statements in the code?
+# - are there 'sys.*.write' statements?
+
+def is_valid_debug(check):
+ return True
+
+def verify_debug(check):
+ f = open('checks/%s' % check.split('.')[0])
+ for l in f.read().split("\n"):
+ l = l.strip()
+ if l.startswith('print ') or l.startswith('print('):
+ return False
+ elif l.startswith('sys.stdout.write'):
+ return False
+ elif l.startswith('sys.stderr.write'):
+ return False
+ f.close()
+ return True
+
# Toooo long lines:
# - Are there too long lines in the check?