Repository: SINTEF/dlite (language: python)

Issue:
Fix new cppcheck issue
It seems that the CI workflow has picked up a new version of cppcheck that complains about the STRINGIFY macro. 

Either configure cppcheck to understand that STRINGIFY is a macro (best solution) or ignore cppcheck errors on the specific lines (a hack).

```
cppcheck . --language=c -q --force --error-exitcode=2 --inline-suppr -i src/utils/tests/test_tgen.c
  shell: /usr/bin/bash -e {0}
src/tests/test_json.c:22:9: error: There is an unknown macro here somewhere. Configuration is required. If STRINGIFY is a macro then please configure it. [unknownMacro]
  url = PREFIX "test-entity.json?mode=r";
        ^
src/tests/test_storage.c:23:1[5](https://github.com/SINTEF/dlite/actions/runs/3656139765/jobs/6178238274#step:5:5): error: There is an unknown macro here somewhere. Configuration is required. If STRINGIFY is a macro then please configure it. [unknownMacro]
    "json://" STRINGIFY(dlite_SOURCE_DIR) "/src/tests/test-data.json?mode=r";
              ^
storages/json/tests/test_json_storage.c:120:25: error: There is an unknown macro here somewhere. Configuration is required. If STRINGIFY is a macro then please configure it. [unknownMacro]
  char *url = "json://" STRINGIFY(DLITE_ROOT) "/src/tests/test-read-data.json"
                        ^
storages/python/tests-c/test_blob_storage.c:18:25: error: There is an unknown macro here somewhere. Configuration is required. If STRINGIFY is a macro then please configure it. [unknownMacro]
  char *url = "blob://" STRINGIFY(CURRENT_SOURCE_DIR)
                        ^
storages/python/tests-c/test_bson_storage.c:13:1[6](https://github.com/SINTEF/dlite/actions/runs/3656139765/jobs/6178238274#step:5:7): error: There is an unknown macro here somewhere. Configuration is required. If STRINGIFY is a macro then please configure it. [unknownMacro]
   = "json://" STRINGIFY(DLITE_ROOT) "/src/tests/test-entity.json?mode=r";
               ^
storages/rdf/tests/test_rdf.c:[15](https://github.com/SINTEF/dlite/actions/runs/3656139765/jobs/6178238274#step:5:16):[16](https://github.com/SINTEF/dlite/actions/runs/3656139765/jobs/6178238274#step:5:17): error: There is an unknown macro here somewhere. Configuration is required. If STRINGIFY is a macro then please configure it. [unknownMacro]
  url="json://"STRINGIFY(dlite_SOURCE_DIR)"/src/tests/test-entity.json?mode=r";
```


Discussion / hints:

Fix patch:
diff --git a/.github/workflows/static_analysis.yml b/.github/workflows/static_analysis.yml
index c2cef33c0..4881bb837 100644
--- a/.github/workflows/static_analysis.yml
+++ b/.github/workflows/static_analysis.yml
@@ -19,6 +19,10 @@ jobs:
       run: |
         sudo apt-get install cppcheck
 
+    - name: Show cppcheck version
+      run: |
+        cppcheck --version
+
     - name: Run static code analysis
       run: |
         # We ignore src/utils/tests/test_tgen.c due to a strange bug in the


