Get rid of broken vera++, integrate clang-tidy
This commit is contained in:
parent
f139efba6d
commit
0c5c680f62
|
@ -1,3 +0,0 @@
|
||||||
[submodule "vera++"]
|
|
||||||
path = vera++
|
|
||||||
url = https://bitbucket.org/verateam/vera.git
|
|
|
@ -3,7 +3,7 @@ cmake_minimum_required (VERSION 3.10)
|
||||||
project (logdiag VERSION 0.2.1 LANGUAGES C)
|
project (logdiag VERSION 0.2.1 LANGUAGES C)
|
||||||
|
|
||||||
# Options
|
# Options
|
||||||
option (OPTION_USE_VERA "Use vera++ for source code style checks" OFF)
|
option (OPTION_CLANG_TIDY "Enable use of clang-tidy" OFF)
|
||||||
option (OPTION_NOINSTALL "For developers only--work without installing" OFF)
|
option (OPTION_NOINSTALL "For developers only--work without installing" OFF)
|
||||||
option (OPTION_GTKDOC "For developers only--enable use of gtk-doc" OFF)
|
option (OPTION_GTKDOC "For developers only--enable use of gtk-doc" OFF)
|
||||||
option (BUILD_TESTING "Build tests" OFF)
|
option (BUILD_TESTING "Build tests" OFF)
|
||||||
|
@ -266,42 +266,38 @@ find_package (CppCheck)
|
||||||
GENERATE_CPPCHECK (SOURCES liblogdiag src tests ENABLE_IDS all
|
GENERATE_CPPCHECK (SOURCES liblogdiag src tests ENABLE_IDS all
|
||||||
TARGET_NAME ${PROJECT_NAME}_cppcheck INCLUDES ${PROJECT_BINARY_DIR})
|
TARGET_NAME ${PROJECT_NAME}_cppcheck INCLUDES ${PROJECT_BINARY_DIR})
|
||||||
|
|
||||||
if (OPTION_USE_VERA)
|
# Various clang-based diagnostics, loads of fake positives and spam
|
||||||
# Force this off, we don't need it
|
if (OPTION_CLANG_TIDY)
|
||||||
option (VERA_LUA "" OFF)
|
set (clang_tidy_checks
|
||||||
|
clang-analyzer-* bugprone-* misc-* readability-* performance-*
|
||||||
|
-bugprone-reserved-identifier # GObject
|
||||||
|
-performance-no-int-to-ptr # GObject
|
||||||
|
-bugprone-narrowing-conversions
|
||||||
|
-bugprone-macro-parentheses # too coarse-grained
|
||||||
|
-readability-braces-around-statements # fine by me
|
||||||
|
-readability-isolate-declaration # fine by me
|
||||||
|
-readability-magic-numbers # too coarse-grained
|
||||||
|
-misc-unused-parameters) # fine by me
|
||||||
|
|
||||||
# Make it build within the same build tree
|
string (REPLACE ";" "," clang_tidy_checks "${clang_tidy_checks}")
|
||||||
get_directory_property (backup_includes INCLUDE_DIRECTORIES)
|
set (clang_tidy_config "{
|
||||||
set_directory_properties (PROPERTIES INCLUDE_DIRECTORIES "")
|
Checks: '${clang_tidy_checks}',
|
||||||
set (backup_source_dir "${CMAKE_SOURCE_DIR}")
|
CheckOptions: [{
|
||||||
set (CMAKE_SOURCE_DIR "${CMAKE_SOURCE_DIR}/vera++")
|
key: readability-function-cognitive-complexity.Threshold,
|
||||||
|
value: '30'
|
||||||
|
}]}")
|
||||||
|
|
||||||
add_subdirectory ("vera++")
|
string (REPLACE "\n" " " clang_tidy_config "${clang_tidy_config}")
|
||||||
|
|
||||||
set_directory_properties (PROPERTIES INCLUDE_DIRECTORIES "${backup_includes}")
|
set (CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
||||||
set (CMAKE_SOURCE_DIR "${backup_source_dir}")
|
set (clang_tidy_sources ${liblogdiag_SOURCES} ${logdiag_SOURCES})
|
||||||
|
add_custom_target (${PROJECT_NAME}_clang_tidy
|
||||||
# Check the sources
|
COMMAND clang-tidy --quiet -p ${PROJECT_BINARY_DIR}
|
||||||
# XXX: maybe do it per source file and not all at once
|
"--config=${clang_tidy_config}" ${clang_tidy_sources}
|
||||||
set (vera_srcs ${liblogdiag_SOURCES} ${logdiag_SOURCES} ${logdiag_HEADERS})
|
| sh -c "cat 1>&2"
|
||||||
set (vera_output ${PROJECT_BINARY_DIR}/vera.log)
|
DEPENDS ${clang_tidy_sources} VERBATIM
|
||||||
add_custom_command (OUTPUT ${vera_output}
|
USES_TERMINAL WORKING_DIRECTORY ${PROJECT_SOURCE_DIR})
|
||||||
COMMAND vera
|
endif ()
|
||||||
-R F001 -R L001 -R T001 -R T004 -R T005 -R T006
|
|
||||||
-R T007 -R T009 -R T010 -R T015 -R T017 -R T018
|
|
||||||
-R L004 -P max-line-length=80
|
|
||||||
-R L005 -P max-consecutive-empty-lines=2
|
|
||||||
--root ${CMAKE_SOURCE_DIR}/vera++
|
|
||||||
--std-report=-
|
|
||||||
--std-report=${vera_output}
|
|
||||||
--warning -s
|
|
||||||
${vera_srcs}
|
|
||||||
DEPENDS ${vera_srcs}
|
|
||||||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
|
||||||
COMMENT "Checking style for logdiag")
|
|
||||||
|
|
||||||
add_custom_target (logdiag_vera ALL DEPENDS ${vera_output})
|
|
||||||
endif (OPTION_USE_VERA)
|
|
||||||
|
|
||||||
# GSettings
|
# GSettings
|
||||||
find_program (GLIB_COMPILE_SCHEMAS_EXECUTABLE glib-compile-schemas)
|
find_program (GLIB_COMPILE_SCHEMAS_EXECUTABLE glib-compile-schemas)
|
||||||
|
|
1
vera++
1
vera++
|
@ -1 +0,0 @@
|
||||||
Subproject commit 45f3ab870d3722891642098bd7fc0d6fc97c8571
|
|
Loading…
Reference in New Issue