diff --git a/Tools/astyle/check_code_style.sh b/Tools/astyle/check_code_style.sh index 3a2fcef35b..c68b32a9a2 100755 --- a/Tools/astyle/check_code_style.sh +++ b/Tools/astyle/check_code_style.sh @@ -3,22 +3,20 @@ FILE=$1 DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) -if [ -f "$FILE" ]; then - CHECK_FAILED=$(${DIR}/fix_code_style.sh --dry-run --formatted $FILE) - if [ -n "$CHECK_FAILED" ]; then - ${DIR}/fix_code_style.sh --quiet < $FILE > $FILE.pretty +CHECK_FAILED=$(${DIR}/fix_code_style.sh --dry-run --formatted $FILE) +if [ -n "$CHECK_FAILED" ]; then + ${DIR}/fix_code_style.sh --quiet < $FILE > $FILE.pretty - echo -e 'Formatting issue found in' $FILE - echo - git --no-pager diff --no-index --minimal --histogram --color=always $FILE $FILE.pretty | grep -vE -e "^.{,4}diff.*\.pretty.{,3}$" -e "^.{,4}--- a/.*$" -e "^.{,4}\+\+\+ b/.*$" -e "^.{,5}@@ .* @@.*$" -e "^.{,4}index .{10}\.\." - rm -f $FILE.pretty - echo + echo -e 'Formatting issue found in' $FILE + echo + git --no-pager diff --no-index --minimal --histogram --color=always $FILE $FILE.pretty | grep -vE -e "^.{,4}diff.*\.pretty.{,3}$" -e "^.{,4}--- a/.*$" -e "^.{,4}\+\+\+ b/.*$" -e "^.{,5}@@ .* @@.*$" -e "^.{,4}index .{10}\.\." + rm -f $FILE.pretty + echo - if [[ $PX4_ASTYLE_FIX -eq 1 ]]; then - ${DIR}/fix_code_style.sh $FILE - else - echo 'to fix automatically run "make format" or "./Tools/astyle/fix_code_style.sh' $FILE'"' - exit 1 - fi + if [[ $PX4_ASTYLE_FIX -eq 1 ]]; then + ${DIR}/fix_code_style.sh $FILE + else + echo 'to fix automatically run "make format" or "./Tools/astyle/fix_code_style.sh' $FILE'"' + exit 1 fi fi diff --git a/Tools/astyle/files_to_check_code_style.sh b/Tools/astyle/files_to_check_code_style.sh index 734d6f5323..97a2d8c6fc 100755 --- a/Tools/astyle/files_to_check_code_style.sh +++ b/Tools/astyle/files_to_check_code_style.sh @@ -31,4 +31,4 @@ exec find boards msg src platforms test \ -path src/lib/cdrstream/rosidl -prune -o \ -path src/modules/zenoh/zenoh-pico -prune -o \ -path boards/modalai/voxl2/libfc-sensor-api -prune -o \ - -type f \( -name "*.c" -o -name "*.h" -o -name "*.cpp" -o -name "*.hpp" \) | grep $PATTERN + \( -type f \( -name "*.c" -o -name "*.h" -o -name "*.cpp" -o -name "*.hpp" \) -print \) | grep $PATTERN