Skip to content

Commit

Permalink
Merge #810(kitsune): Sonar cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
KitsuneRal authored Oct 16, 2024
2 parents b07afdc + ec193bc commit 17acff6
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 17 deletions.
17 changes: 8 additions & 9 deletions Quotient/events/eventcontent.h
Original file line number Diff line number Diff line change
Expand Up @@ -282,20 +282,19 @@ using FileContent = UrlBasedContent<FileInfo>;
template <typename InfoT>
class PlayableContent : public UrlBasedContent<InfoT> {
public:
using UrlBasedContent<InfoT>::UrlBasedContent;
PlayableContent(const QJsonObject& json)
: UrlBasedContent<InfoT>(json)
, duration(FileInfo::originalInfoJson["duration"_L1].toInt())
{}
using UrlBasedContent<InfoT>::UrlBasedContent;
explicit PlayableContent(const QJsonObject& json)
: UrlBasedContent<InfoT>(json), duration(FileInfo::originalInfoJson["duration"_L1].toInt())
{}

protected:
void fillInfoJson(QJsonObject& infoJson) const override
{
infoJson.insert("duration"_L1, duration);
void fillInfoJson(QJsonObject& infoJson) const override
{
infoJson.insert("duration"_L1, duration);
}

public:
int duration;
int duration;
};

//! \brief Content class for m.video
Expand Down
6 changes: 3 additions & 3 deletions Quotient/events/roommessageevent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ inline bool isReplacement(const std::optional<EventRelation>& rel)
QJsonObject RoomMessageEvent::assembleContentJson(const QString& plainBody,
const QString& jsonMsgType,
std::unique_ptr<Base> content,
std::optional<EventRelation> relatesTo)
const std::optional<EventRelation>& relatesTo)
{
QJsonObject json;
if (content) {
Expand Down Expand Up @@ -118,14 +118,14 @@ QJsonObject RoomMessageEvent::assembleContentJson(const QString& plainBody,

RoomMessageEvent::RoomMessageEvent(const QString& plainBody, const QString& jsonMsgType,
std::unique_ptr<Base> content,
std::optional<EventRelation> relatesTo)
const std::optional<EventRelation>& relatesTo)
: RoomEvent(basicJson(TypeId, assembleContentJson(plainBody, jsonMsgType, std::move(content),
relatesTo)))
{}

RoomMessageEvent::RoomMessageEvent(const QString& plainBody, MsgType msgType,
std::unique_ptr<Base> content,
std::optional<EventRelation> relatesTo)
const std::optional<EventRelation>& relatesTo)
: RoomMessageEvent(plainBody, msgTypeToJson(msgType), std::move(content), relatesTo)
{}

Expand Down
6 changes: 3 additions & 3 deletions Quotient/events/roommessageevent.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ class QUOTIENT_API RoomMessageEvent : public RoomEvent {

RoomMessageEvent(const QString& plainBody, const QString& jsonMsgType,
std::unique_ptr<EventContent::Base> content = nullptr,
std::optional<EventRelation> relatesTo = std::nullopt);
const std::optional<EventRelation>& relatesTo = std::nullopt);
explicit RoomMessageEvent(const QString& plainBody, MsgType msgType = MsgType::Text,
std::unique_ptr<EventContent::Base> content = nullptr,
std::optional<EventRelation> relatesTo = std::nullopt);
const std::optional<EventRelation>& relatesTo = std::nullopt);

explicit RoomMessageEvent(const QJsonObject& obj);

Expand Down Expand Up @@ -179,7 +179,7 @@ class QUOTIENT_API RoomMessageEvent : public RoomEvent {
// FIXME: should it really be static?
static QJsonObject assembleContentJson(const QString& plainBody, const QString& jsonMsgType,
std::unique_ptr<EventContent::Base> content,
std::optional<EventRelation> relatesTo);
const std::optional<EventRelation>& relatesTo);

Q_ENUM(MsgType)
};
Expand Down
4 changes: 2 additions & 2 deletions Quotient/room.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1740,8 +1740,8 @@ Room::Private::moveEventsToTimeline(RoomEventsRange events,
if (usesEncryption)
if (auto* const rme = ti.viewAs<RoomMessageEvent>())
if (const auto fileInfo = rme->fileContent()) {
if (auto* const efm = std::get_if<EncryptedFileMetadata>(
&fileInfo->source))
if (const auto* const efm =
std::get_if<EncryptedFileMetadata>(&fileInfo->source))
FileMetadataMap::add(id, eId, *efm);
}

Expand Down

0 comments on commit 17acff6

Please sign in to comment.