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:
Patrick Fallberg
2016-11-24 16:43:04 +01:00
committed by Olivier
parent 26b485cb0d
commit 45b671457d
5 changed files with 71 additions and 1 deletions
+23
View File
@@ -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
+19
View File
@@ -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
View File
@@ -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.
+1
View File
@@ -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
+27
View File
@@ -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