Browse Source

added cppcheck config and simple script to run it

Costa Tsaousis (ktsaou) 7 years ago
parent
commit
dbc69a0ece
4 changed files with 47 additions and 3 deletions
  1. 2 3
      .gitignore
  2. 2 0
      Makefile.am
  3. 30 0
      cppcheck.sh
  4. 13 0
      netdata.cppcheck

+ 2 - 3
.gitignore

@@ -99,6 +99,7 @@ profile/benchmark-dictionary
 profile/benchmark-registry
 profile/test-eval
 profile/benchmark-line-parsing
+profile/statsd-stress
 
 *.pyc
 *.run
@@ -108,12 +109,10 @@ diagrams/*.svg
 diagrams/*.atxt
 diagrams/plantuml.jar
 
-netdata.cppcheck
-
-profile/statsd-stress
 src/cgroup-network
 vgcore.*
 
 src/cppcheck-build/
 makeself/debug/
 
+

+ 2 - 0
Makefile.am

@@ -61,9 +61,11 @@ SUBDIRS = \
 	$(NULL)
 
 dist_noinst_DATA= \
+	cppcheck.sh \
 	configs.signatures \
 	Dockerfile \
 	Dockerfile.armv7hf \
+	netdata.cppcheck \
 	netdata.spec \
 	package.json \
 	$(NULL)

+ 30 - 0
cppcheck.sh

@@ -0,0 +1,30 @@
+#!/usr/bin/env bash
+
+cppcheck=$(which cppcheck 2>/dev/null || command -v cppcheck 2>/dev/null)
+[ -z "${cppcheck}" ] && echo >&2 "install cppcheck." && exit 1
+
+[ -x "/home/costa/src/cppcheck.git/cppcheck" ] && \
+	cppcheck="/home/costa/src/cppcheck.git/cppcheck"
+
+processors=$(grep -c ^processor /proc/cpuinfo)
+[ $(( processors )) -lt 1 ] && processors=1
+
+base="$(dirname "${0}")"
+[ "${base}" = "." ] && base="${PWD}"
+
+cd "${base}/src" || exit 1
+
+[ ! -d "cppcheck-build" ] && mkdir "cppcheck-build"
+
+file="${1}"
+shift
+[ "${file}" = "${base}" -o -z "${file}" ] && file="${base}/src"
+
+"${cppcheck}" \
+	-j ${processors} \
+	--cppcheck-build-dir="cppcheck-build" \
+	-I .. \
+	--force \
+	--enable=warning,performance,portability,information \
+	--suppress="unusedFunction:*" \
+	"${file}" "${@}"

+ 13 - 0
netdata.cppcheck

@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="1">
+    <root name="/home/costa/src/netdata-ktsaou.git/src"/>
+    <builddir>cppcheck-build</builddir>
+    <includedir>
+        <dir name=".."/>
+        <dir name="/usr/include"/>
+    </includedir>
+    <libraries>
+        <library>gnu</library>
+        <library>posix</library>
+    </libraries>
+</project>