blob: 82b46b02ad9446107bf9e868c7e2894e40cb1af1 [file] [log] [blame]
Martin Roth0ad5fbd2020-12-24 12:06:38 -07001#!/usr/bin/env sh
Patrick Georgid13e4162012-02-16 20:28:42 +01002#
Patrick Georgi7333a112020-05-08 20:48:04 +02003# SPDX-License-Identifier: GPL-2.0-only
4
Patrick Georgid13e4162012-02-16 20:28:42 +01005# DESCR: Check for superfluous whitespace in the tree
6
Fred Reitberger743c1c02022-10-07 13:54:10 -04007LINTDIR="$(
Martin Rothd81debd2022-06-03 00:06:57 -06008 cd -- "$(dirname "$0")" > /dev/null 2>&1 || return
9 pwd -P
10)"
11# shellcheck source=helper_functions.sh
12. "${LINTDIR}/helper_functions.sh"
13
Maximilian Bruneb3a7c642023-03-03 03:52:07 +010014EXCLUDELIST='^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 Dabrosffa58cf2020-07-16 13:38:01 +020015INCLUDELIST="src util payloads Makefile* toolchain.inc tests"
Martin Roth86008932018-09-01 14:54:33 -060016
17# shellcheck disable=SC2086,SC2046
18if uname | grep -qi "linux"; then
Balazs Vinarz28def8b2019-01-18 11:23:29 +010019 grep -n -H "[[:space:]][[:space:]]*$" \
Martin Roth95b5b022022-10-17 07:53:16 -060020 $(${FIND_FILES} ${INCLUDELIST} ${FINDOPTS} | \
Martin Roth86008932018-09-01 14:54:33 -060021 grep -Ev "($EXCLUDELIST)" ) | \
22 sed -e "s,^.*$,File & has lines ending with whitespace.,"
23else
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 Roth95b5b022022-10-17 07:53:16 -060026 ${FIND_FILES} ${INCLUDELIST} ${FINDOPTS}| \
Martin Roth86008932018-09-01 14:54:33 -060027 grep -Ev "($EXCLUDELIST)" | \
28 xargs -I % \
29 grep -l "[[:space:]][[:space:]]*$" % | \
30 sed -e "s,^.*$,File & has lines ending with whitespace.,"
31fi