| 1 |
#!/bin/sh |
| 2 |
|
| 3 |
# Copyright © 2015-2019 Jakub Wilk <[email protected]> |
| 4 |
# |
| 5 |
# Permission is hereby granted, free of charge, to any person obtaining a copy |
| 6 |
# of this software and associated documentation files (the “Software”), to deal |
| 7 |
# in the Software without restriction, including without limitation the rights |
| 8 |
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 9 |
# copies of the Software, and to permit persons to whom the Software is |
| 10 |
# furnished to do so, subject to the following conditions: |
| 11 |
# |
| 12 |
# The above copyright notice and this permission notice shall be included in |
| 13 |
# all copies or substantial portions of the Software. |
| 14 |
# |
| 15 |
# THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 16 |
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 17 |
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 18 |
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 19 |
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 20 |
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
| 21 |
# SOFTWARE. |
| 22 |
|
| 23 |
PYTHON=${PYTHON:-python3} |
| 24 |
"$PYTHON" -m pylint --version >/dev/null || exit 1 |
| 25 |
if [ $# -eq 0 ] |
| 26 |
then |
| 27 |
pyscripts=$(grep -l -r '^#!.*python' .) |
| 28 |
set -- lib tests tests/fuzzing/*/*.py $pyscripts |
| 29 |
fi |
| 30 |
whitelist= |
| 31 |
ignored= |
| 32 |
for ext in afl apt_pkg |
| 33 |
do |
| 34 |
if "$PYTHON" -c "import $ext" 2>/dev/null |
| 35 |
then |
| 36 |
whitelist="$whitelist,$ext" |
| 37 |
else |
| 38 |
ignored="$ignored,$ext" |
| 39 |
fi |
| 40 |
done |
| 41 |
if [ -z "${ignored%%*apt*}" ] |
| 42 |
then |
| 43 |
ignored="$ignored,apt" |
| 44 |
fi |
| 45 |
set -- --extension-pkg-whitelist="${whitelist#,}" --ignored-modules="${ignored#,}" "$@" |
| 46 |
log=$(mktemp -t pylint.XXXXXX) |
| 47 |
"$PYTHON" -m pylint "$@" > "$log" || [ $? != 1 ] |
| 48 |
! grep -P '^\S+:' "$log" \ |
| 49 |
| grep -v -P '^(?!lib/).+: missing-(\w+-)?docstring ' \ |
| 50 |
| grep -v ": redefined-builtin \\[.*\\] Redefining built-in 'input'" \ |
| 51 |
| grep -v -P "^tests/.+: wrong-import-order \\[.*\\] external import \"import lib[.].+\" comes before \"from . import tools\"" \ |
| 52 |
| LC_ALL=C sort -k2 \ |
| 53 |
| grep '.' || exit 1 |
| 54 |
rm "$log" |
| 55 |
|
| 56 |
# vim:ts=4 sts=4 sw=4 et |