Martin Roth | 0ad5fbd | 2020-12-24 12:06:38 -0700 | [diff] [blame] | 1 | #!/usr/bin/env sh |
Patrick Georgi | d13e416 | 2012-02-16 20:28:42 +0100 | [diff] [blame] | 2 | # |
Patrick Georgi | 7333a11 | 2020-05-08 20:48:04 +0200 | [diff] [blame] | 3 | # SPDX-License-Identifier: GPL-2.0-only |
| 4 | |
Patrick Georgi | d13e416 | 2012-02-16 20:28:42 +0100 | [diff] [blame] | 5 | # DESCR: Check for superfluous whitespace in the tree |
| 6 | |
Fred Reitberger | 743c1c0 | 2022-10-07 13:54:10 -0400 | [diff] [blame] | 7 | LINTDIR="$( |
Martin Roth | d81debd | 2022-06-03 00:06:57 -0600 | [diff] [blame] | 8 | cd -- "$(dirname "$0")" > /dev/null 2>&1 || return |
| 9 | pwd -P |
| 10 | )" |
| 11 | # shellcheck source=helper_functions.sh |
| 12 | . "${LINTDIR}/helper_functions.sh" |
| 13 | |
Martin Roth | 95b5b02 | 2022-10-17 07:53:16 -0600 | [diff] [blame] | 14 | EXCLUDELIST='^src/vendorcode/|^util/kconfig/|^util/nvidia/cbootimage/|^util/goswid/|__pycache__|COPYING|LICENSE|README|_shipped$|\.patch$|\.bin$|\.hex$|\.jpg$|\.gif$|\.ttf$|\.woff$|\.png$|\.eot$|\.vbt$|\.ico$|\.md$' |
Jan Dabros | ffa58cf | 2020-07-16 13:38:01 +0200 | [diff] [blame] | 15 | INCLUDELIST="src util payloads Makefile* toolchain.inc tests" |
Martin Roth | 8600893 | 2018-09-01 14:54:33 -0600 | [diff] [blame] | 16 | |
| 17 | # shellcheck disable=SC2086,SC2046 |
| 18 | if uname | grep -qi "linux"; then |
Balazs Vinarz | 28def8b | 2019-01-18 11:23:29 +0100 | [diff] [blame] | 19 | grep -n -H "[[:space:]][[:space:]]*$" \ |
Martin Roth | 95b5b02 | 2022-10-17 07:53:16 -0600 | [diff] [blame] | 20 | $(${FIND_FILES} ${INCLUDELIST} ${FINDOPTS} | \ |
Martin Roth | 8600893 | 2018-09-01 14:54:33 -0600 | [diff] [blame] | 21 | grep -Ev "($EXCLUDELIST)" ) | \ |
| 22 | sed -e "s,^.*$,File & has lines ending with whitespace.," |
| 23 | else |
| 24 | # The above form is much (100x) faster, but doesn't work |
| 25 | # on all systems. A for loop also works but takes 30% longer |
Martin Roth | 95b5b02 | 2022-10-17 07:53:16 -0600 | [diff] [blame] | 26 | ${FIND_FILES} ${INCLUDELIST} ${FINDOPTS}| \ |
Martin Roth | 8600893 | 2018-09-01 14:54:33 -0600 | [diff] [blame] | 27 | grep -Ev "($EXCLUDELIST)" | \ |
| 28 | xargs -I % \ |
| 29 | grep -l "[[:space:]][[:space:]]*$" % | \ |
| 30 | sed -e "s,^.*$,File & has lines ending with whitespace.," |
| 31 | fi |