diff options
Diffstat (limited to 'docs/checks/README-writing-to-temporary.md')
-rw-r--r-- | docs/checks/README-writing-to-temporary.md | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/docs/checks/README-writing-to-temporary.md b/docs/checks/README-writing-to-temporary.md new file mode 100644 index 00000000..f39eb5d4 --- /dev/null +++ b/docs/checks/README-writing-to-temporary.md @@ -0,0 +1,19 @@ +# writing-to-temporary + +Catches when calling setters on temporaries. +#### Example +`widget->sizePolicy().setHorizontalStretch(1);` + +Which should instead be: +``` +QSizePolicy sp = widget->sizePolicy(); +sp.setHorizontalStretch(1); +widget->setSizePolicy(sp); +``` + +#### Requirements +- The method must be of void return type, and must belong to one of these whitelisted classes: + QList, QVector, QMap, QHash, QString, QSet, QByteArray, QUrl, QVarLengthArray, QLinkedList, QRect, QRectF, QBitmap, QVector2D, QVector3D, QVector4D, QSize, QSizeF, QSizePolicy + +- Optionally, if you set env variable `CLAZY_EXTRA_OPTIONS="writing-to-temporary-widen-criteria"`, it will warn on any method with name starting with "set", regardless of it being whitelisted, example: +`foo().setBar()` |