diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2018-07-18 14:59:09 +0200 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2018-07-23 10:19:39 +0000 |
commit | ff0be5aba1c12be49b305e596a7610d197ca8427 (patch) | |
tree | e68205afbbb7e687223bf0c3fafa4fbcbf037970 /sources/shiboken2/generator/qtdoc/qtdocgenerator.cpp | |
parent | 61edf76aab3cdd0bfcf57b16f6a1c37271e675a5 (diff) |
Fix some clang-tidy warnings in shiboken
- 'else if' after return/break/continue
- Use const ref for complex arguments passed by value where possible
- Fix 'if (foo) delete foo' to 'delete foo'
- Use container.isEmpty() instead of container.size() in checks
- Use ' = default' for trivial constructors/destructors
- Use range based for where possible
- Complete constructor initializer lists
- Fix invocations of static methods
- Replace some reinterpret_cast by static_cast
- Remove unused variables/fields
- Use initializer lists for return types
Change-Id: Id5b44a2f9d429f66ef069d532a1cd31df796d38e
Reviewed-by: Christian Tismer <tismer@stackless.com>
Diffstat (limited to 'sources/shiboken2/generator/qtdoc/qtdocgenerator.cpp')
-rw-r--r-- | sources/shiboken2/generator/qtdoc/qtdocgenerator.cpp | 31 |
1 files changed, 15 insertions, 16 deletions
diff --git a/sources/shiboken2/generator/qtdoc/qtdocgenerator.cpp b/sources/shiboken2/generator/qtdoc/qtdocgenerator.cpp index bc0ecc094..e8f09df4a 100644 --- a/sources/shiboken2/generator/qtdoc/qtdocgenerator.cpp +++ b/sources/shiboken2/generator/qtdoc/qtdocgenerator.cpp @@ -303,7 +303,7 @@ QTextStream &operator<<(QTextStream &str, const QtXmlToSphinx::LinkContext &link } QtXmlToSphinx::QtXmlToSphinx(QtDocGenerator* generator, const QString& doc, const QString& context) - : m_context(context), m_generator(generator), m_insideBold(false), m_insideItalic(false) + : m_tableHasHeader(false), m_context(context), m_generator(generator), m_insideBold(false), m_insideItalic(false) { m_handlerMap.insert(QLatin1String("heading"), &QtXmlToSphinx::handleHeadingTag); m_handlerMap.insert(QLatin1String("brief"), &QtXmlToSphinx::handleParaTag); @@ -1511,11 +1511,10 @@ QString QtDocGenerator::fileNameForContext(GeneratorContext &context) const const AbstractMetaClass *metaClass = context.metaClass(); if (!context.forSmartPointer()) { return getClassTargetFullName(metaClass, false) + fileNameSuffix(); - } else { - const AbstractMetaType *smartPointerType = context.preciseType(); - QString fileNameBase = getFileNameBaseForSmartPointer(smartPointerType, metaClass); - return fileNameBase + fileNameSuffix(); } + const AbstractMetaType *smartPointerType = context.preciseType(); + QString fileNameBase = getFileNameBaseForSmartPointer(smartPointerType, metaClass); + return fileNameBase + fileNameSuffix(); } void QtDocGenerator::writeFormattedText(QTextStream &s, const Documentation &doc, @@ -1532,7 +1531,7 @@ void QtDocGenerator::writeFormattedText(QTextStream &s, const Documentation &doc } else { const QString &value = doc.value(); const QVector<QStringRef> lines = value.splitRef(QLatin1Char('\n')); - int typesystemIndentation = std::numeric_limits<int>().max(); + int typesystemIndentation = std::numeric_limits<int>::max(); // check how many spaces must be removed from the beginning of each line for (const QStringRef &line : lines) { const auto it = std::find_if(line.cbegin(), line.cend(), @@ -1540,7 +1539,7 @@ void QtDocGenerator::writeFormattedText(QTextStream &s, const Documentation &doc if (it != line.cend()) typesystemIndentation = qMin(typesystemIndentation, int(it - line.cbegin())); } - if (typesystemIndentation == std::numeric_limits<int>().max()) + if (typesystemIndentation == std::numeric_limits<int>::max()) typesystemIndentation = 0; for (const QStringRef &line : lines) { s << INDENT @@ -1675,7 +1674,7 @@ void QtDocGenerator::writeFunctionList(QTextStream& s, const AbstractMetaClass* functionList << str; } - if ((functionList.size() > 0) || (staticFunctionList.size() > 0)) { + if (!functionList.isEmpty() || !staticFunctionList.isEmpty()) { QtXmlToSphinx::Table functionTable; s << endl @@ -1692,7 +1691,7 @@ void QtDocGenerator::writeFunctionList(QTextStream& s, const AbstractMetaClass* void QtDocGenerator::writeFunctionBlock(QTextStream& s, const QString& title, QStringList& functions) { - if (functions.size() > 0) { + if (!functions.isEmpty()) { s << title << endl << QString(title.size(), QLatin1Char('^')) << endl; @@ -1775,7 +1774,8 @@ void QtDocGenerator::writeConstructors(QTextStream& s, const AbstractMetaClass* writeFormattedText(s, func->documentation(), cppClass); } -QString QtDocGenerator::parseArgDocStyle(const AbstractMetaClass* cppClass, const AbstractMetaFunction* func) +QString QtDocGenerator::parseArgDocStyle(const AbstractMetaClass* /* cppClass */, + const AbstractMetaFunction* func) { QString ret; int optArgs = 0; @@ -1857,8 +1857,7 @@ void QtDocGenerator::writeDocSnips(QTextStream &s, if (row.trimmed().size() == 0) { if (currenRow == 0) continue; - else - s << endl; + s << endl; } if (currenRow == 0) { @@ -2122,7 +2121,7 @@ void QtDocGenerator::writeModuleDocumentation() s << ".. module:: " << it.key() << endl << endl; - QString title = it.key(); + const QString &title = it.key(); s << title << endl; s << Pad('*', title.length()) << endl << endl; @@ -2277,10 +2276,10 @@ bool QtDocGenerator::doSetup() qCWarning(lcShiboken) << "Documentation data dir and/or Qt source dir not informed, " "documentation will not be extracted from Qt sources."; return false; - } else { - m_docParser->setDocumentationDataDirectory(m_docDataDir); - m_docParser->setLibrarySourceDirectory(m_libSourceDir); } + + m_docParser->setDocumentationDataDirectory(m_docDataDir); + m_docParser->setLibrarySourceDirectory(m_libSourceDir); return true; } |