Автоматическая правка кода с помощью clazy

This commit is contained in:
Andrei Astafev 2020-04-18 21:56:16 +03:00
parent 0dbfda298f
commit 8defb4fbb4

View File

@ -4,7 +4,7 @@ function(add_clazy_check target)
set(_clazy_checks
"container-inside-loop,heap-allocated-small-trivial-type,inefficient-qlist,isempty-vs-count,qt-keywords,unneeded-cast"
)
set(_args -checks=level2,${_clazy_checks} -extra-arg="-Wno-unknown-warning-option")
set(_args -checks=level2,${_clazy_checks} -extra-arg="-Wno-unknown-warning-option" -export-fixes=clazy-fixes-file.yaml)
if(CLAZY_EXE)
if(NOT TARGET clazy-check)
@ -14,6 +14,30 @@ function(add_clazy_check target)
COMMAND ${CLAZY_EXE} ${_args} -p ${CMAKE_BINARY_DIR} ${_sources})
add_dependencies(clazy-check-${target} ${target})
add_dependencies(clazy-check clazy-check-${target})
option(CMLIB_CLAZY_FIX_STRING_ALLOCATIONS "Clazy allocations" OFF)
option(CMLIB_CLAZY_FIX_OLD_STYLE_CONNECT "Clazy old style connect" OFF)
if (CMLIB_CLAZY_FIX_STRING_ALLOCATIONS OR CMLIB_CLAZY_FIX_OLD_STYLE_CONNECT)
if(NOT TARGET clazy-fix)
add_custom_target(clazy-fix)
endif()
if(CMLIB_CLAZY_FIX_STRING_ALLOCATIONS)
add_custom_target(clazy-fix-string-${target} WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
COMMAND ${CMAKE_COMMAND} -E env "CLAZY_FIXIT=fix-qlatin1string-allocations"
${CLAZY_EXE} ${_args} -p ${CMAKE_BINARY_DIR} ${_sources})
add_dependencies(clazy-fix-string-${target} ${target})
add_dependencies(clazy-fix clazy-fix-string-${target})
endif()
if(CMLIB_CLAZY_FIX_OLD_STYLE_CONNECT)
add_custom_target(clazy-fix-old-style-connect-${target} WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
COMMAND ${CMAKE_COMMAND} -E env "CLAZY_FIXIT=fix-old-style-connect"
${CLAZY_EXE} ${_args} -p ${CMAKE_BINARY_DIR} ${_sources})
add_dependencies(clazy-fix-old-style-connect-${target} ${target})
add_dependencies(clazy-fix clazy-fix-old-style-connect-${target})
endif()
endif()
else()
message(STATUS "CMLIB warning:")
message(STATUS " Clazy standalone analyzer is not found")