From 19bd3083068f4aface5e7c536232b731aeec410e Mon Sep 17 00:00:00 2001
From: Nicolas Pope <nicolas.pope@utu.fi>
Date: Sat, 7 May 2022 09:01:43 +0100
Subject: [PATCH] Use cppcheck directly

---
 .codeclimate.yml |  9 ---------
 .gitlab-ci.yml   | 47 +++++++----------------------------------------
 2 files changed, 7 insertions(+), 49 deletions(-)
 delete mode 100644 .codeclimate.yml

diff --git a/.codeclimate.yml b/.codeclimate.yml
deleted file mode 100644
index 9c892e0..0000000
--- a/.codeclimate.yml
+++ /dev/null
@@ -1,9 +0,0 @@
-plugins:
-  cppcheck:
-    enabled: true
-    config:
-      check: all
-      language: c++
-      stds:
-        - c++14
-        - c++17
\ No newline at end of file
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index db7d44b..ae8aa99 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -21,52 +21,19 @@ image: ubuntu:jammy
 
 code_quality:
   stage: test
-  image: docker:20.10.12
-  allow_failure: true
-  services:
-    - name: 'docker:20.10.12-dind'
-  tags:
-    - docker
   only:
     - main
     - merge_requests
-  variables:
-    DOCKER_DRIVER: overlay2
-    DOCKER_TLS_CERTDIR: ""
-    CODE_QUALITY_IMAGE: "registry.gitlab.com/gitlab-org/ci-cd/codequality:0.85.26"
-  needs: []
+  tags:
+    - docker
   script:
-    - export SOURCE_CODE=$PWD
-    - | # this is required to avoid undesirable reset of Docker image ENV variables being set on build stage
-      function propagate_env_vars() {
-        CURRENT_ENV=$(printenv)
-
-        for VAR_NAME; do
-          echo $CURRENT_ENV | grep "${VAR_NAME}=" > /dev/null && echo "--env $VAR_NAME "
-        done
-      }
-    - docker pull --quiet "$CODE_QUALITY_IMAGE"
-    - |
-      docker run --rm \
-        $(propagate_env_vars \
-          SOURCE_CODE \
-          TIMEOUT_SECONDS \
-          CODECLIMATE_DEBUG \
-          CODECLIMATE_DEV \
-          REPORT_STDOUT \
-          REPORT_FORMAT \
-          ENGINE_MEMORY_LIMIT_BYTES \
-          CODECLIMATE_PREFIX \
-        ) \
-        --volume "$PWD":/code \
-        --volume /var/run/docker.sock:/var/run/docker.sock \
-        "$CODE_QUALITY_IMAGE" /code
+    - DEBIAN_FRONTEND=noninteractive apt update && apt install -y python3 cppcheck
+    - python3 -m pip install -U cppcheck_codequality
+    - cppcheck --xml --enable=warning,style,performance --std=c++14 --suppress=*:*catch.hpp --suppress=*:*json.hpp ./ 2> cppcheck_out.xml
+    - cppcheck-codequality --input-file=cppcheck_out.xml --output-file=cppcheck.json
   artifacts:
     reports:
-      codequality: gl-code-quality-report.json
-    expire_in: 1 week
-  dependencies: []
-
+      codequality: cppcheck.json
 
 linux:build:
   only:
-- 
GitLab