Commit 82d58104 authored by Albert Astals Cid's avatar Albert Astals Cid
Browse files

CI: Enable clazy detaching-temporary

parent 6ddb7e6c
......@@ -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" ninja
- CLAZY_CHECKS="qstring-arg,incorrect-emit,qhash-namespace,detaching-temporary" 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: '*'}\""
......@@ -249,7 +249,7 @@ void EditFormsTest::testComboEditForm()
// Select first choice
m_document->editFormCombo( 0, m_comboEdit, QStringLiteral("combo1"), 0, 0, 0);
QCOMPARE( m_comboEdit->currentChoices().length(), 1 );
QCOMPARE( m_comboEdit->currentChoices()[0], 0 );
QCOMPARE( m_comboEdit->currentChoices().constFirst(), 0 );
QCOMPARE( m_comboEdit->editChoice(), QLatin1String( "" ) );
QVERIFY( m_document->canUndo() );
QVERIFY( !m_document->canRedo() );
......@@ -257,7 +257,7 @@ void EditFormsTest::testComboEditForm()
// Select third choice
m_document->editFormCombo( 0, m_comboEdit, QStringLiteral("combo3"), 0, 0, 0);
QCOMPARE( m_comboEdit->currentChoices().length(), 1 );
QCOMPARE( m_comboEdit->currentChoices()[0], 2 );
QCOMPARE( m_comboEdit->currentChoices().constFirst(), 2 );
QCOMPARE( m_comboEdit->editChoice(), QLatin1String( "" ) );
QVERIFY( m_document->canUndo() );
QVERIFY( !m_document->canRedo() );
......@@ -265,14 +265,14 @@ void EditFormsTest::testComboEditForm()
// Undo and verify that first choice is selected
m_document->undo();
QCOMPARE( m_comboEdit->currentChoices().length(), 1 );
QCOMPARE( m_comboEdit->currentChoices()[0], 0 );
QCOMPARE( m_comboEdit->currentChoices().constFirst(), 0 );
QVERIFY( m_document->canUndo() );
QVERIFY( m_document->canRedo() );
// Redo and verify that third choice is selected
m_document->redo();
QCOMPARE( m_comboEdit->currentChoices().length(), 1 );
QCOMPARE( m_comboEdit->currentChoices()[0], 2 );
QCOMPARE( m_comboEdit->currentChoices().constFirst(), 2 );
QVERIFY( m_document->canUndo() );
QVERIFY( !m_document->canRedo() );
......@@ -286,7 +286,7 @@ void EditFormsTest::testComboEditForm()
// Undo and verify that third choice is selected
m_document->undo();
QCOMPARE( m_comboEdit->currentChoices().length(), 1 );
QCOMPARE( m_comboEdit->currentChoices()[0], 2 );
QCOMPARE( m_comboEdit->currentChoices().constFirst(), 2 );
QVERIFY( m_document->canUndo() );
QVERIFY( m_document->canRedo() );
}
......@@ -300,28 +300,28 @@ void EditFormsTest::testListSingleEdit()
// Select first item
m_document->editFormList( 0, m_listSingleEdit, QList<int>() << 0);
QCOMPARE( m_listSingleEdit->currentChoices().length(), 1 );
QCOMPARE( m_listSingleEdit->currentChoices()[0], 0 );
QCOMPARE( m_listSingleEdit->currentChoices().constFirst(), 0 );
QVERIFY( m_document->canUndo() );
QVERIFY( !m_document->canRedo() );
// Select second item
m_document->editFormList( 0, m_listSingleEdit, QList<int>() << 1);
QCOMPARE( m_listSingleEdit->currentChoices().length(), 1 );
QCOMPARE( m_listSingleEdit->currentChoices()[0], 1 );
QCOMPARE( m_listSingleEdit->currentChoices().constFirst(), 1 );
QVERIFY( m_document->canUndo() );
QVERIFY( !m_document->canRedo() );
// Undo and verify that first item is selected
m_document->undo();
QCOMPARE( m_listSingleEdit->currentChoices().length(), 1 );
QCOMPARE( m_listSingleEdit->currentChoices()[0], 0 );
QCOMPARE( m_listSingleEdit->currentChoices().constFirst(), 0 );
QVERIFY( m_document->canUndo() );
QVERIFY( m_document->canRedo() );
// Redo and verify that second item is selected
m_document->redo();
QCOMPARE( m_listSingleEdit->currentChoices().length(), 1 );
QCOMPARE( m_listSingleEdit->currentChoices()[0], 1 );
QCOMPARE( m_listSingleEdit->currentChoices().constFirst(), 1 );
QVERIFY( m_document->canUndo() );
QVERIFY( !m_document->canRedo() );
}
......
......@@ -4111,7 +4111,7 @@ void Document::editFormCombo( int pageNumber,
}
else
{
prevText = form->choices()[form->currentChoices().constFirst()];
prevText = form->choices().at(form->currentChoices().constFirst());
}
QUndoCommand *uc = new EditFormComboCommand( this->d, form, pageNumber, newText, newCursorPos, prevText, prevCursorPos, prevAnchorPos );
......
......@@ -603,12 +603,12 @@ EditFormComboCommand::EditFormComboCommand( Okular::DocumentPrivate* docPriv,
// Determine new and previous choice indices (if any)
for ( int i = 0; i < m_form->choices().size(); i++ )
{
if ( m_form->choices()[i] == m_prevContents )
if ( m_form->choices().at(i) == m_prevContents )
{
m_prevIndex = i;
}
if ( m_form->choices()[i] == m_newContents )
if ( m_form->choices().at(i) == m_newContents )
{
m_newIndex = i;
}
......
......@@ -45,7 +45,7 @@ void KIMGIOTest::initTestCase()
QVERIFY( !KPluginLoader::findPlugin( QStringLiteral("okularGenerator_kimgio") ).isEmpty() );
// make sure we didn't break the search path for image formats:
auto availableFormats = QImageReader::supportedImageFormats();
QVERIFY2(availableFormats.contains( "jpeg" ), availableFormats.join( ", " ).data() );
QVERIFY2(availableFormats.contains( "jpeg" ), availableFormats.join( ", " ).constData() );
}
......
......@@ -1058,7 +1058,7 @@ void ComboEdit::slotValueChanged()
}
else
{
prevText = form->choices()[form->currentChoices()[0]];
prevText = form->choices().at(form->currentChoices().constFirst());
}
int cursorPos = lineEdit()->cursorPosition();
......
......@@ -989,11 +989,12 @@ LineAnnotPainter::LineAnnotPainter( const Okular::LineAnnotation * a, QSizeF pag
void LineAnnotPainter::draw( QImage &image ) const
{
if ( la->transformedLinePoints().count() == 2 )
const QLinkedList<Okular::NormalizedPoint> transformedLinePoints = la->transformedLinePoints();
if ( transformedLinePoints.count() == 2 )
{
const Okular::NormalizedPoint delta {
la->transformedLinePoints().last().x - la->transformedLinePoints().first().x,
la->transformedLinePoints().first().y - la->transformedLinePoints().last().y
transformedLinePoints.last().x - transformedLinePoints.first().x,
transformedLinePoints.first().y - transformedLinePoints.last().y
};
const double angle { atan2( delta.y * aspectRatio, delta.x ) };
const double cosA { cos( -angle ) };
......@@ -1001,8 +1002,8 @@ void LineAnnotPainter::draw( QImage &image ) const
const QTransform tmpMatrix = QTransform {
cosA, sinA / aspectRatio,
-sinA, cosA / aspectRatio,
la->transformedLinePoints().first().x,
la->transformedLinePoints().first().y };
transformedLinePoints.first().x,
transformedLinePoints.first().y };
const double deaspectedY { delta.y * aspectRatio };
const double mainSegmentLength { sqrt( delta.x * delta.x + deaspectedY * deaspectedY ) };
const double lineendSize { std::min( 6. * la->style().width() / pageSize.width(), mainSegmentLength / 2. ) };
......@@ -1012,7 +1013,7 @@ void LineAnnotPainter::draw( QImage &image ) const
drawLeaderLine( 0., image, tmpMatrix );
drawLeaderLine( mainSegmentLength, image, tmpMatrix );
}
else if ( la->transformedLinePoints().count() > 2 )
else if ( transformedLinePoints.count() > 2 )
{
drawMainLine( image );
}
......
......@@ -71,7 +71,7 @@ void RevisionViewer::viewRevision()
QMimeDatabase db;
const QMimeType mime = db.mimeTypeForData( m_revisionData );
const QString tempDir = QStandardPaths::writableLocation( QStandardPaths::TempLocation );
QTemporaryFile tf( tempDir + QStringLiteral("/okular_revision_XXXXXX.%1").arg( mime.suffixes().first() ));
QTemporaryFile tf( tempDir + QStringLiteral("/okular_revision_XXXXXX.%1").arg( mime.suffixes().constFirst() ));
if ( !tf.open() )
{
KMessageBox::error( m_parent, i18n("Could not view revision.") );
......
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