Bug 353801

Summary: new check: Warn when foreach (foo, container.values()) or foreach (foo, container.keys())
Product: [Developer tools] clazy Reporter: Sergio Martins <smartins>
Component: generalAssignee: Sergio Martins <smartins>
Status: RESOLVED FIXED    
Severity: wishlist    
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:

Description Sergio Martins 2015-10-11 17:56:21 UTC
Causes an extra iteration and memory allocation for temporary QList
Comment 1 Sergio Martins 2016-02-11 22:26:38 UTC
Git commit 66b5fecd1af79472fb8ef67b22be19405dd5550c by Sergio Martins.
Committed on 11/02/2016 at 22:26.
Pushed by smartins into branch 'master'.

container-anti-pattern: Warn when using values() and keys() in for

for (auto i : hash.values()) {} // Warning
foreach (auto i, hash.values()) {} // Warning

M  +4    -0    checks/README-container-anti-pattern
M  +44   -1    checks/container-anti-pattern.cpp
M  +5    -0    checks/container-anti-pattern.h
M  +11   -0    tests/container-anti-pattern/main.cpp
M  +4    -0    tests/container-anti-pattern/main.cpp.expected

http://commits.kde.org/clazy/66b5fecd1af79472fb8ef67b22be19405dd5550c