File: main.cpp.fixed.expected

package info (click to toggle)
clazy 1.17-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 5,248 kB
  • sloc: cpp: 23,552; python: 1,450; xml: 450; sh: 237; makefile: 45
file content (34 lines) | stat: -rw-r--r-- 872 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#include <QtCore/QList>
#include <QtCore/QMap>
#include <QtCore/QMultiMap>

QList<int> getList() {return {};}

void test()
{
    QList<int> list;
    if (!list.isEmpty()) {}   // Warning
    if (list.isEmpty()) {}   // Warning
    bool b1 = !list.isEmpty(); // Warning
    bool b2 = !list.isEmpty(); // Warning
    if (list.indexOf(1)) {} // OK

    QMap<int, int> map;
    if (!map.isEmpty()) {} // Warning
    if (map.contains(2)) {} // Warning

    QMultiMap<int, int> multiMap;
    if (!multiMap.isEmpty()) {} // Warning
    if (multiMap.contains(2)) {} // Warning
    if (multiMap.contains(2)) {} // Warning

    if (!getList().isEmpty()) {} // Warning
}

void testExplicitConversion()
{
    if (getList().isEmpty()) {} // Warning
    if (getList().isEmpty()) {} // Warning
    if (!getList().isEmpty()) {} // Warning
    const bool myCheck = !getList().isEmpty();
}