Skip to content

clang-tidy cleanups 2 #1048

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Oct 15, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions include/json/value.h
Original file line number Diff line number Diff line change
Expand Up @@ -657,7 +657,7 @@ class JSON_API Value {
Comments& operator=(Comments&& that);
bool has(CommentPlacement slot) const;
String get(CommentPlacement slot) const;
void set(CommentPlacement slot, String s);
void set(CommentPlacement slot, String comment);

private:
using Array = std::array<String, numberOfCommentPlacement>;
Expand All @@ -681,7 +681,7 @@ class JSON_API PathArgument {
PathArgument();
PathArgument(ArrayIndex index);
PathArgument(const char* key);
PathArgument(const String& key);
PathArgument(String key);

private:
enum Kind { kindNone = 0, kindIndex, kindKey };
Expand Down
2 changes: 1 addition & 1 deletion src/lib_json/json_reader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -889,7 +889,7 @@ class OurReader {
String message;
};

OurReader(OurFeatures const& features);
explicit OurReader(OurFeatures const& features);
bool parse(const char* beginDoc, const char* endDoc, Value& root,
bool collectComments = true);
String getFormattedErrorMessages() const;
Expand Down
26 changes: 11 additions & 15 deletions src/lib_json/json_value.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ namespace Json {

#if JSON_USE_EXCEPTION
Exception::Exception(String msg) : msg_(std::move(msg)) {}
Exception::~Exception() JSONCPP_NOEXCEPT {}
Exception::~Exception() JSONCPP_NOEXCEPT = default;
char const* Exception::what() const JSONCPP_NOEXCEPT { return msg_.c_str(); }
RuntimeError::RuntimeError(String const& msg) : Exception(msg) {}
LogicError::LogicError(String const& msg) : Exception(msg) {}
Expand Down Expand Up @@ -261,7 +261,7 @@ Value::CZString::CZString(CZString&& other)
Value::CZString::~CZString() {
if (cstr_ && storage_.policy_ == duplicate) {
releaseStringValue(const_cast<char*>(cstr_),
storage_.length_ + 1u); // +1 for null terminating
storage_.length_ + 1U); // +1 for null terminating
// character for sake of
// completeness but not actually
// necessary
Expand Down Expand Up @@ -492,7 +492,7 @@ int Value::compare(const Value& other) const {
bool Value::operator<(const Value& other) const {
int typeDelta = type() - other.type();
if (typeDelta)
return typeDelta < 0 ? true : false;
return typeDelta < 0;
switch (type()) {
case nullValue:
return false;
Expand All @@ -506,10 +506,7 @@ bool Value::operator<(const Value& other) const {
return value_.bool_ < other.value_.bool_;
case stringValue: {
if ((value_.string_ == nullptr) || (other.value_.string_ == nullptr)) {
if (other.value_.string_)
return true;
else
return false;
return other.value_.string_ != nullptr;
}
unsigned this_len;
unsigned other_len;
Expand Down Expand Up @@ -807,7 +804,7 @@ float Value::asFloat() const {
case nullValue:
return 0.0;
case booleanValue:
return value_.bool_ ? 1.0f : 0.0f;
return value_.bool_ ? 1.0F : 0.0F;
default:
break;
}
Expand All @@ -821,9 +818,9 @@ bool Value::asBool() const {
case nullValue:
return false;
case intValue:
return value_.int_ ? true : false;
return value_.int_ != 0;
case uintValue:
return value_.uint_ ? true : false;
return value_.uint_ != 0;
case realValue: {
// According to JavaScript language zero or NaN is regarded as false
const auto value_classification = std::fpclassify(value_.real_);
Expand All @@ -839,7 +836,7 @@ bool Value::isConvertibleTo(ValueType other) const {
switch (other) {
case nullValue:
return (isNumeric() && asDouble() == 0.0) ||
(type() == booleanValue && value_.bool_ == false) ||
(type() == booleanValue && !value_.bool_) ||
(type() == stringValue && asString().empty()) ||
(type() == arrayValue && value_.map_->empty()) ||
(type() == objectValue && value_.map_->empty()) ||
Expand Down Expand Up @@ -894,7 +891,7 @@ ArrayIndex Value::size() const {

bool Value::empty() const {
if (isNull() || isArray() || isObject())
return size() == 0u;
return size() == 0U;
else
return false;
}
Expand Down Expand Up @@ -1543,15 +1540,14 @@ Value::iterator Value::end() {
// class PathArgument
// //////////////////////////////////////////////////////////////////

PathArgument::PathArgument() {}
PathArgument::PathArgument() = default;

PathArgument::PathArgument(ArrayIndex index)
: index_(index), kind_(kindIndex) {}

PathArgument::PathArgument(const char* key) : key_(key), kind_(kindKey) {}

PathArgument::PathArgument(const String& key)
: key_(key.c_str()), kind_(kindKey) {}
PathArgument::PathArgument(String key) : key_(std::move(key)), kind_(kindKey) {}

// class Path
// //////////////////////////////////////////////////////////////////
Expand Down