I think it might be considering the isNull check and because not null it thinks it has content but they are two different things.
style: knownConditionTrueFalse - Condition '!sourceFilePath.isEmpty()' is always true
bool Example(const QString& sourceFilePath, const QUuid& rowMapErid) { bool success = false; if(not sourceFilePath.isNull() and not sourceFilePath.isEmpty() and not rowMapErid.isNull()) { success = CopyFile(sourceFilePath, rowMapErid); } return success; }
https://doc.qt.io/qt-6/qstring.html#isNull doesn't explain the difference, except mentioning "historical reasons". So why have both checks?
This is the key difference
QString("").isNull(); // returns false
QString().isEmpty(); // returns true QString("").isEmpty(); // returns true
I have created https://trac.cppcheck.net/ticket/12776
Log in to post a comment.
I think it might be considering the isNull check and because not null it thinks it has content but they are two different things.
style: knownConditionTrueFalse - Condition '!sourceFilePath.isEmpty()' is always true
https://doc.qt.io/qt-6/qstring.html#isNull doesn't explain the difference, except mentioning "historical reasons". So why have both checks?
This is the key difference
QString("").isNull(); // returns false
QString().isEmpty(); // returns true
QString("").isEmpty(); // returns true
I have created https://trac.cppcheck.net/ticket/12776