Bug 408020

Summary: Suggest to use addRow instead of newRow+sprintf
Product: [Developer tools] clazy Reporter: Giuseppe D'Angelo <dangelog>
Component: generalAssignee: Unassigned bugs <unassigned-bugs-null>
Status: REPORTED ---    
Severity: wishlist CC: smartins
Priority: NOR    
Version First Reported In: unspecified   
Target Milestone: ---   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:

Description Giuseppe D'Angelo 2019-05-28 10:52:15 UTC
Data-driven tests with QTest can use either newRow or addRow to add a new testdata row. Each data row has a unique data-tag used in logs, testrunners etc.

Sometimes this data-tag is generated procedurally:

  QTest::newRow(qPrintable(QString("Testing %1").arg(foo))) << foo;

However there's a better solution: QTest::addRow, which natively supports printf syntax:

  QTest::addRow("Testing %d", foo) << foo;

The idea is that this check should see if newRow is being used with qPrintable / QString::asprintf / etc. and suggest addRow instead.