Commit a23709b0 authored by Albert Astals Cid's avatar Albert Astals Cid
Browse files

CI: Enable clazy range-loop

parent 82d58104
......@@ -48,7 +48,7 @@ build_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_CHECKS="qstring-arg,incorrect-emit,qhash-namespace,detaching-temporary" ninja
- CLAZY_CHECKS="qstring-arg,incorrect-emit,qhash-namespace,detaching-temporary,range-loop" 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: '*'}\""
......@@ -57,7 +57,8 @@ void CalculateTextTest::testSimpleCalculate()
// Field names in test document are:
// field1, field2, field3, Sum, AVG, Prod, Min, Max
for ( Okular::FormField *ff: page->formFields() )
const QLinkedList<Okular::FormField *> pageFormFields = page->formFields();
for ( Okular::FormField *ff: pageFormFields )
{
fields.insert( ff->name(), static_cast<Okular::FormFieldText*>( ff ) );
}
......
......@@ -64,7 +64,8 @@ void FormatTest::initTestCase()
});
const Okular::Page* page = m_document->page( 0 );
for ( Okular::FormField *ff: page->formFields() )
const QLinkedList<Okular::FormField *> pageFormFields = page->formFields();
for ( Okular::FormField *ff: pageFormFields )
{
m_fields.insert( ff->name(), ff );
}
......
......@@ -110,7 +110,8 @@ void KJSFunctionsTest::initTestCase()
QCOMPARE( m_document->openDocument( testFile, QUrl(), mime), Okular::Document::OpenSuccess );
const Okular::Page* page = m_document->page( 0 );
for ( Okular::FormField *ff: page->formFields() )
const QLinkedList<Okular::FormField *> pageFormFields = page->formFields();
for ( Okular::FormField *ff: pageFormFields )
{
m_fields.insert( ff->name(), ff );
}
......
......@@ -1264,7 +1264,8 @@ void PartTest::testSaveAsUndoStackForms()
Okular::Part part(nullptr, nullptr, QVariantList());
part.openDocument( file );
for ( FormField *ff : part.m_document->page( 0 )->formFields() )
const QLinkedList<Okular::FormField *> pageFormFields = part.m_document->page( 0 )->formFields();
for ( FormField *ff : pageFormFields )
{
if ( ff->id() == 65537 )
{
......@@ -1432,7 +1433,8 @@ void PartTest::testCheckBoxReadOnly()
// Field names in test document are:
// CBMakeRW, CBMakeRO, TargetDefaultRO, TargetDefaultRW
for ( Okular::FormField *ff: page->formFields() )
const QLinkedList<Okular::FormField *> pageFormFields = page->formFields();
for ( Okular::FormField *ff: pageFormFields )
{
fields.insert( ff->name(), static_cast< Okular::FormField* >( ff ) );
}
......@@ -1507,9 +1509,12 @@ void PartTest::testCheckBoxReadOnly()
fields.clear();
for ( Okular::FormField *ff: page->formFields() )
{
fields.insert( ff->name(), static_cast< Okular::FormField* >( ff ) );
const QLinkedList<Okular::FormField *> pageFormFields = page->formFields();
for ( Okular::FormField *ff: pageFormFields )
{
fields.insert( ff->name(), static_cast< Okular::FormField* >( ff ) );
}
}
cbMakeRW = dynamic_cast< Okular::FormFieldButton* > ( fields[QStringLiteral( "CBMakeRW" )] );
......@@ -1677,7 +1682,8 @@ void PartTest::testAdditionalActionTriggers()
// For target fields: <trigger_name>_focus_target, <trigger_name>_cursor_target,
// <trigger_name>_mouse_target
const Okular::Page* page = part.m_document->page( 0 );
for ( Okular::FormField *ff: page->formFields() )
const QLinkedList<Okular::FormField *> pageFormFields = page->formFields();
for ( Okular::FormField *ff: pageFormFields )
{
fields.insert( ff->name(), static_cast< Okular::FormField* >( ff ) );
}
......
......@@ -60,7 +60,8 @@ void VisibilityTest::initTestCase()
// With two radio buttons named TargetRadio.
const Okular::Page* page = m_document->page( 0 );
for ( Okular::FormField *ff: page->formFields() )
const QLinkedList<Okular::FormField *> pageFormFields = page->formFields();
for ( Okular::FormField *ff : pageFormFields )
{
m_fields.insert( ff->name(), ff );
}
......@@ -137,7 +138,8 @@ void VisibilityTest::testSaveLoad()
const Okular::Page* page = newDoc->page( 0 );
bool anyChecked = false; // Saveguard against accidental test passing here ;-)
for ( Okular::FormField *ff: page->formFields() )
const QLinkedList<Okular::FormField *> pageFormFields = page->formFields();
for ( Okular::FormField *ff: pageFormFields )
{
if ( ff->name().startsWith( QStringLiteral( "Target" ) ) )
{
......
......@@ -4411,7 +4411,8 @@ void Document::processAction( const Action * action )
if ( executeNextActions )
{
for ( const Action *a : action->nextActions() )
const QVector<Action*> nextActions = action->nextActions();
for ( const Action *a : nextActions )
{
processAction( a );
}
......@@ -4802,7 +4803,7 @@ QStringList Document::supportedMimeTypes() const
// Remove duplicate mimetypes represented by different names
QMimeDatabase mimeDatabase;
QSet<QMimeType> uniqueMimetypes;
for (const QString &mimeName : result) {
for (const QString &mimeName : qAsConst(result)) {
uniqueMimetypes.insert(mimeDatabase.mimeTypeForName(mimeName));
}
result.clear();
......@@ -5078,7 +5079,8 @@ ArchiveData *DocumentPrivate::unpackDocumentArchive( const QString &archivePath
// Check the archive doesn't have folders, we don't create them when saving the archive
// and folders mean paths and paths mean path traversal issues
for ( const QString &entry : mainDir->entries() )
const QStringList mainDirEntries = mainDir->entries();
for ( const QString &entry : mainDirEntries )
{
if ( mainDir->entry( entry )->isDirectory() )
{
......
......@@ -497,7 +497,8 @@ Okular::Action* createLinkFromPopplerLink(const Poppler::Link *popplerLink, bool
{
const Poppler::LinkHide * l = static_cast<const Poppler::LinkHide *>( popplerLink );
QStringList scripts;
for ( const QString &target: l->targets() )
const QVector<QString> targets = l->targets();
for ( const QString &target : targets )
{
scripts << QStringLiteral( "getField(\"%1\").hidden = %2;" ).arg( target ).arg( l->isShowAction() ? QLatin1String( "false" ) : QLatin1String( "true" ) );
}
......@@ -517,7 +518,8 @@ Okular::Action* createLinkFromPopplerLink(const Poppler::Link *popplerLink, bool
if (link)
{
QVector< Okular::Action * > nextActions;
for ( const Poppler::Link *nl : popplerLink->nextLinks() )
const QVector<Poppler::Link *> nextLinks = popplerLink->nextLinks();
for ( const Poppler::Link *nl : nextLinks )
{
nextActions << createLinkFromPopplerLink( nl, false );
}
......
......@@ -400,7 +400,7 @@ void PagePainter::paintCroppedPageOnPainter( QPainter * destPainter, const Okula
if ( bufferedHighlights )
{
// draw highlights that are inside the 'limits' paint region
for (const auto& highlight : *bufferedHighlights)
for (const auto& highlight : qAsConst(*bufferedHighlights))
{
const Okular::NormalizedRect & r = highlight.second;
// find out the rect to highlight on pixmap
......
......@@ -4266,7 +4266,8 @@ void PageView::updateZoomText()
void PageView::updateViewMode(const int nr)
{
for ( QAction* action : d->aViewMode->menu()->actions() ) {
const QList<QAction*> actions = d->aViewMode->menu()->actions();
for ( QAction* action : actions ) {
QVariant mode_id = action->data();
if (mode_id.toInt() == nr) {
action->trigger();
......
......@@ -72,8 +72,8 @@ PropertiesDialog::PropertiesDialog(QWidget *parent, Okular::Document *doc)
{
orderedProperties << Okular::DocumentInfo::getKeyString( ks );
}
// keys() is a const method
for (const QString &ks : info.keys()) {
const QStringList infoKeys = info.keys();
for (const QString &ks : infoKeys) {
if ( !orderedProperties.contains( ks ) ) {
orderedProperties << ks;
}
......
......@@ -96,7 +96,7 @@ static void updateFormFieldSignaturePointer( SignatureItem *item, const QVector<
if ( item->form )
{
const QLinkedList< Okular::FormField * > formFields = pages[item->page]->formFields();
for ( Okular::FormField *f : pages[item->page]->formFields() )
for ( Okular::FormField *f : formFields )
{
if ( item->form->id() == f->id() )
{
......
......@@ -92,7 +92,8 @@ QAction * ToggleActionMenu::checkedAction( QMenu *menu ) const
{
// Look at each action a in the menu whether it is checked.
// If a is a menu, recursively call checkedAction().
for ( QAction * a : menu->actions() )
const QList<QAction*> actions = menu->actions();
for ( QAction * a : actions )
{
if ( a->isChecked() )
{
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment