2008-12-17 23:27:38 +03:00
#!/bin/sh
# pylint doesn't work well with a file named xxx.py.xxx
cp src/virt-manager.py.in src/_virt-manager
cd src || exit 1
IGNOREFILES = "IPy.py"
FILES = "virtManager/ _virt-manager"
# Deliberately ignored warnings:
# Don't print pylint config warning
NO_PYL_CONFIG = ".*No config file found.*"
# The gettext function is installed in the builtin namespace
GETTEXT_VAR = "Undefined variable '_'"
# These all work fine and are legit, just false positives
GOBJECT_VAR = "has no '__gobject_init__' member"
2009-05-11 18:13:32 +04:00
GOBJECT_INIT = "__init__ method from base class 'GObject' is not called"
2008-12-17 23:27:38 +03:00
EMIT_VAR = "has no 'emit' member"
2009-10-29 03:35:13 +03:00
ERROR_VBOX = "Class 'vbox' has no 'pack_start' member"
2008-12-17 23:27:38 +03:00
EXCEPTHOOK = "no '__excepthook__' member"
CONNECT_VAR = "no 'connect' member"
2009-03-09 23:19:39 +03:00
DISCONNECT_VAR = "no 'disconnect' member"
2010-05-06 00:16:15 +04:00
UNABLE_IMPORT = "Unable to import '(gtk.gdk.*|sparkline|appindicator)"
2008-12-17 23:27:38 +03:00
# os._exit is needed for forked processes.
OS_EXIT = "protected member _exit of a client class"
# Avahi API may have requirements on callback argument names, so ignore these
# warnings
BTYPE_LIST = "(vmmConnect.add_service|vmmConnect.remove_service|vmmConnect.add_conn_to_list)"
BUILTIN_TYPE = " ${ BTYPE_LIST } .*Redefining built-in 'type' "
2010-11-30 01:28:52 +03:00
# Types can't be inferred errors
INFER_LIST = "(MenuItem|StatusIcon)"
INFER_ERRORS = " Instance of ' ${ INFER_LIST } '.*not be inferred "
2008-12-17 23:27:38 +03:00
DMSG = ""
addmsg( ) {
DMSG = " ${ DMSG } , $1 "
}
addchecker( ) {
DCHECKERS = " ${ DCHECKERS } , $1 "
}
2009-10-29 03:20:14 +03:00
addmsg_support( ) {
2010-11-30 01:28:52 +03:00
out = ` pylint --list-msgs 2>& 1`
2010-01-27 21:47:53 +03:00
if ` echo $out | grep -q $1 ` ; then
2009-10-29 03:20:14 +03:00
addmsg " $1 "
fi
}
2008-12-17 23:27:38 +03:00
# Disabled unwanted messages
addmsg "C0103" # C0103: Name doesn't match some style regex
addmsg "C0111" # C0111: No docstring
addmsg "C0301" # C0301: Line too long
addmsg "C0302" # C0302: Too many lines in module
addmsg "R0201" # R0201: Method could be a function
addmsg "W0141" # W0141: Complaining about 'map' and 'filter'
addmsg "W0142" # W0142: *Used * or ** magic*
addmsg "W0403" # W0403: Relative imports
addmsg "W0603" # W0603: Using the global statement
addmsg "W0702" # W0703: No exception type specified
addmsg "W0703" # W0703: Catch 'Exception'
addmsg "W0704" # W0704: Exception doesn't do anything
# Potentially useful messages, disabled for now
addmsg "W0511" # W0511: FIXME and XXX: messages
addmsg "W0613" # W0613: Unused arguments
2009-10-29 03:20:14 +03:00
addmsg_support "W6501" # W6501: Using string formatters in logging message
# (see help message for info)
2008-12-17 23:27:38 +03:00
# Disabled Checkers:
addchecker "Design" # Things like "Too many func arguments",
# "Too man public methods"
addchecker "Similarities" # Finds duplicate code (enable this later?)
# May want to enable this in the future
SHOW_REPORT = "n"
AWK = awk
[ ` uname -s` = 'SunOS' ] && AWK = nawk
2010-11-30 01:28:52 +03:00
pylint --ignore= $IGNOREFILES $FILES \
2008-12-17 23:27:38 +03:00
--reports= $SHOW_REPORT \
--output-format= colorized \
--dummy-variables-rgx= "dummy|ignore*" \
2010-11-12 00:29:30 +03:00
--disable= ${ DMSG } \
--disable= ${ DCHECKERS } 2>& 1 | \
2008-12-17 23:27:38 +03:00
egrep -ve " $NO_PYL_CONFIG " \
-ve " $GOBJECT_VAR " \
2009-05-11 18:13:32 +04:00
-ve " $GOBJECT_INIT " \
2008-12-17 23:27:38 +03:00
-ve " $EMIT_VAR " \
-ve " $CONNECT_VAR " \
2009-03-09 23:19:39 +03:00
-ve " $DISCONNECT_VAR " \
2008-12-17 23:27:38 +03:00
-ve " $GETTEXT_VAR " \
-ve " $OS_EXIT " \
-ve " $BUILTIN_TYPE " \
-ve " $ERROR_VBOX " \
2009-05-11 18:13:32 +04:00
-ve " $UNABLE_IMPORT " \
2010-11-30 01:28:52 +03:00
-ve " $INFER_ERRORS " \
2008-12-17 23:27:38 +03:00
-ve " $EXCEPTHOOK " | \
$AWK ' \
# Strip out any "*** Module name" lines if we dont list any errors for them
BEGIN { found = 0; cur_line = "" }
{
if ( found = = 1) {
if ( /\* \* \* / ) {
prev_line = $0
} else {
print prev_line
print $0
found = 0
}
} else if ( /\* \* \* / ) {
found = 1
prev_line = $0
} else {
print $0
}
} '
cd - > /dev/null
rm src/_virt-manager