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

@ -27,22 +27,22 @@ public:
{
Type = typeCardDrag
};
int type() const override
[[nodiscard]] int type() const override
{
return Type;
}
AbstractCardDragItem(AbstractCardItem *_item, const QPointF &_hotSpot, AbstractCardDragItem *parentDrag = 0);
QRectF boundingRect() const override
[[nodiscard]] QRectF boundingRect() const override
{
return QRectF(0, 0, CARD_WIDTH, CARD_HEIGHT);
}
QPainterPath shape() const override;
[[nodiscard]] QPainterPath shape() const override;
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override;
AbstractCardItem *getItem() const
[[nodiscard]] AbstractCardItem *getItem() const
{
return item;
}
QPointF getHotSpot() const
[[nodiscard]] QPointF getHotSpot() const
{
return hotSpot;
}

View file

@ -36,22 +36,22 @@ public:
ArrowItem(Player *_player, int _id, ArrowTarget *_startItem, ArrowTarget *_targetItem, const QColor &color);
~ArrowItem() override;
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override;
QRectF boundingRect() const override
[[nodiscard]] QRectF boundingRect() const override
{
return path.boundingRect();
}
QPainterPath shape() const override
[[nodiscard]] QPainterPath shape() const override
{
return path;
}
void updatePath();
void updatePath(const QPointF &endPoint);
int getId() const
[[nodiscard]] int getId() const
{
return id;
}
Player *getPlayer() const
[[nodiscard]] Player *getPlayer() const
{
return player;
}
@ -63,11 +63,11 @@ public:
{
targetItem = _item;
}
ArrowTarget *getStartItem() const
[[nodiscard]] ArrowTarget *getStartItem() const
{
return startItem;
}
ArrowTarget *getTargetItem() const
[[nodiscard]] ArrowTarget *getTargetItem() const
{
return targetItem;
}

View file

@ -28,18 +28,18 @@ public:
explicit ArrowTarget(Player *_owner, QGraphicsItem *parent = nullptr);
~ArrowTarget() override;
Player *getOwner() const
[[nodiscard]] Player *getOwner() const
{
return owner;
}
void setBeingPointedAt(bool _beingPointedAt);
bool getBeingPointedAt() const
[[nodiscard]] bool getBeingPointedAt() const
{
return beingPointedAt;
}
const QList<ArrowItem *> &getArrowsFrom() const
[[nodiscard]] const QList<ArrowItem *> &getArrowsFrom() const
{
return arrowsFrom;
}
@ -51,7 +51,7 @@ public:
{
arrowsFrom.removeOne(arrow);
}
const QList<ArrowItem *> &getArrowsTo() const
[[nodiscard]] const QList<ArrowItem *> &getArrowsTo() const
{
return arrowsTo;
}

View file

@ -51,7 +51,7 @@ public:
{
Type = typeCard
};
int type() const override
[[nodiscard]] int type() const override
{
return Type;
}
@ -62,13 +62,13 @@ public:
CardZoneLogic *_zone = nullptr);
void retranslateUi();
CardZoneLogic *getZone() const
[[nodiscard]] CardZoneLogic *getZone() const
{
return zone;
}
void setZone(CardZoneLogic *_zone);
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override;
QPoint getGridPoint() const
[[nodiscard]] QPoint getGridPoint() const
{
return gridPoint;
}
@ -76,11 +76,11 @@ public:
{
gridPoint = _gridPoint;
}
QPoint getGridPos() const
[[nodiscard]] QPoint getGridPos() const
{
return gridPoint;
}
Player *getOwner() const
[[nodiscard]] Player *getOwner() const
{
return owner;
}
@ -88,32 +88,32 @@ public:
{
owner = _owner;
}
bool getAttacking() const
[[nodiscard]] bool getAttacking() const
{
return attacking;
}
void setAttacking(bool _attacking);
const QMap<int, int> &getCounters() const
[[nodiscard]] const QMap<int, int> &getCounters() const
{
return counters;
}
void setCounter(int _id, int _value);
QString getAnnotation() const
[[nodiscard]] QString getAnnotation() const
{
return annotation;
}
void setAnnotation(const QString &_annotation);
bool getDoesntUntap() const
[[nodiscard]] bool getDoesntUntap() const
{
return doesntUntap;
}
void setDoesntUntap(bool _doesntUntap);
QString getPT() const
[[nodiscard]] QString getPT() const
{
return pt;
}
void setPT(const QString &_pt);
bool getDestroyOnZoneChange() const
[[nodiscard]] bool getDestroyOnZoneChange() const
{
return destroyOnZoneChange;
}
@ -121,7 +121,7 @@ public:
{
destroyOnZoneChange = _destroy;
}
CardItem *getAttachedTo() const
[[nodiscard]] CardItem *getAttachedTo() const
{
return attachedTo;
}
@ -134,7 +134,7 @@ public:
{
attachedCards.removeOne(card);
}
const QList<CardItem *> &getAttachedCards() const
[[nodiscard]] const QList<CardItem *> &getAttachedCards() const
{
return attachedCards;
}

