Skip to content

clang-tidy fixes #1033

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 4 commits into from
Sep 25, 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
11 changes: 11 additions & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
Checks: 'google-readability-casting,modernize-use-default-member-init,modernize-use-using,readability-redundant-member-init'
WarningsAsErrors: ''
HeaderFilterRegex: ''
AnalyzeTemporaryDtors: false
FormatStyle: none
CheckOptions:
- key: modernize-use-using.IgnoreMacros
value: '0'
...

21 changes: 10 additions & 11 deletions src/lib_json/json_reader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ static size_t const stackLimit_g =
namespace Json {

#if __cplusplus >= 201103L || (defined(_CPPLIB_VER) && _CPPLIB_VER >= 520)
typedef std::unique_ptr<CharReader> CharReaderPtr;
using CharReaderPtr = std::unique_ptr<CharReader>;
#else
typedef std::auto_ptr<CharReader> CharReaderPtr;
#endif
Expand Down Expand Up @@ -86,11 +86,10 @@ bool Reader::containsNewLine(Reader::Location begin, Reader::Location end) {
// //////////////////////////////////////////////////////////////////

Reader::Reader()
: errors_(), document_(), commentsBefore_(), features_(Features::all()) {}
: features_(Features::all()) {}

Reader::Reader(const Features& features)
: errors_(), document_(), begin_(), end_(), current_(), lastValueEnd_(),
lastValue_(), commentsBefore_(), features_(features), collectComments_() {
: features_(features) {
}

bool Reader::parse(const std::string& document,
Expand All @@ -111,7 +110,7 @@ bool Reader::parse(std::istream& is, Value& root, bool collectComments) {
// Since String is reference-counted, this at least does not
// create an extra copy.
String doc;
std::getline(is, doc, (char)EOF);
std::getline(is, doc, static_cast<char>EOF);
return parse(doc.data(), doc.data() + doc.size(), root, collectComments);
}

Expand Down Expand Up @@ -895,8 +894,8 @@ OurFeatures OurFeatures::all() { return {}; }
// for implementing JSON reading.
class OurReader {
public:
typedef char Char;
typedef const Char* Location;
using Char = char;
using Location = const Char *;
struct StructuredError {
ptrdiff_t offset_start;
ptrdiff_t offset_limit;
Expand Down Expand Up @@ -952,7 +951,7 @@ class OurReader {
Location extra_;
};

typedef std::deque<ErrorInfo> Errors;
using Errors = std::deque<ErrorInfo>;

bool readToken(Token& token);
void skipSpaces();
Expand Down Expand Up @@ -997,7 +996,7 @@ class OurReader {
static String normalizeEOL(Location begin, Location end);
static bool containsNewLine(Location begin, Location end);

typedef std::stack<Value*> Nodes;
using Nodes = std::stack<Value *>;
Nodes nodes_;
Errors errors_;
String document_;
Expand All @@ -1023,8 +1022,8 @@ bool OurReader::containsNewLine(OurReader::Location begin,
}

OurReader::OurReader(OurFeatures const& features)
: errors_(), document_(), begin_(), end_(), current_(), lastValueEnd_(),
lastValue_(), commentsBefore_(), features_(features), collectComments_() {
: begin_(), end_(), current_(), lastValueEnd_(),
lastValue_(), features_(features), collectComments_() {
}

bool OurReader::parse(const char* beginDoc,
Expand Down
8 changes: 4 additions & 4 deletions src/lib_json/json_value.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1547,16 +1547,16 @@ Value::iterator Value::end() {
// class PathArgument
// //////////////////////////////////////////////////////////////////

PathArgument::PathArgument() : key_() {}
PathArgument::PathArgument() {}

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

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

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

// class Path
// //////////////////////////////////////////////////////////////////
Expand Down
4 changes: 2 additions & 2 deletions src/lib_json/json_writer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
namespace Json {

#if __cplusplus >= 201103L || (defined(_CPPLIB_VER) && _CPPLIB_VER >= 520)
typedef std::unique_ptr<StreamWriter> StreamWriterPtr;
using StreamWriterPtr = std::unique_ptr<StreamWriter>;
#else
typedef std::auto_ptr<StreamWriter> StreamWriterPtr;
#endif
Expand Down Expand Up @@ -887,7 +887,7 @@ struct BuiltStyledStreamWriter : public StreamWriter {
void writeCommentAfterValueOnSameLine(Value const& root);
static bool hasCommentForValue(const Value& value);

typedef std::vector<String> ChildValues;
using ChildValues = std::vector<String>;

ChildValues childValues_;
String indentString_;
Expand Down