diff --git a/.travis.install.cppcheck b/.travis.install.cppcheck
new file mode 100755
index 0000000000000000000000000000000000000000..aa8383441424e692a5b975cedcb06a92ad14513a
--- /dev/null
+++ b/.travis.install.cppcheck
@@ -0,0 +1,23 @@
+#! /bin/bash
+
+set -e
+set -x
+
+
+git clone https://github.com/danmar/cppcheck.git
+cd cppcheck
+
+if [ -n "$1" ] ; then
+  echo "installing cppcheck $version"
+  version=$1
+else
+  echo "installing latest doxygen"
+  version=$(git tag | tail -n 1)
+fi
+
+
+git checkout $tag
+sudo make -j 4 install CFGDIR=/usr/share/cppcheck/
+cd ../
+
+
diff --git a/.travis.yml b/.travis.yml
index cb4f621e011bad6eb7897400351790d65803b6a1..b390c333233326267a1d7740c2f75d95ab6e1b4a 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -15,6 +15,13 @@ env:
   - PLUMED_CC=clang PLUMED_CXX=clang++ PLUMED_CXXFLAGS=-O3 LAPACK=yes
   - PLUMED_CC=gcc   PLUMED_CXX=g++     PLUMED_CXXFLAGS=-O3 LAPACK=yes
   - PLUMED_CC=mpicc PLUMED_CXX=mpic++  PLUMED_CXXFLAGS=-O3 LAPACK=yes
+# cppcheck
+# in principle we should make only "cppcheck" here
+# to avoid to many if's below, I also make a quick test with -O0 here
+  - PLUMED_CC=gcc   PLUMED_CXX=g++     PLUMED_CXXFLAGS=-O0 CPPCHECK=yes
+matrix:
+  allow_failures:
+    - env: PLUMED_CC=gcc   PLUMED_CXX=g++     PLUMED_CXXFLAGS=-O0 CPPCHECK=yes
 # Possible additional variables:
 #   VALGRIND=yes to make valgrind tests, only when log contains string [valgrind]
 install:
@@ -27,6 +34,8 @@ install:
   - sudo apt-get install -y libmatheval-dev
 # this is not needed (will be used in 2.2)
 #  - ./.travis.install.xdrfile
+# cppcheck:
+  - test "$CPPCHECK" == yes && ./.travis.install.cppcheck 1.69 || true
 # installation of these packages takes a lot of time
 # we do it only when needed
   - test "$PLUMED_CXX" == "mpic++" && sudo apt-get install -y libopenmpi1.5-dev openmpi1.5-bin || true
@@ -53,10 +62,12 @@ script:
   - make -j 2
 # we install plumed so that it is in the path
   - sudo make install
+# run static analyzer
   - test "$VALGRIND" == yes && OPT=valgrind || OPT=""
   - make -C regtest $OPT
   - test "$MAKEDOC" == yes && make -C regtest copytodoc || true
   - test "$MAKEDOC" == yes && make doc >/dev/null || true
   - make -C regtest checkfail
+  - if test "$CPPCHECK" == yes ; then make cppcheck ; fi
 after_success:
   - test "$MAKEDOC" == yes && ./.travis.pushdoc