diff options
author | Sergio Martins <smartins@kde.org> | 2018-05-15 22:14:50 +0100 |
---|---|---|
committer | Sergio Martins <smartins@kde.org> | 2018-05-15 22:52:15 +0100 |
commit | dcac97b866c83d6645e3bc4af1f42b255f81d9a3 (patch) | |
tree | 02b8f6ba3279fd6df932d8bec8f2125052a919c0 /src/checks/level2 | |
parent | fa6f5d8e206eca0823cfa5030abb5c824f7685ac (diff) |
Make it easier to link to READMEs by removing the level name.
After make install they will still be installed to a level0, 1, 2 sub-folder,
as the cmake instructions are generated by generate.py
BUG: 394237
Diffstat (limited to 'src/checks/level2')
-rw-r--r-- | src/checks/level2/README-base-class-event.md | 4 | ||||
-rw-r--r-- | src/checks/level2/README-copyable-polymorphic.md | 8 | ||||
-rw-r--r-- | src/checks/level2/README-ctor-missing-parent-argument.md | 8 | ||||
-rw-r--r-- | src/checks/level2/README-function-args-by-ref.md | 11 | ||||
-rw-r--r-- | src/checks/level2/README-function-args-by-value.md | 10 | ||||
-rw-r--r-- | src/checks/level2/README-global-const-char-pointer.md | 4 | ||||
-rw-r--r-- | src/checks/level2/README-implicit-casts.md | 19 | ||||
-rw-r--r-- | src/checks/level2/README-missing-qobject-macro.md | 17 | ||||
-rw-r--r-- | src/checks/level2/README-missing-typeinfo.md | 6 | ||||
-rw-r--r-- | src/checks/level2/README-old-style-connect.md | 18 | ||||
-rw-r--r-- | src/checks/level2/README-qstring-allocations.md | 49 | ||||
-rw-r--r-- | src/checks/level2/README-returning-void-expression.md | 14 | ||||
-rw-r--r-- | src/checks/level2/README-rule-of-three.md | 13 | ||||
-rw-r--r-- | src/checks/level2/README-static-pmf.md | 9 | ||||
-rw-r--r-- | src/checks/level2/README-virtual-call-ctor.md | 9 |
15 files changed, 0 insertions, 199 deletions
diff --git a/src/checks/level2/README-base-class-event.md b/src/checks/level2/README-base-class-event.md deleted file mode 100644 index fc61fca8..00000000 --- a/src/checks/level2/README-base-class-event.md +++ /dev/null @@ -1,4 +0,0 @@ -# base-class-event - -Warns when you `return false` inside your `QObject::event()` or `QObject::eventFilter()` reimplementation. -Instead you should probably call the base class method, so the event is correctly handled. diff --git a/src/checks/level2/README-copyable-polymorphic.md b/src/checks/level2/README-copyable-polymorphic.md deleted file mode 100644 index a41ead02..00000000 --- a/src/checks/level2/README-copyable-polymorphic.md +++ /dev/null @@ -1,8 +0,0 @@ -# copyable-polymorphic - -Finds polymorphic classes that are copyable. -These classes are usually vulnerable to slicing [1]. - -To fix these warnings use Q_DISABLE_COPY or delete the copy-ctor yourself. - -[1] <https://en.wikipedia.org/wiki/Object_slicing> diff --git a/src/checks/level2/README-ctor-missing-parent-argument.md b/src/checks/level2/README-ctor-missing-parent-argument.md deleted file mode 100644 index 90b9b3ab..00000000 --- a/src/checks/level2/README-ctor-missing-parent-argument.md +++ /dev/null @@ -1,8 +0,0 @@ -# ctor-missing-parent-argument - -Warns when `QObject` derived classes don't have at least one CTOR receiving a QObject. - -This is an attempt to catch classes which are missing the parent argument. -It doesn't have false-positives, but might miss true-positives. For example, -if you have a CTOR which receives a `QObject* but then forget to pass it to the -base CTOR. diff --git a/src/checks/level2/README-function-args-by-ref.md b/src/checks/level2/README-function-args-by-ref.md deleted file mode 100644 index d755bfbc..00000000 --- a/src/checks/level2/README-function-args-by-ref.md +++ /dev/null @@ -1,11 +0,0 @@ -# function-args-by-ref - -Warns when you should be passing by const-ref. -Types with sizeof > 16 bytes [1] or types which are not trivially-copyable [2] or not trivially-destructible [3] should be passed by ref. A rule of thumb is that if passing by value would trigger copy-ctor and/or dtor then pass by ref instead. - -This check will ignore shared pointers, you're on your own. Most of the times passing shared pointers by const-ref is the best thing to do, but occasionally that will lead to crashes if you're in a method that calls something else that makes the shared pointer ref count go down to zero. - - -- [1] <http://www.macieira.org/blog/2012/02/the-value-of-passing-by-value/> -- [2] <http://en.cppreference.com/w/cpp/concept/TriviallyCopyable> -- [3] <http://www.cplusplus.com/reference/type_traits/is_trivially_destructible/> diff --git a/src/checks/level2/README-function-args-by-value.md b/src/checks/level2/README-function-args-by-value.md deleted file mode 100644 index 1e96e4ae..00000000 --- a/src/checks/level2/README-function-args-by-value.md +++ /dev/null @@ -1,10 +0,0 @@ -# function-args-by-value - -Warns when you should be passing by value instead of by-ref. -Types with sizeof <= 16 bytes [1] which are trivially-copyable [2] and trivially-destructible [3] should be passed by value. - -Only fix these warnings if you're sure that the value would be passed in a CPU register instead on the stack. - -- [1] <http://www.macieira.org/blog/2012/02/the-value-of-passing-by-value/> -- [2] <http://en.cppreference.com/w/cpp/concept/TriviallyCopyable> -- [3] <http://www.cplusplus.com/reference/type_traits/is_trivially_destructible/> diff --git a/src/checks/level2/README-global-const-char-pointer.md b/src/checks/level2/README-global-const-char-pointer.md deleted file mode 100644 index 42cfa996..00000000 --- a/src/checks/level2/README-global-const-char-pointer.md +++ /dev/null @@ -1,4 +0,0 @@ -# global-const-char-pointer - -Finds where you're using `const char *foo` instead of `const char *const foo` or `const char []foo`. -The former case adds a pointer in .data, pointing to .rodata. The later cases only use .rodata. diff --git a/src/checks/level2/README-implicit-casts.md b/src/checks/level2/README-implicit-casts.md deleted file mode 100644 index 8a5f3b0f..00000000 --- a/src/checks/level2/README-implicit-casts.md +++ /dev/null @@ -1,19 +0,0 @@ -# implicit-casts - -Finds places with unwanted implicit casts in function calls. - -#### Supported cases - -* pointer->bool cast in functions accepting bool and pointers, example: - - MyWidget(bool b, QObject *parent = nullptr) {} - MyWidget(parent); - -* bool->int - - void func(int duration); - func(someBool); - -This last case is disabled due to false positives when calling C code. -You can enable it by with: -`export CLAZY_EXTRA_OPTIONS=implicit-casts-bool-to-int` diff --git a/src/checks/level2/README-missing-qobject-macro.md b/src/checks/level2/README-missing-qobject-macro.md deleted file mode 100644 index 4b56013a..00000000 --- a/src/checks/level2/README-missing-qobject-macro.md +++ /dev/null @@ -1,17 +0,0 @@ -# missing-qobject-macro - -Finds `QObject` derived classes that don't have a Q_OBJECT macro. - -#### Reasons to use Q_OBJECT -- Signals and slots -- `QObject::inherits` -- `qobject_cast` -- `metaObject()->className()` -- Use your custom widget as a selector in Qt stylesheets - -#### Reasons not to use Q_OBJECT -- Templated QObjects -- Compilation time - -This check can't be used with pre-compiled headers support. -This check doesn't have false positives, but it's not included in level <= 1 because the missing Q_OBJECT might be intentional. diff --git a/src/checks/level2/README-missing-typeinfo.md b/src/checks/level2/README-missing-typeinfo.md deleted file mode 100644 index 675fc2f0..00000000 --- a/src/checks/level2/README-missing-typeinfo.md +++ /dev/null @@ -1,6 +0,0 @@ -# missing-typeinfo - -Suggests usage of `Q_PRIMITIVE_TYPE` or `Q_MOVABLE_TYPE` in cases where you're using `QList<T>` and `sizeof(T) > sizeof(void*)` -or using `QVector<T>`, unless they already have a type info classification. - -See `Q_DECLARE_TYPEINFO` in Qt documentation for more information. diff --git a/src/checks/level2/README-old-style-connect.md b/src/checks/level2/README-old-style-connect.md deleted file mode 100644 index 2cad4e8d..00000000 --- a/src/checks/level2/README-old-style-connect.md +++ /dev/null @@ -1,18 +0,0 @@ -# old-style-connect - -Finds usages of old style connects. -Connecting with old style syntax (`SIGNAL`/`SLOT`) is much slower than using pointer to member syntax (PMF). - -Here's however a non-exhaustive list of caveats you should be aware of: -- You can't disconnect with new-syntax if the connect was made with old-syntax (and vice-versa) -- You can't disconnect from a static slot with new-syntax (although connecting works) -- Difference in behaviour when calling slots of partially destroyed objects (<https://codereview.qt-project.org/#/c/83800>) - -#### Fixits - -You can convert the most simple cases with `export CLAZY_FIXIT=fix-old-style-connect`. -Be careful, as PMF is not a 100% drop-in replacement. - -#### Pitfalls - -Although this check doesn't have false-positives it's a level2 check, that's because some connects are tricky to convert to PMF syntax and might introduce bugs if you don't know what you're doing. diff --git a/src/checks/level2/README-qstring-allocations.md b/src/checks/level2/README-qstring-allocations.md deleted file mode 100644 index fda4278e..00000000 --- a/src/checks/level2/README-qstring-allocations.md +++ /dev/null @@ -1,49 +0,0 @@ -# qstring-unneeded-heap-allocations - -Finds places with unneeded memory allocations due to temporary `QString`s. - -Here's a summary of usages that allocate: - -1. `QString s = "foo"; // Allocates, use QStringLiteral("foo") instead` - -2. `QString s = QLatin1String("foo"); // Allocates, use QStringLiteral("foo") instead` - - 2.1 `QString s = QLatin1String(""); // No allocation. QString is optimized for this case, so it's safe for empty literals` - -3. `QString s = QStringLiteral("foo"); // No allocation` - -4. `QString s = QString::fromLatin1("foo"); // Allocates, use QStringLiteral` - -5. `QString s = QString::fromUtf8("foo"); // Allocates, use QStringLiteral` - -6. `s == "foo" // Allocates, use QLatin1String` - -7. `s == QLatin1String("foo) // No allocation` - -8. `s == QStringLiteral("foo") // No allocation` - -9. `QString {"append", "compare", "endsWith", "startsWith", "indexOf", "insert",` - ` "lastIndexOf", "prepend", "replace", "contains" } // They all have QLatin1String overloads, so passing a QLatin1String is ok.` - -10. `QString::fromLatin1("foo %1").arg(bar) // Allocates twice, replacing with QStringLiteral makes it allocate only once.` - - -#### Fixits - - fix-qlatin1string-allocations // To replace QLatin1String with QStringLiteral only where it was allocating before - fix-fromLatin1_fromUtf8-allocations // To replace fromLatin1() and fromUtf8() so it doesn't allocate - fix-fromCharPtrAllocations // To replace raw string literals so it doesn't allocate - - Example: - export CLAZY_FIXIT="fix-fromCharPtrAllocations" - -#### Pitfalls - -- `QStringLiteral` might make your app crash at exit if plugins are involved. -See: -<https://blogs.kde.org/2015/11/05/qregexp-qstringliteral-crash-exit> and -<http://lists.qt-project.org/pipermail/development/2015-November/023681.html> - -- Also note that MSVC crashes when `QStringLiteral` is used inside initializer lists. For that reason no warning or fixit is emitted for this case unless you set an env variable: - - export CLAZY_EXTRA_OPTIONS="qstring-allocations-no-msvc-compat" diff --git a/src/checks/level2/README-returning-void-expression.md b/src/checks/level2/README-returning-void-expression.md deleted file mode 100644 index bb405092..00000000 --- a/src/checks/level2/README-returning-void-expression.md +++ /dev/null @@ -1,14 +0,0 @@ -# returning-void-expression - -Warns when returning a void expression. - -Example: -``` -void doStuff() -{ - if (cond) - return // Oops, forgot the ; but it still compiles since processStuff() returns void. - - processStuff(); -} -``` diff --git a/src/checks/level2/README-rule-of-three.md b/src/checks/level2/README-rule-of-three.md deleted file mode 100644 index 9e9f64ea..00000000 --- a/src/checks/level2/README-rule-of-three.md +++ /dev/null @@ -1,13 +0,0 @@ -# rule-of-three - -Implements the rule of three: -<https://en.wikipedia.org/wiki/Rule_of_three_%28C%2B%2B_programming%29> - -#### Exceptions -To reduce the amount of warnings, these cases won't emit warnings: -- class has a QSharedDataPointer member -- class inherits from QSharedData -- if only the dtor is implemented and it's protected -- class name ends with "Private" and is defined in a .cpp, .cxx or _p.h file - -In some cases you're missing methods, in others you have too many methods. You'll have to judge what's the correct fix and beware of binary compatibility. diff --git a/src/checks/level2/README-static-pmf.md b/src/checks/level2/README-static-pmf.md deleted file mode 100644 index e27e7b6c..00000000 --- a/src/checks/level2/README-static-pmf.md +++ /dev/null @@ -1,9 +0,0 @@ -# static-pmf - -Warns when storing a pointer to QObject member function into a static variable. -Passing such variable to a connect is known to fail when using MingW. - -Example: - -static auto pmf = &QObject::destroyed; -QCOMPARE(pmf, &QObject::destroyed); // fails diff --git a/src/checks/level2/README-virtual-call-ctor.md b/src/checks/level2/README-virtual-call-ctor.md deleted file mode 100644 index 2bf715c9..00000000 --- a/src/checks/level2/README-virtual-call-ctor.md +++ /dev/null @@ -1,9 +0,0 @@ -# virtual-call-ctor - -Finds places where you're calling pure virtual functions inside a constructor or destructor. -Compilers usually warn about this if there isn't any indirection, this check will catch cases like calling -a non-pure virtual that calls a pure virtual. - - -This check only looks for pure virtuals, ignoring non-pure, which in theory you shouldn't call, -but seems common practice. |