-
Notifications
You must be signed in to change notification settings - Fork 938
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Basic C Code lint checker and shell checker (#859)
* Factor build packages out into a more maintainable list * Create a location for scripts to live * Provide a make target to return the source dir as close as reasonable to the original distributed state * Add a code lint step, checking the coding style * Change test harness as recommended by shellcheck * Ensure we actually have the linter tool installed * Use the correct directory for cmake to run the tests * Adjust for the older uncrustify in the current github ubuntu-latest * Make one file pass the linter * Integrate the lint with the existing test workflow * Add files with minimal changes needed to the linter * Add more files with minimal changes needed to the linter * Dont build binaries if we fail the lint test * Update the phony targets with the lint steps * Ensure the flake8 package is installed in the new lint workflow job * Use the makefile to drive the packages needed to install for linting * No need to add dependancies on lint, just rely on the workflow status to show failure * Update the scripts dir README to reflect current assumptions * Rename and briefly document the indent.sh script * Fix the ignore to ignore the right Makefile * Rename the test_harness script to make it clear it is a shell script * Provide a master lint make target and add a shell script lint tool * Elminate stray tabs * Drop include/auth.h from linter - there are inconsistant results with function definitions when using the current uncrustify rules
- Loading branch information
1 parent
ae502d9
commit 80b33cd
Showing
26 changed files
with
308 additions
and
122 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
This directory contains executables that are not compiled. Some of these may | ||
end up installed for use by end users, but many of them are for use during | ||
development, builds and tests. | ||
|
||
Nothing in this directory should need compiling to use and they should be | ||
written such that they do not need configuring (e.g: they might probe several | ||
directories for their requirements) | ||
|
||
See the [Scripts Documentation](../docs/Scripts.md) for further details |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
#!/bin/sh | ||
# | ||
# Given one or more input source files, run a re-indenter on them. | ||
|
||
help() { | ||
echo "Usage: scripts/indent [-i] [file...]" | ||
echo " -i modify file in place with reindent results" | ||
echo "" | ||
echo "By default, will output a diff and exitcode if changed are needed" | ||
echo "If modifying files, no exit code or diff is output" | ||
exit 1 | ||
} | ||
|
||
[ -z "$1" ] && help | ||
[ "$1" = "-h" ] && help | ||
|
||
INPLACE=0 | ||
if [ "$1" = "-i" ]; then | ||
shift | ||
INPLACE=1 | ||
fi | ||
|
||
## indentOneClang() { | ||
## rm -f "$1.indent" | ||
## clang-format "$1" >"$1.indent" | ||
## if [ $? -ne 0 ]; then | ||
## echo "Error while formatting \"$1\"" | ||
## RESULT=1 | ||
## return | ||
## fi | ||
## diff -u "$1" "$1.indent" | ||
## if [ $? -ne 0 ]; then | ||
## RESULT=1 | ||
## fi | ||
## } | ||
|
||
indentOne() { | ||
IFILE="$1" | ||
if [ "$INPLACE" -eq 0 ]; then | ||
OFILE="$1.indent" | ||
rm -f "$OFILE" | ||
else | ||
OFILE="$1" | ||
fi | ||
if ! uncrustify -c uncrustify.cfg -f "$IFILE" -o "$OFILE"; then | ||
echo "Error while formatting \"$1\"" | ||
RESULT=1 | ||
return | ||
fi | ||
if ! diff -u "$IFILE" "$OFILE"; then | ||
RESULT=1 | ||
fi | ||
} | ||
|
||
RESULT=0 | ||
while [ -n "$1" ]; do | ||
indentOne "$1" | ||
shift | ||
done | ||
exit $RESULT |
Oops, something went wrong.