Add cppcheck as a pre-commit hook
diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml
index dc06161021a41c..4f6bb66d023f22 100644
--- a/.github/workflows/test.yaml
+++ b/.github/workflows/test.yaml
@@ -37,7 +37,7 @@ jobs:
                          external/bin selfdrive/modeld/runners $TEST_DIR
 
         # need these so docker copy won't fail
-        cp Pipfile Pipfile.lock .pylintrc cppcheck_openpilot.sh .coveragerc-app .pre-commit-config.yaml $TEST_DIR
+        cp Pipfile Pipfile.lock .pylintrc .coveragerc-app .pre-commit-config.yaml $TEST_DIR
         cd $TEST_DIR
         mkdir laika laika_repo tools release
     - name: Build Docker image
@@ -96,18 +96,6 @@ jobs:
         run: eval "$BUILD"
       - name: pre-commit
         run: $RUN "cd /tmp/openpilot/ && git init && git add -A && pre-commit run --all"
-      - name: cppcheck
-        run: $PERSIST "cd /tmp/openpilot/ && ./cppcheck_openpilot.sh 2> cppcheck_report.txt"
-      - name: Print cppcheck report
-        if: always()
-        run: |
-          docker cp tmppilot:/tmp/openpilot/cppcheck_report.txt cppcheck_report.txt
-          cat cppcheck_report.txt
-      - uses: actions/upload-artifact@v2
-        if: always()
-        with:
-          name: cppcheck_report.txt
-          path: cppcheck_report.txt
 
   unit_tests:
     name: unit tests
diff --git a/.gitignore b/.gitignore
index fb1cbfc0b63f2c..31ced88ca9f8a5 100644
--- a/.gitignore
+++ b/.gitignore
@@ -59,7 +59,6 @@ openpilot-apks
 
 .coverage*
 coverage.xml
-cppcheck_report.txt
 htmlcov
 pandaextra
 
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index af18f795ffc205..491d5fb49848c4 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -31,3 +31,16 @@ repos:
         language: system
         types: [python]
         exclude: '^(pyextra)|(external)|(cereal)|(rednose)|(panda)|(laika)|(laika_repo)|(rednose_repo)/'
+-   repo: local
+    hooks:
+    -   id: cppcheck
+        name: cppcheck
+        entry: cppcheck
+        language: system
+        types: [c++]
+        exclude: '^(phonelibs)|(external)|(cereal)|(opendbc)|(panda)|(tools)|(selfdrive/modeld/thneed/debug)|(selfdrive/modeld/test)|(selfdrive/camerad/test)/'
+        args:
+        - --error-exitcode=1
+        - --quiet
+        - --force
+        - -j8
diff --git a/Dockerfile.openpilot b/Dockerfile.openpilot
index ec4ee189dcda23..71827ae9b84ddd 100644
--- a/Dockerfile.openpilot
+++ b/Dockerfile.openpilot
@@ -77,7 +77,6 @@ RUN pyenv install 3.8.2 && \
 RUN mkdir -p /tmp/openpilot
 
 COPY SConstruct \
-     cppcheck_openpilot.sh \
      .pylintrc \
      .pre-commit-config.yaml \
      .coveragerc-app \
diff --git a/cppcheck_openpilot.sh b/cppcheck_openpilot.sh
deleted file mode 100755
index 6f6520806f793e..00000000000000
--- a/cppcheck_openpilot.sh
+++ /dev/null
@@ -1,4 +0,0 @@
-#!/bin/bash
-
-cppcheck --force -j$(nproc) selfdrive/ common/ opendbc/ cereal/ installer/ 2> cppcheck_report.txt
-
diff --git a/selfdrive/ui/sidebar.cc b/selfdrive/ui/sidebar.cc
index 5d75a9bbfb2cf7..890ea7e7ac5b8b 100644
--- a/selfdrive/ui/sidebar.cc
+++ b/selfdrive/ui/sidebar.cc
@@ -136,7 +136,7 @@ static void ui_draw_sidebar_temp_metric(UIState *s) {
 }
 
 static void ui_draw_sidebar_panda_metric(UIState *s) {
-  int panda_severity;
+  int panda_severity = 2;
   char panda_message_str[32];
   const int panda_y_offset = 32 + 148;
 
