File: main.cpp

package info (click to toggle)
clazy 1.17-1
  • links: PTS, VCS
  • area: main
  • in suites: forky
  • size: 5,248 kB
  • sloc: cpp: 23,552; python: 1,450; xml: 450; sh: 237; makefile: 46
file content (51 lines) | stat: -rw-r--r-- 876 bytes parent folder | download | duplicates (6)
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#include <QtCore/qglobal.h>
#include <QtCore/QVector>
#include <QtCore/QString>








struct SomeStruct
{
    bool nonConstMember() { return false; }
    bool constMember() const { return false; }
    bool m;
};


bool global_func() { return false; }

void test()
{
    SomeStruct s;
    Q_ASSERT(s.nonConstMember()); // Warning, but ok with normal agressiveness
    Q_ASSERT(global_func()); // Warning, but ok with normal agressiveness

    int i;
    Q_ASSERT(i = 0); // Warning
}

class MyVector : QVector<int>
{
public:
    MyVector()
    {
        Q_ASSERT(!isEmpty()); // OK

        int a, b;
        Q_ASSERT(a <= b); // OK

        SomeStruct *s;
        Q_ASSERT(s->m); // OK
        Q_ASSERT(s->constMember()); // OK

        QString format;
        int i = 0;
        Q_ASSERT(format.at(i) == QLatin1Char('\'')); // OK
        Q_ASSERT(++i); // Warning
    }
};