From ce5688253e1ef06cd9551f563f70aab2cd487197 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sun, 6 Oct 2024 13:39:24 -0400 Subject: Add cppcheck lint test --- NEWS | 3 ++- meson.build | 1 + test/meson.build | 14 ++++++++++++++ 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index 071b177..13548b7 100644 --- a/NEWS +++ b/NEWS @@ -1,9 +1,10 @@ sratom (0.6.17) unstable; urgency=medium + * Add lint option with project metadata and code formatting tests * Enable clang nullability checks * Fix library current_version on MacOS - -- David Robillard Thu, 14 Mar 2024 17:00:24 +0000 + -- David Robillard Sun, 06 Oct 2024 17:37:06 +0000 sratom (0.6.16) stable; urgency=medium diff --git a/meson.build b/meson.build index 767322d..48f4675 100644 --- a/meson.build +++ b/meson.build @@ -15,6 +15,7 @@ project( ) sratom_src_root = meson.current_source_dir() +sratom_build_root = meson.current_build_dir() major_version = meson.project_version().split('.')[0] version_suffix = '-@0@'.format(major_version) versioned_name = 'sratom' + version_suffix diff --git a/test/meson.build b/test/meson.build index 337f26d..1e8b08f 100644 --- a/test/meson.build +++ b/test/meson.build @@ -38,6 +38,20 @@ if get_option('lint') if autoship.found() test('autoship', autoship, args: ['test', sratom_src_root], suite: 'data') endif + + # Check code with cppcheck + cppcheck = find_program('cppcheck', required: false) + if cppcheck.found() + compdb_path = join_paths(sratom_build_root, 'compile_commands.json') + cppcheck_args = [ + '--enable=warning,style,performance,portability', + '--error-exitcode=1', + '--project=' + compdb_path, + '--suppress=normalCheckLevelMaxBranches', + '-q', + ] + test('cppcheck', cppcheck, args: cppcheck_args, suite: 'code') + endif endif # Check licensing metadata -- cgit v1.2.1