From 9d2275763919023653fabcac9db720e60630472c Mon Sep 17 00:00:00 2001 From: Florian Fischer Date: Mon, 11 May 2020 12:10:39 +0200 Subject: Makefile: add new pylint check-target which fails on errors and warnings --- Makefile | 13 ++++++++----- tools/check-pylint | 20 ++++++++++++++++++++ 2 files changed, 28 insertions(+), 5 deletions(-) create mode 100755 tools/check-pylint diff --git a/Makefile b/Makefile index 662d3e8..67f0d42 100644 --- a/Makefile +++ b/Makefile @@ -20,7 +20,7 @@ export CXXFLAGS = -std=c++11 $(CFLAGS) -fno-exceptions export LDFLAGS = -pthread -static-libgcc export LDXXFLAGS = $(LDFLAGS) -static-libstdc++ -.PHONY: all clean pylint yapf tags check $(MAKEFILES) $(CMAKELISTS) +.PHONY: all clean pylint format tags check check-format check-pylint $(MAKEFILES) $(CMAKELISTS) all: $(OBJDIR)/ccinfo $(MAKEFILES) $(CMAKELISTS) $(CMAKELISTS): @@ -47,13 +47,16 @@ $(OBJDIR): clean: rm -rf $(OBJDIR) -pylint: - pylint $(PYTHONFILES) +check-pylint: + pylint -j 0 $(PYTHONFILES) || ./tools/check-pylint -yapf: +format: yapf -i $(PYTHONFILES) +check-format: + yapf -q -d $(PYTHONFILES) + tags: ctags -R --exclude="build/*" --exclude="cache/*" --exclude="doc/*" --exclude="results/*" -check: pylint +check: check-pylint check-format diff --git a/tools/check-pylint b/tools/check-pylint new file mode 100755 index 0000000..ce1ef30 --- /dev/null +++ b/tools/check-pylint @@ -0,0 +1,20 @@ +#!/bin/bash + +PYLINT_EXIT=$? +# pylint error masks + +FATAL_MASK=1 +ERROR_MASK=2 +WARNING_MASK=4 +REFACTRO_MASK=8 +CONVENTION_MASK=16 +USAGE_ERROR_MASK=32 + +# fail on fatal +[[ $(( $PYLINT_EXIT & $FATAL_MASK )) -gt 0 ]] && exit $PYLINT_EXIT + +# fail on error +[[ $(( $PYLINT_EXIT & $ERROR_MASK )) -gt 0 ]] && exit $PYLINT_EXIT + +# fail on warning +[[ $(( $PYLINT_EXIT & $WARNING_MASK )) -gt 0 ]] && exit $PYLINT_EXIT -- cgit v1.2.3