From f65f70d5c3a99d808b1da7a7bbf4618721d829fd Mon Sep 17 00:00:00 2001 From: Sander Speetjens Date: Sat, 23 Dec 2023 21:44:30 +0100 Subject: [PATCH] linter --- .lint/exclude | 10 ++++++++++ .lint/search | 4 ++++ lint.sh | 33 +++++++++++++++++++++++++++++++++ 3 files changed, 47 insertions(+) create mode 100644 .lint/exclude create mode 100644 .lint/search create mode 100644 lint.sh diff --git a/.lint/exclude b/.lint/exclude new file mode 100644 index 0000000..8734232 --- /dev/null +++ b/.lint/exclude @@ -0,0 +1,10 @@ +project/Core/Inc/main.h +project/Core/Inc/stm32f7xx_hal_conf.h +project/Core/Inc/stm32f7xx_it.h +project/Core/Inc/fsdata_custom.c +project/Core/Src/stm32f7xx_hal_msp.c +project/Core/Src/syscalls.c +project/Core/Src/sysmem.c +project/Core/Src/system_stm32f7xx.c +project/Core/Src/stm32f7xx_it.c +mkllfs/build/CMakeFiles/3.27.7/CompilerIdC/CMakeCCompilerId.c diff --git a/.lint/search b/.lint/search new file mode 100644 index 0000000..179fe1f --- /dev/null +++ b/.lint/search @@ -0,0 +1,4 @@ +project/Core/ +mkllfs +tests/ +Applications/Qt-application_for_UDP_broadcast/ diff --git a/lint.sh b/lint.sh new file mode 100644 index 0000000..fb40b6e --- /dev/null +++ b/lint.sh @@ -0,0 +1,33 @@ +#!/bin/bash + +if (( $# != 2 )); then + >&2 echo "Illegal number of parameters" + exit 1 +fi + +INPUT=$1 +EXCLUDE=$2 + +function get_files() { +while read p; do + find "$p" -regex '.*\.\(c\|cpp\|h\)$' | grep -vFf $2 +done < $1 +} + +if [ ! -f $1 ]; then + echo "File not found!" + exit 1 +fi + +if [ ! -f $2 ]; then + echo "File not found!" + exit 1 +fi + +# save unsaved work +git stash --include-untracked +get_files $1 $2 | xargs clang-format -i + +git add -A && git commit -m "Lint" + +git stash pop