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
+1 -1
View File
@@ -391,7 +391,7 @@ QString AbstractIrcServer::cleanChannelName(const QString &dirtyChannelName)
void AbstractIrcServer::addFakeMessage(const QString &data)
{
auto fakeMessage = Communi::IrcMessage::fromData(
auto *fakeMessage = Communi::IrcMessage::fromData(
data.toUtf8(), this->readConnection_.get());
if (fakeMessage->command() == "PRIVMSG")
+17 -3
View File
@@ -104,10 +104,16 @@ Irc::Irc()
// set server of abandoned channels
for (auto weak : ab->second)
{
if (auto shared = weak.lock())
if (auto ircChannel =
{
if (auto *ircChannel =
dynamic_cast<IrcChannel *>(shared.get()))
{
ircChannel->setServer(server.get());
}
}
}
// add new server with abandoned channels
this->servers_.emplace(args.item.id, std::move(server));
@@ -132,10 +138,16 @@ Irc::Irc()
// set server of abandoned servers to nullptr
for (auto weak : abandoned)
{
if (auto shared = weak.lock())
if (auto ircChannel =
{
if (auto *ircChannel =
dynamic_cast<IrcChannel *>(shared.get()))
{
ircChannel->setServer(nullptr);
}
}
}
this->abandonedChannels_[args.item.id] = abandoned;
this->servers_.erase(server);
@@ -156,7 +168,7 @@ Irc::Irc()
QAbstractTableModel *Irc::newConnectionModel(QObject *parent)
{
auto model = new Model(parent);
auto *model = new Model(parent);
model->initialize(&this->connections);
return model;
}
@@ -234,7 +246,9 @@ void Irc::save()
void Irc::load()
{
if (this->loaded_)
{
return;
}
this->loaded_ = true;
QString config = configPath();
+2
View File
@@ -100,7 +100,9 @@ bool IrcChannel::canReconnect() const
void IrcChannel::reconnect()
{
if (this->server())
{
this->server()->connect();
}
}
} // namespace chatterino
+10 -4
View File
@@ -261,7 +261,7 @@ void IrcServer::readConnectionMessageReceived(Communi::IrcMessage *message)
switch (message->type())
{
case Communi::IrcMessage::Join: {
auto x = static_cast<Communi::IrcJoinMessage *>(message);
auto *x = static_cast<Communi::IrcJoinMessage *>(message);
if (auto it = this->channels.find(x->channel());
it != this->channels.end())
@@ -274,9 +274,11 @@ void IrcServer::readConnectionMessageReceived(Communi::IrcMessage *message)
}
else
{
if (auto c =
if (auto *c =
dynamic_cast<ChannelChatters *>(shared.get()))
{
c->addJoinedUser(x->nick());
}
}
}
}
@@ -284,7 +286,7 @@ void IrcServer::readConnectionMessageReceived(Communi::IrcMessage *message)
}
case Communi::IrcMessage::Part: {
auto x = static_cast<Communi::IrcPartMessage *>(message);
auto *x = static_cast<Communi::IrcPartMessage *>(message);
if (auto it = this->channels.find(x->channel());
it != this->channels.end())
@@ -297,9 +299,11 @@ void IrcServer::readConnectionMessageReceived(Communi::IrcMessage *message)
}
else
{
if (auto c =
if (auto *c =
dynamic_cast<ChannelChatters *>(shared.get()))
{
c->addPartedUser(x->nick());
}
}
}
}
@@ -327,7 +331,9 @@ void IrcServer::readConnectionMessageReceived(Communi::IrcMessage *message)
for (auto &&weak : this->channels)
{
if (auto shared = weak.lock())
{
shared->addMessage(msg);
}
}
};
}
+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)