Add cppcheck as a pre-commit hook (#1646)

* add cppcheck as a pre-commit hook

* fix Dockerfile

* update precommit config

* exclude panda and opendbc
pull/1756/head
Adeeb Shihadeh 2020-06-19 20:39:34 -07:00 committed by GitHub
parent cab96374c5
commit 3c461ca5cc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 15 additions and 20 deletions

View File

@ -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

1
.gitignore vendored
View File

@ -59,7 +59,6 @@ openpilot-apks
.coverage*
coverage.xml
cppcheck_report.txt
htmlcov
pandaextra

View File

@ -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

View File

@ -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 \

View File

@ -1,4 +0,0 @@
#!/bin/bash
cppcheck --force -j$(nproc) selfdrive/ common/ opendbc/ cereal/ installer/ 2> cppcheck_report.txt

View File

@ -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;