Skip to content

Commit

Permalink
Fix clang-tidy warnings (#1231)
Browse files Browse the repository at this point in the history
* Fix clang-tidy warnings

Signed-off-by: Marcel Opprecht <[email protected]>

* Fixup/clang-format

Co-authored-by: Marcel Opprecht <[email protected]>
Co-authored-by: Jordan Bayles <[email protected]>
  • Loading branch information
3 people authored Nov 6, 2020
1 parent 30170d6 commit ceae0e3
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 15 deletions.
4 changes: 3 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,9 @@ bool Reader::decodeNumber(Token& token) {
```
Before submitting your code, ensure that you meet the versioning requirements above, follow the style guide of the file you are modifying (or the above rules for new files), and run clang format. Meson exposes clang format with the following command:
```
ninja -v -C build-${LIB_TYPE}/ clang-format
```
For convenience, you can also run the `reformat.sh` script located in the root directory.
12 changes: 6 additions & 6 deletions include/json/value.h
Original file line number Diff line number Diff line change
Expand Up @@ -263,10 +263,10 @@ class JSON_API Value {
CZString(ArrayIndex index);
CZString(char const* str, unsigned length, DuplicationPolicy allocate);
CZString(CZString const& other);
CZString(CZString&& other);
CZString(CZString&& other) noexcept;
~CZString();
CZString& operator=(const CZString& other);
CZString& operator=(CZString&& other);
CZString& operator=(CZString&& other) noexcept;

bool operator<(CZString const& other) const;
bool operator==(CZString const& other) const;
Expand Down Expand Up @@ -344,13 +344,13 @@ class JSON_API Value {
Value(bool value);
Value(std::nullptr_t ptr) = delete;
Value(const Value& other);
Value(Value&& other);
Value(Value&& other) noexcept;
~Value();

/// \note Overwrite existing comments. To preserve comments, use
/// #swapPayload().
Value& operator=(const Value& other);
Value& operator=(Value&& other);
Value& operator=(Value&& other) noexcept;

/// Swap everything.
void swap(Value& other);
Expand Down Expand Up @@ -635,9 +635,9 @@ class JSON_API Value {
public:
Comments() = default;
Comments(const Comments& that);
Comments(Comments&& that);
Comments(Comments&& that) noexcept;
Comments& operator=(const Comments& that);
Comments& operator=(Comments&& that);
Comments& operator=(Comments&& that) noexcept;
bool has(CommentPlacement slot) const;
String get(CommentPlacement slot) const;
void set(CommentPlacement slot, String comment);
Expand Down
Empty file modified reformat.sh
100644 → 100755
Empty file.
2 changes: 1 addition & 1 deletion src/lib_json/json_reader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1921,7 +1921,7 @@ bool CharReaderBuilder::validate(Json::Value* invalid) const {
if (valid_keys.count(key))
continue;
if (invalid)
(*invalid)[std::move(key)] = *si;
(*invalid)[key] = *si;
else
return false;
}
Expand Down
13 changes: 7 additions & 6 deletions src/lib_json/json_value.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ Value::CZString::CZString(const CZString& other) {
storage_.length_ = other.storage_.length_;
}

Value::CZString::CZString(CZString&& other)
Value::CZString::CZString(CZString&& other) noexcept
: cstr_(other.cstr_), index_(other.index_) {
other.cstr_ = nullptr;
}
Expand All @@ -285,7 +285,7 @@ Value::CZString& Value::CZString::operator=(const CZString& other) {
return *this;
}

Value::CZString& Value::CZString::operator=(CZString&& other) {
Value::CZString& Value::CZString::operator=(CZString&& other) noexcept {
cstr_ = other.cstr_;
index_ = other.index_;
other.cstr_ = nullptr;
Expand Down Expand Up @@ -433,7 +433,7 @@ Value::Value(const Value& other) {
dupMeta(other);
}

Value::Value(Value&& other) {
Value::Value(Value&& other) noexcept {
initBasic(nullValue);
swap(other);
}
Expand All @@ -448,7 +448,7 @@ Value& Value::operator=(const Value& other) {
return *this;
}

Value& Value::operator=(Value&& other) {
Value& Value::operator=(Value&& other) noexcept {
other.swap(*this);
return *this;
}
Expand Down Expand Up @@ -1373,14 +1373,15 @@ bool Value::isObject() const { return type() == objectValue; }
Value::Comments::Comments(const Comments& that)
: ptr_{cloneUnique(that.ptr_)} {}

Value::Comments::Comments(Comments&& that) : ptr_{std::move(that.ptr_)} {}
Value::Comments::Comments(Comments&& that) noexcept
: ptr_{std::move(that.ptr_)} {}

Value::Comments& Value::Comments::operator=(const Comments& that) {
ptr_ = cloneUnique(that.ptr_);
return *this;
}

Value::Comments& Value::Comments::operator=(Comments&& that) {
Value::Comments& Value::Comments::operator=(Comments&& that) noexcept {
ptr_ = std::move(that.ptr_);
return *this;
}
Expand Down
2 changes: 1 addition & 1 deletion src/lib_json/json_writer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1217,7 +1217,7 @@ bool StreamWriterBuilder::validate(Json::Value* invalid) const {
if (valid_keys.count(key))
continue;
if (invalid)
(*invalid)[std::move(key)] = *si;
(*invalid)[key] = *si;
else
return false;
}
Expand Down

0 comments on commit ceae0e3

Please sign in to comment.