diff --git a/.clang-tidy b/.clang-tidy new file mode 100644 index 0000000..6b5e801 --- /dev/null +++ b/.clang-tidy @@ -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' +... + diff --git a/src/lib_json/json_reader.cpp b/src/lib_json/json_reader.cpp index 6a1c765..d1ae192 100644 --- a/src/lib_json/json_reader.cpp +++ b/src/lib_json/json_reader.cpp @@ -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 CharReaderPtr; +using CharReaderPtr = std::unique_ptr; #else typedef std::auto_ptr CharReaderPtr; #endif @@ -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, @@ -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_castEOF); return parse(doc.data(), doc.data() + doc.size(), root, collectComments); } @@ -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; @@ -952,7 +951,7 @@ private: Location extra_; }; - typedef std::deque Errors; + using Errors = std::deque; bool readToken(Token& token); void skipSpaces(); @@ -997,7 +996,7 @@ private: static String normalizeEOL(Location begin, Location end); static bool containsNewLine(Location begin, Location end); - typedef std::stack Nodes; + using Nodes = std::stack; Nodes nodes_; Errors errors_; String document_; @@ -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, diff --git a/src/lib_json/json_value.cpp b/src/lib_json/json_value.cpp index 4f71e77..cce2b29 100644 --- a/src/lib_json/json_value.cpp +++ b/src/lib_json/json_value.cpp @@ -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 // ////////////////////////////////////////////////////////////////// diff --git a/src/lib_json/json_writer.cpp b/src/lib_json/json_writer.cpp index 41dfd8c..4b91035 100644 --- a/src/lib_json/json_writer.cpp +++ b/src/lib_json/json_writer.cpp @@ -84,7 +84,7 @@ namespace Json { #if __cplusplus >= 201103L || (defined(_CPPLIB_VER) && _CPPLIB_VER >= 520) -typedef std::unique_ptr StreamWriterPtr; +using StreamWriterPtr = std::unique_ptr; #else typedef std::auto_ptr StreamWriterPtr; #endif @@ -887,7 +887,7 @@ private: void writeCommentAfterValueOnSameLine(Value const& root); static bool hasCommentForValue(const Value& value); - typedef std::vector ChildValues; + using ChildValues = std::vector; ChildValues childValues_; String indentString_;