mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-01-10 08:09:26 +01:00
Merge pull request #5800 from ligfx/lintstrictmode
Tools/lint.sh: turn on Bash 'strict mode'
This commit is contained in:
commit
5461cf211d
@ -2,13 +2,18 @@
|
|||||||
#
|
#
|
||||||
# Linter script that checks for common style issues in Dolphin's codebase.
|
# Linter script that checks for common style issues in Dolphin's codebase.
|
||||||
|
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
fail=0
|
fail=0
|
||||||
|
|
||||||
# Default to staged files, unless a commit was passed.
|
# Default to staged files, unless a commit was passed.
|
||||||
COMMIT=${1:---cached}
|
COMMIT=${1:---cached}
|
||||||
|
|
||||||
|
# Get modified files (must be on own line for exit-code handling)
|
||||||
|
modified_files=$(git diff --name-only --diff-filter=ACMRTUXB $COMMIT)
|
||||||
|
|
||||||
# Loop through each modified file.
|
# Loop through each modified file.
|
||||||
for f in $(git diff --name-only --diff-filter=ACMRTUXB $COMMIT); do
|
for f in ${modified_files}; do
|
||||||
# Filter them.
|
# Filter them.
|
||||||
if ! echo "${f}" | egrep -q "[.](cpp|h|mm)$"; then
|
if ! echo "${f}" | egrep -q "[.](cpp|h|mm)$"; then
|
||||||
continue
|
continue
|
||||||
@ -18,7 +23,7 @@ for f in $(git diff --name-only --diff-filter=ACMRTUXB $COMMIT); do
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Check for clang-format issues.
|
# Check for clang-format issues.
|
||||||
d=$(diff -u "${f}" <(clang-format ${f}))
|
d=$(clang-format ${f} | (diff -u "${f}" - || true))
|
||||||
if ! [ -z "${d}" ]; then
|
if ! [ -z "${d}" ]; then
|
||||||
echo "!!! ${f} not compliant to coding style, here is the fix:"
|
echo "!!! ${f} not compliant to coding style, here is the fix:"
|
||||||
echo "${d}"
|
echo "${d}"
|
||||||
@ -26,7 +31,8 @@ for f in $(git diff --name-only --diff-filter=ACMRTUXB $COMMIT); do
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Check for newline at EOF.
|
# Check for newline at EOF.
|
||||||
if [ -n "$(tail -c 1 ${f})" ]; then
|
last_line="$(tail -c 1 ${f})"
|
||||||
|
if [ -n "${last_line}" ]; then
|
||||||
echo "!!! ${f} not compliant to coding style:"
|
echo "!!! ${f} not compliant to coding style:"
|
||||||
echo "Missing newline at end of file"
|
echo "Missing newline at end of file"
|
||||||
fail=1
|
fail=1
|
||||||
|
Loading…
x
Reference in New Issue
Block a user