From 000f851d94399a58f7d01139b36333ad33bbc7f4 Mon Sep 17 00:00:00 2001
From: Dinyar Rabady <dinyar@cern.ch>
Date: Fri, 20 Oct 2023 09:59:18 +0200
Subject: [PATCH 1/2] Run code quality tools as part of CI

We run lizard via statick for general warnings about function complexity
etc., we additionally run cppcheck for granular warnings.
The two tools are run in different jobs because Gitlab otherwise doesn't
merge the reports correctly.
---
 .gitlab-ci.yml | 23 ++++++++++++++++++++++-
 1 file changed, 22 insertions(+), 1 deletion(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 7d5c8059..2d4dff9e 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -2,10 +2,31 @@ image: gitlab-registry.cern.ch/scouting-demonstrator/scouting-docker-images/scda
 
 check_formatting:
   stage: check
-  image: gitlab-registry.cern.ch/scouting-demonstrator/scouting-docker-images/scouting-devtools:1.0.0
+  image: gitlab-registry.cern.ch/scouting-demonstrator/scouting-docker-images/scouting-devtools:1.1.1
   script:
     - find src/ -iname '*.h' -o -iname '*.cc' | xargs clang-format --style=file --dry-run -Werror || (printf "Please reformat your code using the command\ngit clang-format\n\nafter staging your files with \`git add\` or\n\nclang-format -i [your files]\n" && exit 1)
 
+code_quality-cppcheck:
+  stage: check
+  image: gitlab-registry.cern.ch/scouting-demonstrator/scouting-docker-images/scouting-devtools:1.1.1
+  script:
+    - cppcheck --xml --enable=warning,style,performance ./src 2> cppcheck_out.xml
+    - cppcheck-codequality --input-file cppcheck_out.xml --output-file cppcheck.json
+  artifacts:
+    reports:
+      codequality: cppcheck.json
+
+code_quality-lizard:
+  stage: check
+  image: gitlab-registry.cern.ch/scouting-demonstrator/scouting-docker-images/scouting-devtools:1.1.1
+  script:
+    - statick --config=/tmp/statick.yaml --level=gitlab src/
+    - sed -i 's#/builds/scouting-demonstrator/scdaq/##g' src-gitlab.code-climate.json
+  artifacts:
+    reports:
+      codequality: src-gitlab.code-climate.json
+
+
 build_rpm_tag:
   stage: build
   only:
-- 
GitLab


From c74881ad8406572a26b2c0c50458ebeada8a3a9d Mon Sep 17 00:00:00 2001
From: Dinyar Rabady <dinyar@cern.ch>
Date: Thu, 26 Oct 2023 14:51:25 +0200
Subject: [PATCH 2/2] Enabled all checks in cppcheck

---
 .gitlab-ci.yml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 2d4dff9e..d55a7e23 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -10,7 +10,7 @@ code_quality-cppcheck:
   stage: check
   image: gitlab-registry.cern.ch/scouting-demonstrator/scouting-docker-images/scouting-devtools:1.1.1
   script:
-    - cppcheck --xml --enable=warning,style,performance ./src 2> cppcheck_out.xml
+    - cppcheck --xml --enable=all ./src 2> cppcheck_out.xml
     - cppcheck-codequality --input-file cppcheck_out.xml --output-file cppcheck.json
   artifacts:
     reports:
-- 
GitLab