Coding style related changes (#653)
* Add .astylerc with the core coding standard * Added pre-commit git hook The hook currently only checks code format using astyle and will not permit commits which cause astyle to change the contents of any source file in the commit. This is useful to have automatic coding standard verification done without having to wait for Jenkins to react to a pull request. Installation: Linux: ln -s ../../tools/hooks/pre-commit.sh .git/hooks/pre-commit Windows: copy tools\hooks\pre-commit.sh .git\hooks\pre-commit * Added editorconfig and updated gitattributes Unix style line endings are now default. * Resolved doxygen warning
This commit is contained in:
committed by
Olivier
parent
26b485cb0d
commit
45b671457d
@@ -0,0 +1,23 @@
|
||||
# Coding standard for MySensors core library (see https://www.mysensors.org/download/contributing)
|
||||
|
||||
# Curly braces should follow "One True Brace Style" format
|
||||
style=1tbs
|
||||
|
||||
# All control statements ('if', 'for', 'while' etc.) should include curly braces {}. Even one-liners.
|
||||
add-brackets
|
||||
|
||||
# Tab-character for white space/indentation
|
||||
indent=tab
|
||||
|
||||
# All lines should be kept at 100 character width or less
|
||||
max-code-length=100
|
||||
break-after-logical
|
||||
|
||||
# Preprocessor blocks should be indented
|
||||
indent-preproc-block
|
||||
|
||||
# Preprocessor definitions should be indented if linebroken
|
||||
indent-preproc-define
|
||||
|
||||
# C++ comments should be indented to source level, and not be kept in first column
|
||||
indent-col1-comments
|
||||
@@ -0,0 +1,19 @@
|
||||
# EditorConfig is awesome: http://EditorConfig.org
|
||||
|
||||
# top-most EditorConfig file
|
||||
root = true
|
||||
|
||||
# Unix-style newlines with UTF-8 encoding for every file
|
||||
[*]
|
||||
end_of_line = lf
|
||||
charset = utf-8
|
||||
|
||||
# For all source code
|
||||
[*.{c,cpp,h,ino}]
|
||||
insert_final_newline = true
|
||||
indent_style = tab
|
||||
indent_size = 2
|
||||
|
||||
# Tab indentation also for makefiles
|
||||
[Makefile]
|
||||
indent_style = tab
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
# Set default behaviour, in case users don't have core.autocrlf set.
|
||||
* text=auto
|
||||
* text eol=lf
|
||||
|
||||
# Explicitly declare text files we want to always be normalized and converted
|
||||
# to native line endings on checkout.
|
||||
|
||||
@@ -953,6 +953,7 @@
|
||||
#define MY_RX_MESSAGE_BUFFER_SIZE
|
||||
#define MY_NODE_LOCK_FEATURE
|
||||
#define MY_REPEATER_FEATURE
|
||||
#define MY_TRANSPORT_UPLINK_CHECK_DISABLED
|
||||
#define MY_TRANSPORT_DONT_CARE_MODE
|
||||
#define MY_LINUX_SERIAL_GROUPNAME
|
||||
#define MY_IS_SERIAL_PTY
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
#!/bin/sh
|
||||
|
||||
OPTIONS="--options=.astylerc"
|
||||
|
||||
RETURN=0
|
||||
ASTYLE=astyle
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "[!] astyle not installed or not in current path. Unable to check source file format policy." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
FILES=`git diff --name-only --diff-filter=ACMR | grep -E "\.(c|cpp|h|ino)$"`
|
||||
for FILE in $FILES; do
|
||||
$ASTYLE $OPTIONS < $FILE | cmp -s $FILE -
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "[!] $FILE does not respect the agreed coding style." >&2
|
||||
RETURN=1
|
||||
fi
|
||||
done
|
||||
|
||||
if [ $RETURN -eq 1 ]; then
|
||||
echo "" >&2
|
||||
echo "Make sure you have run astyle with the following options:" >&2
|
||||
echo $OPTIONS >&2
|
||||
fi
|
||||
|
||||
exit $RETURN
|
||||
Reference in New Issue
Block a user