From 35f22e85962fb1b325ba595b7d696449fdd0c435 Mon Sep 17 00:00:00 2001 From: Niels Date: Wed, 17 Aug 2016 21:38:19 +0200 Subject: [PATCH 1/7] checking MSVC compiler flags --- test/CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 782d5b53f..9fe0327c8 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -38,8 +38,8 @@ add_executable(${JSON_UNITTEST_TARGET_NAME} set_target_properties(${JSON_UNITTEST_TARGET_NAME} PROPERTIES CXX_STANDARD 11 CXX_STANDARD_REQUIRED ON - COMPILE_DEFINITIONS "$<$:_SCL_SECURE_NO_WARNINGS>" - COMPILE_OPTIONS "$<$:/EHsc;$<$:/Od>>" + #COMPILE_DEFINITIONS "$<$:_SCL_SECURE_NO_WARNINGS>" + COMPILE_OPTIONS "$<$:/EHsc /Wall;$<$:/Od>>" ) target_include_directories(${JSON_UNITTEST_TARGET_NAME} PRIVATE "src") From c0922c7aac3ffacbfcde50eddb45ce23006e5b1e Mon Sep 17 00:00:00 2001 From: Niels Date: Wed, 17 Aug 2016 21:43:28 +0200 Subject: [PATCH 2/7] /Wall --- test/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 9fe0327c8..540d9db19 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -39,7 +39,7 @@ set_target_properties(${JSON_UNITTEST_TARGET_NAME} PROPERTIES CXX_STANDARD 11 CXX_STANDARD_REQUIRED ON #COMPILE_DEFINITIONS "$<$:_SCL_SECURE_NO_WARNINGS>" - COMPILE_OPTIONS "$<$:/EHsc /Wall;$<$:/Od>>" + COMPILE_OPTIONS "$<$:/EHsc;/Wall$<$:/Od>>" ) target_include_directories(${JSON_UNITTEST_TARGET_NAME} PRIVATE "src") From f40f81c87eb9cfb7b3983e8d71c9ec5ba82db87d Mon Sep 17 00:00:00 2001 From: Niels Date: Wed, 17 Aug 2016 21:44:53 +0200 Subject: [PATCH 3/7] forgot a semicolon --- test/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 540d9db19..febb06958 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -39,7 +39,7 @@ set_target_properties(${JSON_UNITTEST_TARGET_NAME} PROPERTIES CXX_STANDARD 11 CXX_STANDARD_REQUIRED ON #COMPILE_DEFINITIONS "$<$:_SCL_SECURE_NO_WARNINGS>" - COMPILE_OPTIONS "$<$:/EHsc;/Wall$<$:/Od>>" + COMPILE_OPTIONS "$<$:/EHsc;/Wall;$<$:/Od>>" ) target_include_directories(${JSON_UNITTEST_TARGET_NAME} PRIVATE "src") From 628a5eae500b8320aec3f0fbb4a5eba48d320e03 Mon Sep 17 00:00:00 2001 From: Niels Date: Wed, 17 Aug 2016 22:33:26 +0200 Subject: [PATCH 4/7] reset build file --- test/CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index febb06958..782d5b53f 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -38,8 +38,8 @@ add_executable(${JSON_UNITTEST_TARGET_NAME} set_target_properties(${JSON_UNITTEST_TARGET_NAME} PROPERTIES CXX_STANDARD 11 CXX_STANDARD_REQUIRED ON - #COMPILE_DEFINITIONS "$<$:_SCL_SECURE_NO_WARNINGS>" - COMPILE_OPTIONS "$<$:/EHsc;/Wall;$<$:/Od>>" + COMPILE_DEFINITIONS "$<$:_SCL_SECURE_NO_WARNINGS>" + COMPILE_OPTIONS "$<$:/EHsc;$<$:/Od>>" ) target_include_directories(${JSON_UNITTEST_TARGET_NAME} PRIVATE "src") From 039cedaf8e2884d136b70aae1f3a2b80640b2583 Mon Sep 17 00:00:00 2001 From: Niels Date: Wed, 17 Aug 2016 23:14:28 +0200 Subject: [PATCH 5/7] changes to address #295 --- src/json.hpp | 6 ++++-- src/json.hpp.re2c | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/json.hpp b/src/json.hpp index ddf37eb2e..a8289a495 100644 --- a/src/json.hpp +++ b/src/json.hpp @@ -8892,7 +8892,8 @@ basic_json_parser_63: { case lexer::token_type::begin_object: { - if (keep and (not callback or (keep = callback(depth++, parse_event_t::object_start, result)))) + if (keep and (not callback + or ((keep = callback(depth++, parse_event_t::object_start, result)) != 0))) { // explicitly set result to object to cope with {} result.m_type = value_t::object; @@ -8970,7 +8971,8 @@ basic_json_parser_63: case lexer::token_type::begin_array: { - if (keep and (not callback or (keep = callback(depth++, parse_event_t::array_start, result)))) + if (keep and (not callback + or ((keep = callback(depth++, parse_event_t::array_start, result)) != 0))) { // explicitly set result to object to cope with [] result.m_type = value_t::array; diff --git a/src/json.hpp.re2c b/src/json.hpp.re2c index 740c768c5..ffa20f39a 100644 --- a/src/json.hpp.re2c +++ b/src/json.hpp.re2c @@ -8189,7 +8189,8 @@ class basic_json { case lexer::token_type::begin_object: { - if (keep and (not callback or (keep = callback(depth++, parse_event_t::object_start, result)))) + if (keep and (not callback + or ((keep = callback(depth++, parse_event_t::object_start, result)) != 0))) { // explicitly set result to object to cope with {} result.m_type = value_t::object; @@ -8267,7 +8268,8 @@ class basic_json case lexer::token_type::begin_array: { - if (keep and (not callback or (keep = callback(depth++, parse_event_t::array_start, result)))) + if (keep and (not callback + or ((keep = callback(depth++, parse_event_t::array_start, result)) != 0))) { // explicitly set result to object to cope with [] result.m_type = value_t::array; From d2564c6100062476182006fc9e3ba34d2078facf Mon Sep 17 00:00:00 2001 From: Niels Date: Thu, 18 Aug 2016 18:29:19 +0200 Subject: [PATCH 6/7] added cppcheck target for travis --- .travis.yml | 14 ++++++++++++++ Makefile | 3 +-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index ad1d12d97..bd806cb89 100644 --- a/.travis.yml +++ b/.travis.yml @@ -41,6 +41,20 @@ matrix: after_success: - valgrind --error-exitcode=1 --leak-check=full test/json_unit + # cppcheck + + - os: linux + compiler: gcc + env: + - COMPILER=g++-4.9 + - SPECIAL=cppcheck + addons: + apt: + sources: ['ubuntu-toolchain-r-test'] + packages: [g++-4.9, cppcheck] + after_success: + - make cppcheck + # Coveralls (http://gronlier.fr/blog/2015/01/adding-code-coverage-to-your-c-project/) - os: linux diff --git a/Makefile b/Makefile index f08d5cf37..b53d8d3dc 100644 --- a/Makefile +++ b/Makefile @@ -64,8 +64,7 @@ fuzz: test/src/fuzz.cpp src/json.hpp # call cppcheck on the main header file cppcheck: - cppcheck --enable=all --inconclusive --std=c++11 src/json.hpp - + cppcheck --enable=warning --inconclusive --force --std=c++11 src/json.hpp --error-exitcode=1 ########################################################################## # maintainer targets From 0cf7ebaa57f83935398f466907e322062c167a4b Mon Sep 17 00:00:00 2001 From: Niels Date: Thu, 18 Aug 2016 18:43:27 +0200 Subject: [PATCH 7/7] mentioning the CII --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 73a03363b..3015e860a 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ There are myriads of [JSON](http://json.org) libraries out there, and each may e - **Trivial integration**. Our whole code consists of a single header file [`json.hpp`](https://github.com/nlohmann/json/blob/develop/src/json.hpp). That's it. No library, no subproject, no dependencies, no complex build system. The class is written in vanilla C++11. All in all, everything should require no adjustment of your compiler flags or project settings. -- **Serious testing**. Our class is heavily [unit-tested](https://github.com/nlohmann/json/blob/master/test/src/unit.cpp) and covers [100%](https://coveralls.io/r/nlohmann/json) of the code, including all exceptional behavior. Furthermore, we checked with [Valgrind](http://valgrind.org) that there are no memory leaks. +- **Serious testing**. Our class is heavily [unit-tested](https://github.com/nlohmann/json/blob/master/test/src/unit.cpp) and covers [100%](https://coveralls.io/r/nlohmann/json) of the code, including all exceptional behavior. Furthermore, we checked with [Valgrind](http://valgrind.org) that there are no memory leaks. To maintain high quality, the project is following the [Core Infrastructure Initiative (CII) best practices](https://bestpractices.coreinfrastructure.org/projects/289). Other aspects were not so important to us: