Skip to content

Commit

Permalink
Start adding support for static analysis and closing out analysis-det…
Browse files Browse the repository at this point in the history
…ected defects.
  • Loading branch information
iainchesworth committed Feb 9, 2024
1 parent 13fb61a commit 9481ff1
Show file tree
Hide file tree
Showing 86 changed files with 913 additions and 189 deletions.
13 changes: 13 additions & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Checks: "
bugprone-*,
clang-diagnostic-*,
clang-analyzer-*,
modernize-*,
performance-*,
readability-*
"
WarningsAsErrors: ""
HeaderFilterRegex: ""
CheckOptions:
- key: readability-identifier-naming.PrivateMemberSuffix
value: "_"
51 changes: 36 additions & 15 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake" "${CMAKE_SOURCE_DIR}/cmake/tools/" "${CMAKE_SOURCE_DIR}/cmake/tools/coverage" "${CMAKE_SOURCE_DIR}/deps" "${CMAKE_SOURCE_DIR}/deps/sanitizers-cmake/cmake")
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake" "${CMAKE_SOURCE_DIR}/cmake/tools/" "${CMAKE_SOURCE_DIR}/cmake/tools/" "${CMAKE_SOURCE_DIR}/cmake/tools/coverage" "${CMAKE_SOURCE_DIR}/deps" "${CMAKE_SOURCE_DIR}/deps/sanitizers-cmake/cmake")

project(
aqualink-automate
Expand All @@ -18,7 +18,8 @@ option(ENABLE_BENCHMARKS "Enable performance tests" ON)
option(ENABLE_COVERAGE "Enable coverage of unit tests" OFF)
option(ENABLE_TESTS "Enable unit tests" ON)
option(ENABLE_PROFILING "DevTools: Enable profiling tooling" ON)
option(ENABLE_CLANG_TIDY "DevTools: Enable Clang-Tidy analysis" ON)
option(ENABLE_CLANG_TIDY "DevTools: Enable static analysis using clang-tidy" ON)
option(ENABLE_PVS_STUDIO "DevTools: Enable static analysis using PVS-Studio" ON)
option(ENABLE_ASIO_TRACKING "DevTools: Debug using ASIO connection tracking" OFF)
cmake_dependent_option(ENABLE_SANITIZERS "DevTools: Enable sanitizer tooling" ON "NOT ENABLE_PROFILING" OFF)

Expand Down Expand Up @@ -99,19 +100,6 @@ endif(ENABLE_SANITIZERS)
#
#------------------------------------------------------------------------------

if(ENABLE_CLANG_TIDY)

find_package(ClangTidy)

endif(ENABLE_CLANG_TIDY)

#------------------------------------------------------------------------------
#
#
#
#
#------------------------------------------------------------------------------

# Template the git commit information prior to building the application.
set(GIT_FAIL_IF_NONZERO_EXIT false)
set(PRE_CONFIGURE_FILE "src/version/version_git.constants.cpp.in")
Expand Down Expand Up @@ -572,6 +560,39 @@ target_link_libraries(
"$<LINK_LIBRARY:WHOLE_ARCHIVE,libaqualink-automate>"
)

#------------------------------------------------------------------------------
#
# STATIC ANALYSIS CONFIGURATION
# =============================
#
#------------------------------------------------------------------------------

if(ENABLE_CLANG_TIDY)

find_package(ClangTidy)

set_target_properties(aqualink-automate PROPERTIES CXX_CLANG_TIDY "${CMAKE_CXX_CLANG_TIDY}")

endif(ENABLE_CLANG_TIDY)

if(ENABLE_PVS_STUDIO)

include(PVS-Studio)

pvs_studio_add_target(
ALL
TARGET aqualink-automate.analyze
ANALYZE aqualink-automate libaqualink-automate
OUTPUT
LOG "${CMAKE_CURRENT_BINARY_DIR}/aqualink-automate.pvs-studio.log"
FORMAT fullhtml
MODE 64+GA+OP+CS+MISRA+AUTOSAR+OWASP
SOURCES "${CMAKE_SOURCE_DIR}/src"
ARGS --exclude-path "${CMAKE_SOURCE_DIR}/build"
)

endif(ENABLE_PVS_STUDIO)

#------------------------------------------------------------------------------
#
#
Expand Down
1 change: 1 addition & 0 deletions CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"ENABLE_COVERAGE": "OFF",
"ENABLE_TESTS": "ON",
"ENABLE_CLANG_TIDY": "OFF",
"ENABLE_PVS_STUDIO": "OFF",
"ENABLE_PROFILING": "OFF",
"ENABLE_SANITIZERS": "OFF",
"ENABLE_ASIO_TRACKING": "OFF",
Expand Down
4 changes: 3 additions & 1 deletion CMakeUserPresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,9 @@
"rhs": "Windows"
},
"cacheVariables": {
"ENABLE_ASIO_TRACKING": "OFF"
"ENABLE_ASIO_TRACKING": "OFF",
"ENABLE_CLANG_TIDY": "ON",
"ENABLE_PVS_STUDIO": "ON"
}
}
],
Expand Down
Loading

0 comments on commit 9481ff1

Please sign in to comment.