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);
}
}
};
}