Skip to content
Snippets Groups Projects
Commit eed5c5df authored by Michael Hanselmann's avatar Michael Hanselmann
Browse files

Check for tabs and long lines in Python code


Signed-off-by: default avatarMichael Hanselmann <hansmi@google.com>
Reviewed-by: default avatarGuido Trotter <ultrotter@google.com>
parent 88258349
No related branches found
No related tags found
No related merge requests found
......@@ -13,6 +13,7 @@ ACLOCAL_AMFLAGS = -I autotools
DOCBOOK_WRAPPER = $(top_srcdir)/autotools/docbook-wrapper
BUILD_BASH_COMPLETION = $(top_srcdir)/autotools/build-bash-completion
RUN_IN_TEMPDIR = $(top_srcdir)/autotools/run-in-tempdir
CHECK_PYTHON_CODE = $(top_srcdir)/autotools/check-python-code
REPLACE_VARS_SED = autotools/replace_vars.sed
hypervisordir = $(pkgpythondir)/hypervisor
......@@ -195,6 +196,7 @@ EXTRA_DIST = \
DEVNOTES \
pylintrc \
autotools/build-bash-completion \
autotools/check-python-code \
autotools/docbook-wrapper \
autotools/run-in-tempdir \
daemons/ganeti-cleaner.in \
......@@ -280,8 +282,7 @@ TESTS_ENVIRONMENT = \
PYTHONPATH=. TOP_SRCDIR=$(abs_top_srcdir) \
$(RUN_IN_TEMPDIR) $(PYTHON)
srclink_files = \
man/footer.sgml \
all_python_code = \
$(dist_sbin_SCRIPTS) \
$(dist_tools_SCRIPTS) \
$(dist_TESTS) \
......@@ -292,6 +293,13 @@ srclink_files = \
$(confd_PYTHON) \
$(noinst_PYTHON)
srclink_files = \
man/footer.sgml \
$(all_python_code)
check_python_code = \
$(all_python_code)
all-local: stamp-directories devel/upload \
doc/examples/bash_completion \
doc/examples/ganeti.initd doc/examples/ganeti.cron \
......@@ -403,6 +411,9 @@ srclinks: stamp-directories
ganeti:
cd $(top_builddir) && test -h "$@" || { rm -f $@ && $(LN_S) lib $@; }
check-local:
$(CHECK_PYTHON_CODE) $(check_python_code)
# a dist hook rule for catching revision control directories
distcheck-hook:
if find $(top_distdir) | grep -F -e '.svn' -e '.git'; then \
......
#!/bin/bash
#
# Copyright (C) 2009 Google Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301, USA.
let problems=0
for script; do
if grep -H -F $'\t' "$script"; then
let ++problems
echo "Found tabs in $script" >&2
fi
if [[ "$(wc --max-line-length < "$script")" -gt 80 ]]; then
let ++problems
echo "Longest line in $script is longer than 80 characters" >&2
fi
done
if [[ "$problems" -gt 0 ]]; then
echo "Found $problems problems while checking code." >&2
exit 1
fi
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment