mirror of https://github.com/ntop/n2n.git
Browse Source
* 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 rulespull/864/head
Hamish Coleman
3 years ago
committed by
GitHub
26 changed files with 308 additions and 122 deletions
@ -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 |
@ -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 |
@ -0,0 +1,34 @@ |
|||||
|
# Initial rules taken from a quick discussion |
||||
|
# (See https://github.com/ntop/n2n/commit/00159d0d012c6836fd972af1748833eeaf50fa22#commitcomment-57137247) |
||||
|
|
||||
|
# 4 space indention (never use tabs) |
||||
|
indent_columns = 4 |
||||
|
indent_with_tabs = 0 |
||||
|
indent_switch_case = 4 |
||||
|
|
||||
|
# space between name and bracket during function define |
||||
|
sp_func_def_paren = force |
||||
|
sp_func_proto_paren = force |
||||
|
|
||||
|
# no space between name and bracket during call |
||||
|
sp_func_call_paren = remove |
||||
|
|
||||
|
# no space after if and while |
||||
|
sp_before_sparen = remove |
||||
|
#sp_while_paren_open = remove # only in newer uncrustify |
||||
|
|
||||
|
# block-braces as seen above |
||||
|
nl_if_brace = remove |
||||
|
nl_brace_else = remove |
||||
|
nl_elseif_brace = remove |
||||
|
nl_else_brace = remove |
||||
|
#nl_before_opening_brace_func_class_def = remove # only in newer uncrustify |
||||
|
nl_for_brace = remove |
||||
|
nl_while_brace = remove |
||||
|
|
||||
|
# multi-line parameters with indentation under the opening bracket |
||||
|
# looks like this is the default, but might be the following: |
||||
|
#indent_func_call_param = false ? |
||||
|
|
||||
|
# Want to keep var definition alignment |
||||
|
#align_keep_extra_space = true |
Loading…
Reference in new issue