Discussions about Programming Style and Coding Conventions #22
Comments
True, I think @hustcalm pointed it out well. We should follow the |
That's true. We need to decide the same style guide for everyone. Google C++ Style Guide could be nice. I have found this script [1] in order to check a C++ file and the steps to integrate it in eclipse [2]. And you know what? We have a lot of work with this issue :-) So, we can wait a few days for other opinions and decide the final style guide before 1 week. Thanks for your comments guys! [1] https://google-styleguide.googlecode.com/svn/trunk/cpplint/cpplint.py |
Cool, this can be a huge project refactoring the source code to be consistent with the Style Guide. Quite agree @rocapal that we need more opinions and discussions to make things clear. However, before refactoring the existed code base, I suggest that we should first follow the style guide when contributing new source code once the final style guide decided. For command line usage with Also, it inspires wondering maybe Jenkins should help us too, see the issue I created for discussions [2]. [1] http://www.sw-engineering-candies.com/snippets/cpp/hello-world-google-cpp-style-guide-compliant |
@rocapal #!/bin/sh
#
# This hook script runs the astyle program in order to apply the style defined by ../../utils/astylerc_ansi
#
#
# the astyle configuratios for igatools can be also found in igatools/utils/astylerc_ansi
#
astyle --style=allman --convert-tabs --indent-preprocessor --indent=spaces=4 \
--indent-switches --min-conditional-indent=0 --pad-header \
--unpad-paren --lineend=linux --indent-labels --align-pointer=name \
--align-reference=name --max-instatement-indent=60 --suffix=none \
--quiet \
$(git status | awk -F : '(/modified:/ || /new file:/) && (/\.h\>/ || /\.cpp\>/) {print $2}') Another snippet demoing #!/bin/bash
# Installation:
# cd my_gitproject
# wget -O pre-commit.sh http://tinyurl.com/mkovs45
# ln -s ../../pre-commit.sh .git/hooks/pre-commit
# chmod +x pre-commit.sh
OPTIONS="-A8 -t8 --lineend=linux"
RETURN=0
ASTYLE=$(which astyle)
if [ $? -ne 0 ]; then
echo "[!] astyle not installed. Unable to check source file format policy." >&2
exit 1
fi
FILES=`git diff --cached --name-only --diff-filter=ACMR | grep -E "\.(c|cpp|h)$"`
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 Another project #!/bin/sh
echo "Running pre-commit lint pass... (skip with --no-verify)"
git stash -q --keep-index
make lint
RESULT=$?
git stash pop -q
if [ ${RESULT} != 0 ]; then
echo
echo "-----------------------------------------------"
echo " LINTING FAILED -- please fix above errors. "
echo ""
echo " [Bypass by passing --no-verify to git commit] "
echo "-----------------------------------------------"
exit 1
else
exit 0
fi Based on the survey, I come up with a strategy which will first filter all the Any idea? I will try this and keep you informed. [1] https://code.google.com/p/igatools/wiki/CodingConventions |
I'm reading the source code of
JdeRobot
and wondering if we got a common programming style guide or coding conventions? I do find here is aProgramming Style
section, but not talking too much except forDoxygen
.For better collaboration, the coherent of coding conventions are important, especially for new developers trying to help and contribute source code.
I find two good references and hopefully we can have some discussions, then come out with our own
JdeRobot Programming Style and Coding Conventions
according to the existed code base. Maybe also do some code refactoring.The references are Google C++ Style Guide and C++ Programming Style Guidelines. They mainly cover
C++
, we can also make adaptions toPython
andJava
, etc.Cheers,
Lihang
The text was updated successfully, but these errors were encountered: