Eg: QMap<QString,QString> map; Q_FOREACH( const QString& key, map.keys() ) { QString val = map.value(key); ... } It's inefficient, and it'd be nice to catch this and suggest using QMap::iterator/QHash::Iterator to iterate over both the keys and values at the same time to avoid the unnecessary lookup. Reproducible: Always
The container-anti-pattern will warn when you iterate on keys(), which you should fix with: Q_FOREACH( const QString& value, map) {}, or using iterator if you need both value and key. There might be corner-cases where people are doing something very stupid, but it's difficult to make a check for more imaginative cases, so I consider this done