diff options
author | Nikolai Kosjar <nikolai.kosjar@qt.io> | 2019-10-31 16:03:18 +0100 |
---|---|---|
committer | Nikolai Kosjar <nikolai.kosjar@qt.io> | 2019-11-01 09:21:29 +0000 |
commit | d337d03ce1b8c0bcd76eaf6a6defcd717490d78a (patch) | |
tree | 00c1902f774dc47961e24be923b1469b098fdab2 | |
parent | d1912784c82d0012a86cc1bc8a9303d879d7e4c0 (diff) | |
download | qt-creator-d337d03ce1b8c0bcd76eaf6a6defcd717490d78a.tar.gz |
CppEditor: Simplify
bugprone-branch-clone
readability-simplify-boolean-expr
Change-Id: Id30a155e224370713d23b4b534fb82f5e630f36c
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
-rw-r--r-- | src/plugins/cmakeprojectmanager/cmakeautocompleter.cpp | 5 | ||||
-rw-r--r-- | src/plugins/cppeditor/cppdocumentationcommenthelper.cpp | 10 | ||||
-rw-r--r-- | src/plugins/cppeditor/cppfunctiondecldeflink.cpp | 4 | ||||
-rw-r--r-- | src/plugins/cppeditor/cppquickfixes.cpp | 18 |
4 files changed, 7 insertions, 30 deletions
diff --git a/src/plugins/cmakeprojectmanager/cmakeautocompleter.cpp b/src/plugins/cmakeprojectmanager/cmakeautocompleter.cpp index eca893b8ea..eb9ae0c76f 100644 --- a/src/plugins/cmakeprojectmanager/cmakeautocompleter.cpp +++ b/src/plugins/cmakeprojectmanager/cmakeautocompleter.cpp @@ -45,10 +45,7 @@ bool CMakeAutoCompleter::isInComment(const QTextCursor &cursor) const // NOTE: This doesn't handle '#' inside quotes, nor multi-line comments QTextCursor moved = cursor; moved.movePosition(QTextCursor::StartOfLine, QTextCursor::KeepAnchor); - if (moved.selectedText().contains(QLatin1Char('#'))) - return true; - else - return false; + return moved.selectedText().contains(QLatin1Char('#')); } bool CMakeAutoCompleter::isInString(const QTextCursor &cursor) const diff --git a/src/plugins/cppeditor/cppdocumentationcommenthelper.cpp b/src/plugins/cppeditor/cppdocumentationcommenthelper.cpp index 65c3dc9769..bb656d1900 100644 --- a/src/plugins/cppeditor/cppdocumentationcommenthelper.cpp +++ b/src/plugins/cppeditor/cppdocumentationcommenthelper.cpp @@ -88,10 +88,7 @@ bool isPreviousLineCppStyleComment(const QTextCursor &cursor) return false; const QString text = actual.text().trimmed(); - if (text.startsWith(QLatin1String("///")) || text.startsWith(QLatin1String("//!"))) - return true; - - return false; + return text.startsWith(QLatin1String("///")) || text.startsWith(QLatin1String("//!")); } /// Check if next line is a CppStyle Doxygen Comment @@ -106,10 +103,7 @@ bool isNextLineCppStyleComment(const QTextCursor &cursor) return false; const QString text = actual.text().trimmed(); - if (text.startsWith(QLatin1String("///")) || text.startsWith(QLatin1String("//!"))) - return true; - - return false; + return text.startsWith(QLatin1String("///")) || text.startsWith(QLatin1String("//!")); } bool isCppStyleContinuation(const QTextCursor& cursor) diff --git a/src/plugins/cppeditor/cppfunctiondecldeflink.cpp b/src/plugins/cppeditor/cppfunctiondecldeflink.cpp index beb2e2aaf7..7368ecb416 100644 --- a/src/plugins/cppeditor/cppfunctiondecldeflink.cpp +++ b/src/plugins/cppeditor/cppfunctiondecldeflink.cpp @@ -442,9 +442,7 @@ static bool canReplaceSpecifier(TranslationUnit *translationUnit, SpecifierAST * return false; } } - if (specifier->asAttributeSpecifier()) - return false; - return true; + return !specifier->asAttributeSpecifier(); } static SpecifierAST *findFirstReplaceableSpecifier(TranslationUnit *translationUnit, SpecifierListAST *list) diff --git a/src/plugins/cppeditor/cppquickfixes.cpp b/src/plugins/cppeditor/cppquickfixes.cpp index 7689e960e0..d384322bdd 100644 --- a/src/plugins/cppeditor/cppquickfixes.cpp +++ b/src/plugins/cppeditor/cppquickfixes.cpp @@ -581,21 +581,11 @@ static bool checkDeclarationForSplit(SimpleDeclarationAST *declaration) for (SpecifierListAST *it = declaration->decl_specifier_list; it; it = it->next) { SpecifierAST *specifier = it->value; - - if (specifier->asEnumSpecifier() != nullptr) - return false; - - else if (specifier->asClassSpecifier() != nullptr) + if (specifier->asEnumSpecifier() || specifier->asClassSpecifier()) return false; } - if (!declaration->declarator_list) - return false; - - else if (!declaration->declarator_list->next) - return false; - - return true; + return declaration->declarator_list && declaration->declarator_list->next; } namespace { @@ -3502,9 +3492,7 @@ public: bool preVisit(AST *) override { - if (m_done) - return false; - return true; + return !m_done; } void statement(StatementAST *stmt) |