From dcf8f794818fa736e70e3c598700e76be4fbe079 Mon Sep 17 00:00:00 2001 From: Albert Astals Cid Date: Fri, 21 Feb 2020 16:34:08 +0100 Subject: [PATCH] Enable clazy isempty-vs-count and qhash-with-char-pointer-key --- .gitlab-ci.yml | 2 +- core/textpage.cpp | 2 +- generators/chm/lib/helper_search_index.cpp | 9 +++------ ui/sidebar.cpp | 2 +- 4 files changed, 6 insertions(+), 9 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 7f0445ae4..c17547a04 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -48,7 +48,7 @@ build_clazy_clang_tidy: script: - srcdir=`pwd` && mkdir -p /tmp/okular_build && cd /tmp/okular_build && CC=clang CXX=clazy CXXFLAGS="-Werror -Wno-deprecated-declarations" cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -G Ninja $srcdir && cat compile_commands.json | jq '[.[] | select(.file | contains("'"$srcdir"'"))]' > compile_commands.aux.json && cat compile_commands.aux.json | jq '[.[] | select(.file | contains("/synctex/")| not)]' > compile_commands.json - - CLAZY_IGNORE_DIRS="settings_core.[cpp|h]|settings.[cpp.h]|pdfsettings.h|gssettings.h" CLAZY_CHECKS="level0,level1,level2,no-ctor-missing-parent-argument,no-qstring-allocations" ninja + - CLAZY_IGNORE_DIRS="settings_core.[cpp|h]|settings.[cpp.h]|pdfsettings.h|gssettings.h" CLAZY_CHECKS="level0,level1,level2,no-ctor-missing-parent-argument,no-qstring-allocations,isempty-vs-count,qhash-with-char-pointer-key" ninja # Fix the poppler header, remove when debian:unstable ships poppler 0.82 or later - sed -i "N;N;N;N; s#class MediaRendition\;\nclass MovieAnnotation\;\nclass ScreenAnnotation;#class MediaRendition\;#g" /usr/include/poppler/qt5/poppler-link.h - "run-clang-tidy -header-filter='.*/okular/.*' -checks='-*,performance-*,bugprone-*,readability-inconsistent-declaration-parameter-name,readability-string-compare,modernize-redundant-void-arg,modernize-use-bool-literals,modernize-make-unique,modernize-make-shared,modernize-use-override,modernize-use-equals-delete,modernize-use-emplace,modernize-loop-convert,modernize-use-nullptr,-bugprone-macro-parentheses,-bugprone-narrowing-conversions,-bugprone-branch-clone,-bugprone-incorrect-roundings' -config=\"{WarningsAsErrors: '*'}\"" diff --git a/core/textpage.cpp b/core/textpage.cpp index d9caf7e20..477a2234c 100644 --- a/core/textpage.cpp +++ b/core/textpage.cpp @@ -1193,7 +1193,7 @@ static WordsWithCharacters makeWordFromCharacters(const TextList &characters, in while (!space) { - if (textString.length()) + if (!textString.isEmpty()) { newString.append(textString); diff --git a/generators/chm/lib/helper_search_index.cpp b/generators/chm/lib/helper_search_index.cpp index ecdc51b46..89f7f4cae 100644 --- a/generators/chm/lib/helper_search_index.cpp +++ b/generators/chm/lib/helper_search_index.cpp @@ -122,7 +122,7 @@ bool Index::makeIndex(const QList< QUrl >& docs, EBook *chmFile ) void Index::insertInDict( const QString &str, int docNum ) { Entry *e = nullptr; - if ( dict.count() ) + if ( !dict.isEmpty() ) e = dict[ str ]; if ( e ) @@ -377,7 +377,7 @@ QList< QUrl > Index::query(const QStringList &terms, const QStringList &termSeq, } } - if ( !termList.count() ) + if ( termList.isEmpty() ) return QList< QUrl >(); std::sort(termList.begin(), termList.end()); @@ -482,10 +482,7 @@ bool Index::searchForPhrases( const QStringList &phrases, const QStringList &wor } } - if ( first_word_positions.count() ) - return true; - - return false; + return !first_word_positions.isEmpty(); } diff --git a/ui/sidebar.cpp b/ui/sidebar.cpp index ded6efe8e..b96156fc0 100644 --- a/ui/sidebar.cpp +++ b/ui/sidebar.cpp @@ -557,7 +557,7 @@ void Sidebar::setMainWidget( QWidget *widget ) if ( !d->splitterSizesSet ) { QList splitterSizes = Okular::Settings::splitterSizes(); - if ( !splitterSizes.count() ) + if ( splitterSizes.isEmpty() ) { // the first time use 1/10 for the panel and 9/10 for the pageView splitterSizes.push_back( 50 );