Test patch:
diff --git a/src/tests/test_json.c b/src/tests/test_json.c
index 99b8fc6e3..a487356e2 100644
--- a/src/tests/test_json.c
+++ b/src/tests/test_json.c
@@ -19,7 +19,7 @@ DLiteMeta *meta=NULL;
 MU_TEST(test_load)
 {
   char *url;
-  url = PREFIX "test-entity.json?mode=r";
+  url = PREFIX "test-entity.json?mode=r";  // cppcheck-suppress unknownMacro
   meta = dlite_meta_load_url(url);
   mu_check(meta);
 
diff --git a/src/tests/test_storage.c b/src/tests/test_storage.c
index d6042fcd8..c92465a5a 100644
--- a/src/tests/test_storage.c
+++ b/src/tests/test_storage.c
@@ -20,7 +20,7 @@ MU_TEST(test_open)
 MU_TEST(test_open_url)
 {
   char *url =
-    "json://" STRINGIFY(dlite_SOURCE_DIR) "/src/tests/test-data.json?mode=r";
+    "json://" STRINGIFY(dlite_SOURCE_DIR) "/src/tests/test-data.json?mode=r";  // cppcheck-suppress unknownMacro
   mu_assert_int_eq(0, dlite_storage_close(s));
   mu_check((s = dlite_storage_open_url(url)));
   mu_assert_int_eq(0, dlite_storage_is_writable(s));
diff --git a/storages/json/tests/test_json_storage.c b/storages/json/tests/test_json_storage.c
index 34f9d47e6..e31b4479f 100644
--- a/storages/json/tests/test_json_storage.c
+++ b/storages/json/tests/test_json_storage.c
@@ -117,8 +117,9 @@ MU_TEST(test_load)
 
 MU_TEST(test_load2)
 {
-  char *url = "json://" STRINGIFY(DLITE_ROOT) "/src/tests/test-read-data.json"
-    "#dlite/1/test-c";
+  char *url = "json://"
+    STRINGIFY(DLITE_ROOT)  // cppcheck-suppress unknownMacro
+    "/src/tests/test-read-data.json#dlite/1/test-c";
   printf("\n--- test_load2: %s ---\n", url);
 
   DLiteInstance *inst2 = dlite_instance_load_url(url);
diff --git a/storages/python/tests-c/test_blob_storage.c b/storages/python/tests-c/test_blob_storage.c
index c752d8eb2..7621fe167 100644
--- a/storages/python/tests-c/test_blob_storage.c
+++ b/storages/python/tests-c/test_blob_storage.c
@@ -15,7 +15,8 @@ DLiteInstance *inst = NULL;
 
 MU_TEST(test_load)
 {
-  char *url = "blob://" STRINGIFY(CURRENT_SOURCE_DIR)
+  char *url = "blob://"
+    STRINGIFY(CURRENT_SOURCE_DIR)  // cppcheck-suppress unknownMacro
     "/test_blob_storage.c?mode=r";
   inst = dlite_instance_load_url(url);
   mu_check(inst);
diff --git a/storages/python/tests-c/test_bson_storage.c b/storages/python/tests-c/test_bson_storage.c
index b776b986d..8e0504371 100644
--- a/storages/python/tests-c/test_bson_storage.c
+++ b/storages/python/tests-c/test_bson_storage.c
@@ -9,8 +9,9 @@ MU_TEST(test_save)
   DLiteStorage* s = NULL;
 
   // Load JSON metadata
-  char* url
-	  = "json://" STRINGIFY(DLITE_ROOT) "/src/tests/test-entity.json?mode=r";
+  char* url =
+    "json://" STRINGIFY(DLITE_ROOT)  // cppcheck-suppress unknownMacro
+    "/src/tests/test-entity.json?mode=r";
   DLiteInstance* meta = (DLiteInstance*)dlite_meta_load_url(url);
   mu_check(meta);
   mu_check(dlite_instance_is_meta(meta));
diff --git a/storages/rdf/tests/test_rdf.c b/storages/rdf/tests/test_rdf.c
index 5e80abb6b..40babac7a 100644
--- a/storages/rdf/tests/test_rdf.c
+++ b/storages/rdf/tests/test_rdf.c
@@ -12,7 +12,9 @@ DLiteMeta *meta=NULL;
 MU_TEST(test_load_inst)
 {
   char *url;
-  url="json://"STRINGIFY(dlite_SOURCE_DIR)"/src/tests/test-entity.json?mode=r";
+  url = "json://"
+    STRINGIFY(dlite_SOURCE_DIR)  // cppcheck-suppress unknownMacro
+    "/src/tests/test-entity.json?mode=r";
   meta = dlite_meta_load_url(url);
   mu_check(meta);