View file

@ -35,7 +35,7 @@ public:
const QString &_originZone = QString());
~DeckViewCard() override;
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override;
const QString &getOriginZone() const
[[nodiscard]] const QString &getOriginZone() const
{
return originZone;
}
@ -71,34 +71,34 @@ private:
QMultiMap<QString, DeckViewCard *> cardsByType;
QList<QPair<int, int>> currentRowsAndCols;
qreal width, height;
int getCardTypeTextWidth() const;
[[nodiscard]] int getCardTypeTextWidth() const;
public:
enum
{
Type = typeDeckViewCardContainer
};
int type() const override
[[nodiscard]] int type() const override
{
return Type;
}
explicit DeckViewCardContainer(const QString &_name);
QRectF boundingRect() const override;
[[nodiscard]] QRectF boundingRect() const override;
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override;
void addCard(DeckViewCard *card);
void removeCard(DeckViewCard *card);
const QList<DeckViewCard *> &getCards() const
[[nodiscard]] const QList<DeckViewCard *> &getCards() const
{
return cards;
}
const QString &getName() const
[[nodiscard]] const QString &getName() const
{
return name;
}
void setWidth(qreal _width);
QList<QPair<int, int>> getRowsAndCols() const;
QSizeF calculateBoundingRect(const QList<QPair<int, int>> &rowsAndCols) const;
[[nodiscard]] QList<QPair<int, int>> getRowsAndCols() const;
[[nodiscard]] QSizeF calculateBoundingRect(const QList<QPair<int, int>> &rowsAndCols) const;
void rearrangeItems(const QList<QPair<int, int>> &rowsAndCols);
};
@ -123,7 +123,7 @@ public:
{
locked = _locked;
}
bool getLocked() const
[[nodiscard]] bool getLocked() const
{
return locked;
}
@ -135,7 +135,7 @@ public:
}
void rearrangeItems();
void updateContents();
QList<MoveCard_ToZone> getSideboardPlan() const;
[[nodiscard]] QList<MoveCard_ToZone> getSideboardPlan() const;
void resetSideboardPlan();
void applySideboardPlan(const QList<MoveCard_ToZone> &plan);
};
@ -162,7 +162,7 @@ public:
{
deckViewScene->setLocked(_locked);
}
QList<MoveCard_ToZone> getSideboardPlan() const
[[nodiscard]] QList<MoveCard_ToZone> getSideboardPlan() const
{
return deckViewScene->getSideboardPlan();
}

View file

@ -32,7 +32,7 @@ signals:
public:
explicit ToggleButton(QWidget *parent = nullptr);
bool getState() const
[[nodiscard]] bool getState() const
{
return state;
}

View file

@ -39,7 +39,7 @@ class DlgCreateToken : public QDialog
Q_OBJECT
public:
explicit DlgCreateToken(const QStringList &_predefinedTokens, QWidget *parent = nullptr);
TokenInfo getTokenInfo() const;
[[nodiscard]] TokenInfo getTokenInfo() const;
protected:
void closeEvent(QCloseEvent *event) override;

View file

@ -34,10 +34,10 @@ public:
QStringList exprs = QStringList(),
uint numberOfHits = 1,
bool autoPlay = false);
QString getExpr() const;
QStringList getExprs() const;
uint getNumberOfHits() const;
bool isAutoPlay() const;
[[nodiscard]] QString getExpr() const;
[[nodiscard]] QStringList getExprs() const;
[[nodiscard]] uint getNumberOfHits() const;
[[nodiscard]] bool isAutoPlay() const;
};
#endif // DLG_MOVE_TOP_CARDS_UNTIL_H

View file

