Summary: | new check: test QList.count() must be replaced by !QList.isEmpty() | ||
---|---|---|---|
Product: | [Developer tools] clazy | Reporter: | Stephane MANKOWSKI <stephane> |
Component: | general | Assignee: | Unassigned bugs <unassigned-bugs-null> |
Status: | RESOLVED FIXED | ||
Severity: | wishlist | CC: | eric.lemanissier |
Priority: | NOR | ||
Version First Reported In: | unspecified | ||
Target Milestone: | --- | ||
Platform: | Kubuntu | ||
OS: | Linux | ||
Latest Commit: | http://commits.kde.org/clazy/ef337e2facc0dcae72c84917d0c678b02031b06e | Version Fixed In: | |
Sentry Crash Report: |
Description
Stephane MANKOWSKI
2015-11-21 09:53:36 UTC
Git commit ef337e2facc0dcae72c84917d0c678b02031b06e by Sergio Martins. Committed on 07/12/2015 at 18:40. Pushed by smartins into branch 'master'. Introduce isempty-vs-count check if (list.count()) -> if (!list.isEmpty()) This is just a warning, if someone is interested in doing the fixit please volunteer. M +1 -0 CMakeLists.txt A +9 -0 checks/README-isempty-vs-count A +62 -0 checks/isempty-vs-count.cpp [License: GPL (v2+) (+Qt exception)] A +46 -0 checks/isempty-vs-count.h [License: GPL (v2+) (+Qt exception)] M +11 -11 tests/clazy/test_requested_checks.sh.expected A +7 -0 tests/isempty-vs-count/config.json A +10 -0 tests/isempty-vs-count/main.cpp [License: UNKNOWN] * A +3 -0 tests/isempty-vs-count/main.cpp.expected The files marked with a * at the end have a non valid license. Please read: http://techbase.kde.org/Policies/Licensing_Policy and use the headers which are listed at that page. http://commits.kde.org/clazy/ef337e2facc0dcae72c84917d0c678b02031b06e Hi, Thank you, this helps me a lot. Just one more comment: could be interesting to generate warning for the 2 followings cases too ! if (list.count()>0) {} if (list.count()==0) {} The suggestion to replace container::count with !container::isEmpty works only if there is no argument to container::count. Otherwise container::contains should be suggested |