Browse Source

Linting: Additional fixes and cleanup

Stefan Profanter 5 years ago
parent
commit
58d08d5dc2
4 changed files with 27 additions and 29 deletions
  1. 0 1
      CMakeLists.txt
  2. 1 0
      CPPLINT.cfg
  3. 0 20
      tools/cmake/linting_build.cmake
  4. 26 8
      tools/cmake/linting_target.cmake

+ 0 - 1
CMakeLists.txt

@@ -1228,7 +1228,6 @@ set_property(GLOBAL PROPERTY PREDEFINED_TARGETS_FOLDER "_CmakePredifinedTargets"
 
 set_target_properties(open62541 PROPERTIES FOLDER "open62541/lib")
 set_target_properties(open62541-object PROPERTIES FOLDER "open62541/lib")
-set_target_properties(clang-tidy PROPERTIES FOLDER "CodeAnalysis")
 if (UA_ENABLE_AMALGAMATION)
     set_target_properties(open62541-amalgamation-header PROPERTIES FOLDER "open62541/lib")
     set_target_properties(open62541-amalgamation-source PROPERTIES FOLDER "open62541/lib")

+ 1 - 0
CPPLINT.cfg

@@ -15,6 +15,7 @@ filter=-readability/alt_tokens
 filter=-runtime/indentation_namespace
 filter=-whitespace/comments
 filter=-whitespace/blank_line
+filter=-whitespace/parens
 filter=-readability/braces
 exclude_files=deps/*
 exclude_files=build/*

+ 0 - 20
tools/cmake/linting_build.cmake

@@ -31,23 +31,3 @@ elseif(UA_ENABLE_STATIC_ANALYZER STREQUAL FULL)
     endif()
 endif()
 
-# adds new target "clangformat" to enforce clang-format rules
-find_program(CLANG_FORMAT_EXE NAMES "clang-format")
-if(CLANG_FORMAT_EXE)
-  file(GLOB_RECURSE FILES_TO_FORMAT
-       ${PROJECT_SOURCE_DIR}/arch/*.c
-       ${PROJECT_SOURCE_DIR}/plugins/*.c
-       ${PROJECT_SOURCE_DIR}/src/*.c
-       ${PROJECT_SOURCE_DIR}/arch/*.h
-       ${PROJECT_SOURCE_DIR}/include/*.h
-       ${PROJECT_SOURCE_DIR}/plugins/*.h
-       ${PROJECT_SOURCE_DIR}/src/*.h
-    )
-  add_custom_target(
-    clangformat COMMAND ${CLANG_FORMAT_EXE}
-        -style=file
-        -i
-        ${FILES_TO_FORMAT}
-  )
-endif()
-

+ 26 - 8
tools/cmake/linting_target.cmake

@@ -1,18 +1,14 @@
 find_package(ClangTools)
+# clang-tidy uses the compile_commands.json file for include dirs and other config
 add_custom_target(clang-tidy ${CLANG_TIDY_PROGRAM}
-                  ${lib_sources}
                   -p=compile_commands.json
+                  -format-style=file
                   --
-                  -I${PROJECT_SOURCE_DIR}/include
-                  -I${PROJECT_SOURCE_DIR}/plugins
-                  -I${PROJECT_SOURCE_DIR}/deps
-                  -I${PROJECT_SOURCE_DIR}/src
-                  -I${PROJECT_SOURCE_DIR}/src/server
-                  -I${PROJECT_SOURCE_DIR}/src/client
-                  -I${PROJECT_BINARY_DIR}/src_generated
+                  ${lib_sources}
                   DEPENDS ${lib_sources}
                   COMMENT "Run clang-tidy on the library")
 add_dependencies(clang-tidy open62541)
+set_target_properties(clang-tidy PROPERTIES FOLDER "CodeAnalysis")
 
 add_custom_target(cpplint cpplint
                   ${lib_sources}
@@ -28,3 +24,25 @@ add_custom_target(cpplint cpplint
                           ${ua_architecture_headers}
                           ${ua_architecture_sources}
                   COMMENT "Run cpplint code style checker on the library")
+set_target_properties(cpplint PROPERTIES FOLDER "CodeAnalysis")
+
+
+# adds new target "clang-format" to enforce clang-format rules
+find_program(CLANG_FORMAT_EXE NAMES "clang-format")
+if(CLANG_FORMAT_EXE)
+    file(GLOB_RECURSE FILES_TO_FORMAT
+         ${PROJECT_SOURCE_DIR}/arch/*.c
+         ${PROJECT_SOURCE_DIR}/plugins/*.c
+         ${PROJECT_SOURCE_DIR}/src/*.c
+         ${PROJECT_SOURCE_DIR}/arch/*.h
+         ${PROJECT_SOURCE_DIR}/include/*.h
+         ${PROJECT_SOURCE_DIR}/plugins/*.h
+         ${PROJECT_SOURCE_DIR}/src/*.h
+         )
+    add_custom_target(
+        clang-format COMMAND ${CLANG_FORMAT_EXE}
+        -style=file
+        -i
+        ${FILES_TO_FORMAT}
+    )
+endif()