@ -45,10 +45,10 @@ public:
QGraphicsItem *parent = nullptr,
QAction *_doubleClickAction = nullptr,
bool _highlightable = true);
QRectF boundingRect() const override;
[[nodiscard]] QRectF boundingRect() const override;
void setWidth(double _width);
void setActive(bool _active);
bool getActive() const
[[nodiscard]] bool getActive() const
{
return active;
}
@ -77,18 +77,18 @@ private:
public:
explicit PhasesToolbar(QGraphicsItem *parent = nullptr);
QRectF boundingRect() const override;
[[nodiscard]] QRectF boundingRect() const override;
void retranslateUi();
void setHeight(double _height);
double getWidth() const
[[nodiscard]] double getWidth() const
{
return width;
}
int phaseCount() const
[[nodiscard]] int phaseCount() const
{
return buttonList.size();
}
QString getLongPhaseName(int phase) const;
[[nodiscard]] QString getLongPhaseName(int phase) const;
public slots:
void setActivePhase(int phase);
void triggerPhaseAction(int phase);

View file

@ -49,15 +49,15 @@ public:
}
// expose useful actions/menus if PlayerMenu needs them
QMenu *revealLibrary() const
[[nodiscard]] QMenu *revealLibrary() const
{
return mRevealLibrary;
}
QMenu *lendLibraryMenu() const
[[nodiscard]] QMenu *lendLibraryMenu() const
{
return mLendLibrary;
}
QMenu *revealTopCardMenu() const
[[nodiscard]] QMenu *revealTopCardMenu() const
{
return mRevealTopCard;
}

View file

@ -61,7 +61,7 @@ public:
return utilityMenu;
}
bool getShortcutsActive() const
[[nodiscard]] bool getShortcutsActive() const
{
return shortcutsActive;
}

View file

@ -63,7 +63,7 @@ public:
void moveOneCardUntil(CardItem *card);
void stopMoveTopCardsUntil();
bool isMovingCardsUntil() const
[[nodiscard]] bool isMovingCardsUntil() const
{
return movingCardsUntil;
}

View file

@ -28,13 +28,13 @@ public:
{
Type = typeOther
};
int type() const override
[[nodiscard]] int type() const override
{
return Type;
}
explicit PlayerArea(QGraphicsItem *parent = nullptr);
QRectF boundingRect() const override
[[nodiscard]] QRectF boundingRect() const override
{
return bRect;
}
@ -43,7 +43,7 @@ public:
void setSize(qreal width, qreal height);
void setPlayerZoneId(int _playerZoneId);
int getPlayerZoneId() const
[[nodiscard]] int getPlayerZoneId() const
{
return playerZoneId;
}

View file

@ -27,39 +27,39 @@ public:
bool localPlayerIsSpectator;
QMap<int, ServerInfo_User> spectators;
bool isSpectator() const
[[nodiscard]] bool isSpectator() const
{
return localPlayerIsSpectator;
}
bool isJudge() const
[[nodiscard]] bool isJudge() const
{
return localPlayerIsJudge;
}
int getLocalPlayerId() const
[[nodiscard]] int getLocalPlayerId() const
{
return localPlayerId;
}
const QMap<int, Player *> &getPlayers() const
[[nodiscard]] const QMap<int, Player *> &getPlayers() const
{
return players;
}
int getPlayerCount() const
[[nodiscard]] int getPlayerCount() const
{
return players.size();
}
Player *getActiveLocalPlayer(int activePlayer) const;
[[nodiscard]] Player *getActiveLocalPlayer(int activePlayer) const;
bool isLocalPlayer(int playerId);
Player *addPlayer(int playerId, const ServerInfo_User &info);
void removePlayer(int playerId);
Player *getPlayer(int playerId) const;
[[nodiscard]] Player *getPlayer(int playerId) const;
void onPlayerConceded(int playerId, bool conceded);
@ -70,17 +70,17 @@ public:
return playerId == getLocalPlayerId();
}
const QMap<int, ServerInfo_User> &getSpectators() const
[[nodiscard]] const QMap<int, ServerInfo_User> &getSpectators() const
{
return spectators;
}
ServerInfo_User getSpectator(int playerId) const
[[nodiscard]] ServerInfo_User getSpectator(int playerId) const
{
return spectators.value(playerId);
}
QString getSpectatorName(int spectatorId) const
[[nodiscard]] QString getSpectatorName(int spectatorId) const
{
return QString::fromStdString(spectators.value(spectatorId).name());
}
@ -100,7 +100,7 @@ public:
emit spectatorRemoved(spectatorId, spectatorInfo);
}
AbstractGame *getGame() const
[[nodiscard]] AbstractGame *getGame() const
{
return game;
}

