Bug 353801 - new check: Warn when foreach (foo, container.values()) or foreach (foo, container.keys())
Summary: new check: Warn when foreach (foo, container.values()) or foreach (foo, conta...
Status: RESOLVED FIXED
Alias: None
Product: clazy
Classification: Developer tools
Component: general (show other bugs)
Version: unspecified
Platform: Other Linux
: NOR wishlist
Target Milestone: ---
Assignee: Sergio Martins
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-10-11 17:56 UTC by Sergio Martins
Modified: 2016-02-11 22:26 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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