refactor: fix clang-tidy auto*, const&, and curly braces (#5083)

This commit is contained in:
pajlada
2024-01-14 17:54:52 +01:00
committed by GitHub
parent 292f9b9734
commit 5b6675abb4
78 changed files with 647 additions and 228 deletions
+29 -7
View File
@@ -442,7 +442,9 @@ std::optional<ChannelPointReward> TwitchChannel::channelPointReward(
auto it = rewards->find(rewardId);
if (it == rewards->end())
{
return std::nullopt;
}
return it->second;
}
@@ -572,7 +574,7 @@ void TwitchChannel::roomIdChanged()
QString TwitchChannel::prepareMessage(const QString &message) const
{
auto app = getApp();
auto *app = getApp();
QString parsedMessage = app->emotes->emojis.replaceShortCodes(message);
parsedMessage = parsedMessage.simplified();
@@ -618,7 +620,7 @@ QString TwitchChannel::prepareMessage(const QString &message) const
void TwitchChannel::sendMessage(const QString &message)
{
auto app = getApp();
auto *app = getApp();
if (!app->accounts->twitch.isLoggedIn())
{
if (!message.isEmpty())
@@ -652,7 +654,7 @@ void TwitchChannel::sendMessage(const QString &message)
void TwitchChannel::sendReply(const QString &message, const QString &replyId)
{
auto app = getApp();
auto *app = getApp();
if (!app->accounts->twitch.isLoggedIn())
{
if (!message.isEmpty())
@@ -803,7 +805,9 @@ std::optional<EmotePtr> TwitchChannel::bttvEmote(const EmoteName &name) const
auto it = emotes->find(name);
if (it == emotes->end())
{
return std::nullopt;
}
return it->second;
}
@@ -813,7 +817,9 @@ std::optional<EmotePtr> TwitchChannel::ffzEmote(const EmoteName &name) const
auto it = emotes->find(name);
if (it == emotes->end())
{
return std::nullopt;
}
return it->second;
}
@@ -1181,11 +1187,15 @@ void TwitchChannel::loadRecentMessages()
[weak](const auto &messages) {
auto shared = weak.lock();
if (!shared)
{
return;
}
auto tc = dynamic_cast<TwitchChannel *>(shared.get());
auto *tc = dynamic_cast<TwitchChannel *>(shared.get());
if (!tc)
{
return;
}
tc->addMessagesAtStart(messages);
tc->loadingRecentMessages_.clear();
@@ -1208,11 +1218,15 @@ void TwitchChannel::loadRecentMessages()
[weak]() {
auto shared = weak.lock();
if (!shared)
{
return;
}
auto tc = dynamic_cast<TwitchChannel *>(shared.get());
auto *tc = dynamic_cast<TwitchChannel *>(shared.get());
if (!tc)
{
return;
}
tc->loadingRecentMessages_.clear();
},
@@ -1253,11 +1267,15 @@ void TwitchChannel::loadRecentMessagesReconnect()
[weak](const auto &messages) {
auto shared = weak.lock();
if (!shared)
{
return;
}
auto tc = dynamic_cast<TwitchChannel *>(shared.get());
auto *tc = dynamic_cast<TwitchChannel *>(shared.get());
if (!tc)
{
return;
}
tc->fillInMissingMessages(messages);
tc->loadingRecentMessages_.clear();
@@ -1265,11 +1283,15 @@ void TwitchChannel::loadRecentMessagesReconnect()
[weak]() {
auto shared = weak.lock();
if (!shared)
{
return;
}
auto tc = dynamic_cast<TwitchChannel *>(shared.get());
auto *tc = dynamic_cast<TwitchChannel *>(shared.get());
if (!tc)
{
return;
}
tc->loadingRecentMessages_.clear();
},
+8
View File
@@ -395,11 +395,15 @@ std::shared_ptr<Channel> TwitchIrcServer::getChannelOrEmptyByID(
{
auto channel = weakChannel.lock();
if (!channel)
{
continue;
}
auto twitchChannel = std::dynamic_pointer_cast<TwitchChannel>(channel);
if (!twitchChannel)
{
continue;
}
if (twitchChannel->roomId() == channelId &&
twitchChannel->getName().count(':') < 2)
@@ -414,9 +418,13 @@ std::shared_ptr<Channel> TwitchIrcServer::getChannelOrEmptyByID(
QString TwitchIrcServer::cleanChannelName(const QString &dirtyChannelName)
{
if (dirtyChannelName.startsWith('#'))
{
return dirtyChannelName.mid(1).toLower();
}
else
{
return dirtyChannelName.toLower();
}
}
bool TwitchIrcServer::hasSeparateWriteConnection() const
@@ -1233,7 +1233,9 @@ std::unordered_map<QString, QString> TwitchMessageBuilder::parseBadgeInfoTag(
auto infoIt = tags.constFind("badge-info");
if (infoIt == tags.end())
{
return infoMap;
}
auto info = infoIt.value().toString().split(',', Qt::SkipEmptyParts);
@@ -1651,7 +1653,7 @@ void TwitchMessageBuilder::listOfUsersSystemMessage(QString prefix,
builder->emplace<TextElement>(prefix, MessageElementFlag::Text,
MessageColor::System);
bool isFirst = true;
auto tc = dynamic_cast<TwitchChannel *>(channel);
auto *tc = dynamic_cast<TwitchChannel *>(channel);
for (const QString &username : users)
{
if (!isFirst)