View file

@ -63,16 +63,16 @@ public:
{
cards.sortBy(options);
}
QString getName() const
[[nodiscard]] QString getName() const
{
return name;
}
QString getTranslatedName(bool theirOwn, GrammaticalCase gc) const;
Player *getPlayer() const
[[nodiscard]] QString getTranslatedName(bool theirOwn, GrammaticalCase gc) const;
[[nodiscard]] Player *getPlayer() const
{
return player;
}
bool contentsKnown() const
[[nodiscard]] bool contentsKnown() const
{
return cards.getContentsKnown();
}
@ -84,15 +84,15 @@ public:
{
alwaysRevealTopCard = _alwaysRevealTopCard;
}
bool getAlwaysRevealTopCard() const
[[nodiscard]] bool getAlwaysRevealTopCard() const
{
return alwaysRevealTopCard;
}
bool getHasCardAttr() const
[[nodiscard]] bool getHasCardAttr() const
{
return hasCardAttr;
}
bool getIsShufflable() const
[[nodiscard]] bool getIsShufflable() const
{
return isShufflable;
}

View file

@ -84,7 +84,7 @@ private:
*/
bool active = false;
bool isInverted() const;
[[nodiscard]] bool isInverted() const;
private slots:
/**
@ -110,7 +110,7 @@ public:
/**
@return a QRectF of the TableZone bounding box.
*/
QRectF boundingRect() const override;
[[nodiscard]] QRectF boundingRect() const override;
/**
Render the TableZone
@ -140,12 +140,12 @@ public:
/**
@return CardItem from grid location
*/
CardItem *getCardFromGrid(const QPoint &gridPoint) const;
[[nodiscard]] CardItem *getCardFromGrid(const QPoint &gridPoint) const;
/**
@return CardItem from coordinate location
*/
CardItem *getCardFromCoords(const QPointF &point) const;
[[nodiscard]] CardItem *getCardFromCoords(const QPointF &point) const;
QPointF closestGridPoint(const QPointF &point) override;
@ -157,7 +157,7 @@ public:
*/
void resizeToContents();
int getMinimumWidth() const
[[nodiscard]] int getMinimumWidth() const
{
return currentMinimumWidth;
}
@ -166,7 +166,7 @@ public:
prepareGeometryChange();
width = _width;
}
qreal getWidth() const
[[nodiscard]] qreal getWidth() const
{
return width;
}
@ -188,13 +188,13 @@ private:
/*
Mapping functions for points to/from gridpoints.
*/
QPointF mapFromGrid(QPoint gridPoint) const;
QPoint mapToGrid(const QPointF &mapPoint) const;
[[nodiscard]] QPointF mapFromGrid(QPoint gridPoint) const;
[[nodiscard]] QPoint mapToGrid(const QPointF &mapPoint) const;
/*
Helper function to create a single key from a card stack location.
*/
int getCardStackMapKey(int x, int y) const
[[nodiscard]] int getCardStackMapKey(int x, int y) const
{
return x + (y * 1000);
}

View file

@ -58,12 +58,12 @@ private:
public:
ZoneViewZone(ZoneViewZoneLogic *_logic, QGraphicsItem *parent);
QRectF boundingRect() const override;
[[nodiscard]] QRectF boundingRect() const override;
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override;
void reorganizeCards() override;
void initializeCards(const QList<const ServerInfo_Card *> &cardList = QList<const ServerInfo_Card *>());
void setGeometry(const QRectF &rect) override;
QRectF getOptimumRect() const
[[nodiscard]] QRectF getOptimumRect() const
{
return optimumRect;
}
@ -83,7 +83,7 @@ signals:
void wheelEventReceived(QGraphicsSceneWheelEvent *event);
protected:
QSizeF sizeHint(Qt::SizeHint which, const QSizeF &constraint = QSizeF()) const override;
[[nodiscard]] QSizeF sizeHint(Qt::SizeHint which, const QSizeF &constraint = QSizeF()) const override;
void wheelEvent(QGraphicsSceneWheelEvent *event) override;
};