From b1eaa443f25e25741c95b083ee48c68899d6d180 Mon Sep 17 00:00:00 2001 From: Timm Fitschen <t.fitschen@indiscale.com> Date: Thu, 22 Jul 2021 22:25:53 +0200 Subject: [PATCH] WIP: fix pedantic warnings --- CMakeLists.txt | 3 --- test/CMakeLists.txt | 30 +++++++++++++++++++++++++++++- test/test_ccaosdb.cpp | 2 +- test/test_connection.cpp | 30 ++++++++++++++++++------------ test/test_transaction.cpp | 6 +++--- 5 files changed, 51 insertions(+), 20 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 681fb86..31b42d2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -42,9 +42,6 @@ string(REGEX REPLACE "grpc\\+?\\+?_unsecure" "" CONAN_LIBS string(REGEX REPLACE "grpc\\+?\\+?_unsecure" "" CONAN_PKG_LIBS "${CONAN_PKG_LIBS}") -# ignore some warnings here -add_compile_options(-Wno-unused-parameter -Wno-unused-result -g) - set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH}) enable_testing() diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 49dde42..23ef7d4 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -27,11 +27,39 @@ set(test_cases test_ccaosdb ) + +include(CheckCXXCompilerFlag) +include(CheckCCompilerFlag) + +function(add_compiler_flag flag) + string(FIND "${CMAKE_CXX_FLAGS}" "${flag}" cxx_present) + if(cxx_present EQUAL -1) + check_cxx_compiler_flag("${flag}" flag_supported) + if(flag_supported) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${flag}" PARENT_SCOPE) + endif() + unset(flag_supported CACHE) + endif() + unset(cxx_present CACHE) +endfunction() + +### but ignore these +add_compiler_flag("-Wno-unused-parameter") +add_compiler_flag("-Wno-unused-result") +add_compiler_flag("-g") + ####################################################### ### Linting with clang-tidy and include-what-you-use ####################################################### option(LINTING "clang-tidy and iwye" ON) if(LINTING) + ### set paranoid compiler flags + #add_compiler_flag("-Wall") + #add_compiler_flag("-Wextra") + #add_compiler_flag("-pedantic") + #add_compiler_flag("-Werror") + + find_program(iwyu NAMES include-what-you-use iwyu PATHS ${CMAKE_SOURCE_DIR}/tools/include-what-you-use/${iwyu_os}/bin) @@ -54,7 +82,7 @@ if(LINTING) "--warnings-as-errors=*" "--fix") set(_CMAKE_CXX_CLANG_TIDY_CHECKS - "--checks=*,-fuchsia-*,-llvm-include-order,-llvmlibc-*,-cert-err58-cpp,-cppcoreguidelines-avoid-non-const-global-variables,-cppcoreguidelines-owning-memory,-modernize-use-trailing-return-type,-google-readability-avoid-underscore-in-googletest-name,-cppcoreguidelines-avoid-magic-numbers,-readability-magic-numbers,-cppcoreguidelines-avoid-goto,-hicpp-avoid-goto") + "--checks=*,-fuchsia-*,-llvmlibc-*,-cert-err58-cpp,-cppcoreguidelines-avoid-non-const-global-variables,-cppcoreguidelines-owning-memory,-modernize-use-trailing-return-type,-google-readability-avoid-underscore-in-googletest-name,-cppcoreguidelines-avoid-magic-numbers,-readability-magic-numbers,-cppcoreguidelines-avoid-goto,-hicpp-avoid-goto") endif() else() message(STATUS "LINTING is OFF") diff --git a/test/test_ccaosdb.cpp b/test/test_ccaosdb.cpp index 3b99e8e..1bf3342 100644 --- a/test/test_ccaosdb.cpp +++ b/test/test_ccaosdb.cpp @@ -17,11 +17,11 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <https://www.gnu.org/licenses/>. */ -#include <memory> // for allocator, unique_ptr #include "ccaosdb.h" // for caosdb_info_version_info, caosdb_... #include "gtest/gtest-message.h" // for Message #include "gtest/gtest-test-part.h" // for TestPartResult #include "gtest/gtest_pred_impl.h" // for Test, EXPECT_EQ, SuiteApiResolver +#include <memory> // for allocator, unique_ptr TEST(test_ccaosdb, connection_ssl_authentication_success) { diff --git a/test/test_connection.cpp b/test/test_connection.cpp index 08eec66..2562998 100644 --- a/test/test_connection.cpp +++ b/test/test_connection.cpp @@ -18,21 +18,27 @@ * along with this program. If not, see <https://www.gnu.org/licenses/>. * */ -#include <gtest/gtest-message.h> // for Message -#include <gtest/gtest-test-part.h> // for SuiteApiResolver, TestPartResult -#include <memory> // for make_shared, allocator, shared_ptr -#include <string> // for string -#include "caosdb/authentication.h" // for PlainPasswordAuthenticator -#include "caosdb/connection.h" // for InsecureConnectionConfiguration -#include "caosdb/exceptions.h" // for AuthenticationError, ConnectionError -#include "caosdb/info.h" // for VersionInfo -#include "caosdb/utility.h" // for get_env_var -#include "gtest/gtest_pred_impl.h" // for Test, TEST, EXPECT_EQ, EXPECT_THROW -#include "caosdb_test_utility.h" -#include "caosdb/constants.h" +#include <gtest/gtest-message.h> // for Message +#include <gtest/gtest-test-part.h> // for SuiteApiResolver, TestPartR... +#include <memory> // for allocator, unique_ptr, __sh... +#include <string> // for stoi, string +#include "boost/filesystem/path.hpp" // for path +#include "caosdb/authentication.h" // for PlainPasswordAuthenticator +#include "caosdb/certificate_provider.h" // for PemFileCertificateProvider +#include "caosdb/configuration.h" // for InsecureConnectionConfigura... +#include "caosdb/connection.h" // for Connection, VersionInfo, path +#include "caosdb/constants.h" // for COMPATIBLE_SERVER_VERSION_M... +#include "caosdb/exceptions.h" // for AuthenticationError, Connec... +#include "caosdb/info.h" // for VersionInfo +#include "caosdb/utility.h" // for get_env_var +#include "caosdb_test_utility.h" // for EXPECT_THROW_MESSAGE +#include "gtest/gtest_pred_impl.h" // for Test, TestInfo, TEST, EXPEC... namespace caosdb::connection { using caosdb::authentication::PlainPasswordAuthenticator; +using caosdb::configuration::InsecureConnectionConfiguration; +using caosdb::configuration::PemFileCertificateProvider; +using caosdb::configuration::TlsConnectionConfiguration; using caosdb::exceptions::AuthenticationError; using caosdb::exceptions::ConnectionError; diff --git a/test/test_transaction.cpp b/test/test_transaction.cpp index ec59df9..343b888 100644 --- a/test/test_transaction.cpp +++ b/test/test_transaction.cpp @@ -18,13 +18,13 @@ * along with this program. If not, see <https://www.gnu.org/licenses/>. * */ -#include <gtest/gtest-message.h> // for Message -#include <gtest/gtest-test-part.h> // for SuiteApiResolver, TestFactoryImpl -#include <memory> // for allocator, static_pointer_cast #include "caosdb/connection.h" // for CaosDBConnection #include "caosdb/entity.h" // for Entity, EntityID #include "caosdb/transaction.h" // for Transaction, UniqueResult, Entity +#include <gtest/gtest-message.h> // for Message +#include <gtest/gtest-test-part.h> // for SuiteApiResolver, TestFactoryImpl #include "gtest/gtest_pred_impl.h" // for Test, TestInfo, EXPECT_EQ, TEST +#include <memory> // for allocator, static_pointer_cast namespace caosdb::transaction { -- GitLab