From 97204363b56fa941a7c688b93fc214b81e007b71 Mon Sep 17 00:00:00 2001 From: Sean Robinson Date: Mon, 7 Feb 2022 11:51:22 -0700 Subject: [PATCH] Refactor configuration for StaticAnalysis Upstream StaticAnalysis looks to be changing for more flexibility with source files to process. While these changes may eventually benefit argparse, the public interfaces are in flux and we need a stable tool. argparse also needs a SA change which is not yet upstream. Trying to run clang-tidy via StaticAnalysis on a single file in a directory with many source file is not easy, so move the analysis kernel to a location (i.e. tools) where it is the only C++ source file. Another benefit is cppcheck no longer needs to be told to ignore the test sources. Signed-off-by: Sean Robinson --- .github/workflows/static_analysis.yml | 4 +--- test/CMakeLists.txt | 7 ------- tools/CMakeLists.txt | 10 ++++++++++ tools/static_analysis_setup.sh | 4 ++-- {test => tools}/tidy-base.cpp | 0 5 files changed, 13 insertions(+), 12 deletions(-) create mode 100644 tools/CMakeLists.txt rename {test => tools}/tidy-base.cpp (100%) diff --git a/.github/workflows/static_analysis.yml b/.github/workflows/static_analysis.yml index d5a2e50..2724a71 100644 --- a/.github/workflows/static_analysis.yml +++ b/.github/workflows/static_analysis.yml @@ -28,15 +28,13 @@ jobs: uses: actions/checkout@v2 - name: Analyze - uses: JacobDomagala/StaticAnalysis@master + uses: skrobinson/StaticAnalysis@stable-for-argparse with: clang_tidy_args: >- --config-file=$GITHUB_WORKSPACE/.clang-tidy --extra-arg=-I$GITHUB_WORKSPACE/include --extra-arg=-std=c++17 cppcheck_args: >- --enable=all --inconclusive --inline-suppr - -i$GITHUB_WORKSPACE/test/main.cpp - -i$GITHUB_WORKSPACE/test/test_*.cpp --suppress=missingInclude --suppress='*:$GITHUB_WORKSPACE/test/doctest.hpp' init_script: tools/static_analysis_setup.sh diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 02572a0..3c502d9 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -57,10 +57,3 @@ set_property(TARGET ARGPARSE PROPERTY CXX_STANDARD 17) # Set ${PROJECT_NAME} as the startup project set_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT ARGPARSE) - -file(GLOB ARGPARSE_LINT_SOURCES - tidy-base.cpp -) -ADD_EXECUTABLE(ARGPARSE_LINT ${ARGPARSE_LINT_SOURCES}) -set_target_properties(ARGPARSE_LINT PROPERTIES OUTPUT_NAME tidy-base) -set_property(TARGET ARGPARSE_LINT PROPERTY CXX_STANDARD 17) diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt new file mode 100644 index 0000000..cff613b --- /dev/null +++ b/tools/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.12) +project(argparse) + +file(GLOB ARGPARSE_LINT_SOURCES + tidy-base.cpp +) +ADD_EXECUTABLE(ARGPARSE_LINT ${ARGPARSE_LINT_SOURCES}) +set_target_properties(ARGPARSE_LINT PROPERTIES OUTPUT_NAME tidy-base) +set_property(TARGET ARGPARSE_LINT PROPERTY CXX_STANDARD 17) +INCLUDE_DIRECTORIES("../include" ".") diff --git a/tools/static_analysis_setup.sh b/tools/static_analysis_setup.sh index cd0dc06..350eb82 100755 --- a/tools/static_analysis_setup.sh +++ b/tools/static_analysis_setup.sh @@ -1,4 +1,4 @@ #!/bin/bash -# Change to the "test" subdir before "build" subdir is made. -cd test +# Change to the "tools" subdir before "build" subdir is made. +cd tools diff --git a/test/tidy-base.cpp b/tools/tidy-base.cpp similarity index 100% rename from test/tidy-base.cpp rename to tools/tidy-base.cpp