Mark more functions as [[nodiscard]] (#6320)

* Fix local variable double declaration.

Took 44 seconds

* Mark functions as [[nodiscard]]

Took 31 minutes

---------

Co-authored-by: Lukas Brübach <Bruebach.Lukas@bdosecurity.de>
This commit is contained in:
BruebachL 2025-11-16 01:39:24 +01:00 committed by GitHub
parent 27708d5964
commit 73763b5ee6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
65 changed files with 258 additions and 257 deletions

View file

@ -57,7 +57,7 @@ public:
ServerInfo_Zone::ZoneType _type);
~Server_CardZone();
const QList<Server_Card *> &getCards() const
[[nodiscard]] const QList<Server_Card *> &getCards() const
{
return cards;
}
@ -65,7 +65,7 @@ public:
int removeCard(Server_Card *card, bool &wasLookedAt);
Server_Card *getCard(int id, int *position = nullptr, bool remove = false);
int getCardsBeingLookedAt() const
[[nodiscard]] int getCardsBeingLookedAt() const
{
return cardsBeingLookedAt;
}
@ -73,28 +73,28 @@ public:
{
cardsBeingLookedAt = qMax(0, _cardsBeingLookedAt);
}
bool isCardAtPosLookedAt(int pos) const;
bool hasCoords() const
[[nodiscard]] bool isCardAtPosLookedAt(int pos) const;
[[nodiscard]] bool hasCoords() const
{
return has_coords;
}
ServerInfo_Zone::ZoneType getType() const
[[nodiscard]] ServerInfo_Zone::ZoneType getType() const
{
return type;
}
QString getName() const
[[nodiscard]] QString getName() const
{
return name;
}
Server_AbstractPlayer *getPlayer() const
[[nodiscard]] Server_AbstractPlayer *getPlayer() const
{
return player;
}
void getInfo(ServerInfo_Zone *info, Server_AbstractParticipant *recipient, bool omniscient);
int getFreeGridColumn(int x, int y, const QString &cardName, bool dontStackSameName) const;
bool isColumnEmpty(int x, int y) const;
bool isColumnStacked(int x, int y) const;
[[nodiscard]] int getFreeGridColumn(int x, int y, const QString &cardName, bool dontStackSameName) const;
[[nodiscard]] bool isColumnEmpty(int x, int y) const;
[[nodiscard]] bool isColumnStacked(int x, int y) const;
void fixFreeSpaces(GameEventStorage &ges);
void moveCardInRow(GameEventStorage &ges, Server_Card *card, int x, int y);
void insertCard(Server_Card *card, int x, int y);
@ -102,11 +102,11 @@ public:
void shuffle(int start = 0, int end = -1);
void clear();
void addWritePermission(int playerId);
const QSet<int> &getPlayersWithWritePermission() const
[[nodiscard]] const QSet<int> &getPlayersWithWritePermission() const
{
return playersWithWritePermission;
}
bool getAlwaysRevealTopCard() const
[[nodiscard]] bool getAlwaysRevealTopCard() const
{
return alwaysRevealTopCard;
}
@ -114,7 +114,7 @@ public:
{
alwaysRevealTopCard = _alwaysRevealTopCard;
}
bool getAlwaysLookAtTopCard() const
[[nodiscard]] bool getAlwaysLookAtTopCard() const
{
return alwaysLookAtTopCard;
}

View file

@ -31,11 +31,11 @@ public:
GameEventStorageItem(const ::google::protobuf::Message &_event, int _playerId, EventRecipients _recipients);
~GameEventStorageItem();
const GameEvent &getGameEvent() const
[[nodiscard]] const GameEvent &getGameEvent() const
{
return *event;
}
EventRecipients getRecipients() const
[[nodiscard]] EventRecipients getRecipients() const
{
return recipients;
}
@ -56,15 +56,15 @@ public:
~GameEventStorage();
void setGameEventContext(const ::google::protobuf::Message &_gameEventContext);
::google::protobuf::Message *getGameEventContext() const
[[nodiscard]] ::google::protobuf::Message *getGameEventContext() const
{
return gameEventContext;
}
const QList<GameEventStorageItem *> &getGameEventList() const
[[nodiscard]] const QList<GameEventStorageItem *> &getGameEventList() const
{
return gameEventList;
}
int getPrivatePlayerId() const
[[nodiscard]] int getPrivatePlayerId() const
{
return privatePlayerId;
}
@ -96,7 +96,7 @@ public:
ResponseContainer(int _cmdId);
~ResponseContainer();
int getCmdId() const
[[nodiscard]] int getCmdId() const
{
return cmdId;
}
@ -104,7 +104,7 @@ public:
{
responseExtension = _responseExtension;
}
::google::protobuf::Message *getResponseExtension() const
[[nodiscard]] ::google::protobuf::Message *getResponseExtension() const
{
return responseExtension;
}
@ -116,11 +116,13 @@ public:
{
postResponseQueue.append(qMakePair(type, item));
}
const QList<QPair<ServerMessage::MessageType, ::google::protobuf::Message *>> &getPreResponseQueue() const
[[nodiscard]] const QList<QPair<ServerMessage::MessageType, ::google::protobuf::Message *>> &
getPreResponseQueue() const
{
return preResponseQueue;
}
const QList<QPair<ServerMessage::MessageType, ::google::protobuf::Message *>> &getPostResponseQueue() const
[[nodiscard]] const QList<QPair<ServerMessage::MessageType, ::google::protobuf::Message *>> &
getPostResponseQueue() const
{
return postResponseQueue;
}

View file

@ -14,14 +14,15 @@ public:
ServerInfo_User_Container(const ServerInfo_User_Container &other);
ServerInfo_User_Container &operator=(const ServerInfo_User_Container &other) = default;
virtual ~ServerInfo_User_Container();
ServerInfo_User *getUserInfo() const
[[nodiscard]] ServerInfo_User *getUserInfo() const
{
return userInfo;
}
void setUserInfo(const ServerInfo_User &_userInfo);
ServerInfo_User &
copyUserInfo(ServerInfo_User &result, bool complete, bool internalInfo = false, bool sessionInfo = false) const;
ServerInfo_User copyUserInfo(bool complete, bool internalInfo = false, bool sessionInfo = false) const;
[[nodiscard]] ServerInfo_User
copyUserInfo(bool complete, bool internalInfo = false, bool sessionInfo = false) const;
};
#endif