Skip to content

Commit

Permalink
travis: add cppcheck
Browse files Browse the repository at this point in the history
  • Loading branch information
Filip Gospodinov committed Jun 6, 2014
1 parent 797a0c8 commit a7a6f6c
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 7 deletions.
6 changes: 4 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ compiler:
- gcc
- clang
install: ./scripts/travis/install-deps.sh "${TRAVIS_OS_NAME}"
script: ./autogen.sh && ./configure && make distcheck -j 2
script:
- ./scripts/travis/cppcheck_wrapper.sh ./src
- ./autogen.sh && ./configure && make distcheck -j 2
branches:
only:
- master
Expand All @@ -33,4 +35,4 @@ after_success:
- git config credential.helper "store --file=.git/credentials"
- echo "https://${GH_TOKEN}:@github.com" > .git/credentials
- ./scripts/travis/update_online_documentation.sh
- ./scripts/travis/update_sample_mint.sh
# - ./scripts/travis/update_sample_mint.sh
17 changes: 17 additions & 0 deletions scripts/travis/cppcheck_wrapper.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/usr/bin/env bash

# The goal is to remove the suppressed checks stepwise and fix the issues
# in the same commit. Use cppcheck --inline-suppr for false positives.
sup_warn="--suppress=nullPointer"
sup_info="--suppress=ConfigurationNotChecked"
sup_perf="--suppress=stlSize --suppress=redundantAssignment \
--suppress=passedByValue --suppress=postfixOperator"
sup_style="--suppress=variableScope --suppress=unreadVariable \
--suppress=noCopyConstructor --suppress=unusedVariable \
--suppress=cstyleCast --suppress=multiCondition"
suppress="$sup_warn $sup_info $sup_perf $sup_style"
enabled="--enable=warning --enable=information --enable=performance \
--enable=portability --enable=missingInclude --enable=style"
# Exit code '1' is returned if arguments are not valid or if no input
# files are provided. Compare 'cppcheck --help'.
cppcheck -f -q --error-exitcode=2 $enabled $suppress "$@"
24 changes: 19 additions & 5 deletions scripts/travis/install-deps.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
#!/usr/bin/env bash

# Install cppcheck on Ubuntu from source since we need a recent version.
# Will not be needed once travis is updated to Ubuntu 14.04.
install_cppcheck()
{
git clone https://github.com/danmar/cppcheck.git
cd cppcheck
git checkout 1.65
make SRCDIR=build CFGDIR=/usr/share/cppcheck HAVE_RULES=no -j2
sudo make install
# On travis cppcheck ignores CFGDIR. Instead, it looks in $PWD. Compare
# strace output.
sudo install -m644 ./cfg/* ../
}

if [ $# -ne 1 ]; then
echo "Error: expected OS type argument." >&2
exit 1
Expand All @@ -9,18 +23,18 @@ os=$1

case "$os" in
linux)
before_install:
sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
sudo apt-get -qq update
sudo apt-get -qq install g++-4.8
sudo apt-get install libprotobuf-dev protobuf-compiler libzmq3-dev \
libboost-all-dev doxygen
export CC="gcc-4.8"
export CXX="g++-4.8"
libboost-all-dev doxygen
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.8 50
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.8 50
install_cppcheck
;;
osx)
brew update
brew install protobuf-c protobuf boost openssl
brew install protobuf-c protobuf boost openssl cppcheck
brew link --force openssl
;;
*)
Expand Down

0 comments on commit a7a6f6c

Please sign in to comment.