Skip to content

Commit

Permalink
Merge pull request #11 from st235/feature/pedantic_warnings
Browse files Browse the repository at this point in the history
Enable pedantic warnings
  • Loading branch information
st235 authored Jul 10, 2024
2 parents cf05181 + e0d4983 commit 1ae91c6
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 7 deletions.
6 changes: 6 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ add_library(jsonc
src/json.cpp
)

if(MSVC)
target_compile_options(jsonc PRIVATE /W4 /WX)
else()
target_compile_options(jsonc PRIVATE -Wall -Wextra -Wpedantic -Werror)
endif()

set_property(TARGET jsonc PROPERTY COMPILE_WARNING_AS_ERROR ON)

target_include_directories(jsonc PUBLIC ${CMAKE_CURRENT_LIST_DIR}/include)
Expand Down
2 changes: 1 addition & 1 deletion include/json.h
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ class Json {
keys.insert(key);
}

return std::move(keys);
return keys;
}

bool add(const Json& that) {
Expand Down
2 changes: 1 addition & 1 deletion include/json_beautifier.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class JsonBeautifier: public JsonVisitor {
}

inline std::string beautifiedJson() const {
return std::move(_stream.str());
return _stream.str();
}

uint16_t _depth;
Expand Down
2 changes: 1 addition & 1 deletion include/json_minifier.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class JsonMinifier: public JsonVisitor {
}

inline std::string minifiedJson() const {
return std::move(_stream.str());
return _stream.str();
}

std::stringstream _stream;
Expand Down
8 changes: 4 additions & 4 deletions src/json.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,21 @@ const Json& Json::null() {
}

Json Json::array() {
return std::move(Json(array_t()));
return Json(array_t());
}

Json Json::object() {
return std::move(Json(object_t()));
return Json(object_t());
}

std::optional<Json> Json::fromJson(const std::string& json) {
__internal::JsonParser parser;
return std::move(parser.parse(json));
return parser.parse(json);
}

std::string Json::toJson(const Json& json) {
JsonMinifier minifier;
return std::move(minifier.minify(json));
return minifier.minify(json);
}

} // namespace json

0 comments on commit 1ae91c6

Please sign in to comment.