aboutsummaryrefslogtreecommitdiff
path: root/lib/events
diff options
context:
space:
mode:
authorAlexey Rusakov <Kitsune-Ral@users.sf.net>2021-11-28 16:53:51 +0100
committerAlexey Rusakov <Kitsune-Ral@users.sf.net>2021-11-28 16:53:51 +0100
commit8a769cddcd1a063dd9400518ff65c0b1f1aec1b4 (patch)
tree4b9a686edd9f482182353fa50f535507bf6f27e6 /lib/events
parentca1ba482b50c41425bd0a540c7bb68406d10e552 (diff)
downloadlibquotient-8a769cddcd1a063dd9400518ff65c0b1f1aec1b4.tar.gz
libquotient-8a769cddcd1a063dd9400518ff65c0b1f1aec1b4.zip
Comment on const return types in event.h
Proper linters recognise that the returned types are not primitive, while people might still be confused a bit.
Diffstat (limited to 'lib/events')
-rw-r--r--lib/events/event.cpp3
-rw-r--r--lib/events/event.h3
2 files changed, 3 insertions, 3 deletions
diff --git a/lib/events/event.cpp b/lib/events/event.cpp
index 3d66ab55..96be717c 100644
--- a/lib/events/event.cpp
+++ b/lib/events/event.cpp
@@ -46,14 +46,11 @@ QString Event::matrixType() const { return fullJson()[TypeKeyL].toString(); }
QByteArray Event::originalJson() const { return QJsonDocument(_json).toJson(); }
-// On const below: this is to catch accidental attempts to change event JSON
-// NOLINTNEXTLINE(readability-const-return-type)
const QJsonObject Event::contentJson() const
{
return fullJson()[ContentKeyL].toObject();
}
-// NOLINTNEXTLINE(readability-const-return-type)
const QJsonObject Event::unsignedJson() const
{
return fullJson()[UnsignedKeyL].toObject();
diff --git a/lib/events/event.h b/lib/events/event.h
index e45fecca..998a386c 100644
--- a/lib/events/event.h
+++ b/lib/events/event.h
@@ -220,6 +220,9 @@ public:
// a "content" object; but since its structure is different for
// different types, we're implementing it per-event type.
+ // NB: const return types below are meant to catch accidental attempts
+ // to change event JSON (e.g., consider contentJson()["inexistentKey"]).
+
const QJsonObject contentJson() const;
template <typename T = QJsonValue, typename KeyT>