style: Add braces to all control flow statements (#6887)

* style: Add braces to all control flow statements

  Standardize code style by adding explicit braces to all single-statement
  control flow blocks (if, else, for, while) across the entire codebase.

  Also documents the InsertBraces clang-format option (requires v15+) for
  future automated enforcement.

* InsertBraces-check-enabled
This commit is contained in:
DawnFire42 2026-05-16 13:19:53 -04:00 committed by GitHub
parent 7153f7d4c1
commit aadee34238
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
173 changed files with 2725 additions and 1461 deletions

View file

@ -103,9 +103,11 @@ void CardDatabase::addCard(CardInfoPtr card)
// If a card already exists, just add the new set property.
if (auto existing = cards.value(name)) {
for (const auto &printings : card->getSets())
for (const auto &printing : printings)
for (const auto &printings : card->getSets()) {
for (const auto &printing : printings) {
existing->addToSet(printing.getSet(), printing);
}
}
return;
}
@ -123,14 +125,17 @@ void CardDatabase::removeCard(CardInfoPtr card)
return;
}
for (auto *cardRelation : card->getRelatedCards())
for (auto *cardRelation : card->getRelatedCards()) {
cardRelation->deleteLater();
}
for (auto *cardRelation : card->getReverseRelatedCards())
for (auto *cardRelation : card->getReverseRelatedCards()) {
cardRelation->deleteLater();
}
for (auto *cardRelation : card->getReverseRelatedCards2Me())
for (auto *cardRelation : card->getReverseRelatedCards2Me()) {
cardRelation->deleteLater();
}
QMutexLocker locker(removeCardMutex);
cards.remove(card->getName());

View file

@ -125,8 +125,9 @@ QStringList CardDatabaseLoader::collectCustomDatabasePaths() const
QDirIterator::Subdirectories | QDirIterator::FollowSymlinks);
QStringList paths;
while (it.hasNext())
while (it.hasNext()) {
paths << it.next();
}
paths.sort();
return paths;
}

View file

@ -36,8 +36,9 @@ QList<CardInfoPtr> CardDatabaseQuerier::getCardInfos(const QStringList &cardName
QList<CardInfoPtr> cardInfos;
for (const QString &cardName : cardNames) {
CardInfoPtr ptr = db->cards.value(cardName);
if (ptr)
if (ptr) {
cardInfos.append(ptr);
}
}
return cardInfos;
@ -50,10 +51,12 @@ CardInfoPtr CardDatabaseQuerier::getCardBySimpleName(const QString &cardName) co
CardInfoPtr CardDatabaseQuerier::lookupCardByName(const QString &name) const
{
if (auto info = getCardInfo(name))
if (auto info = getCardInfo(name)) {
return info;
if (auto info = getCardBySimpleName(name))
}
if (auto info = getCardBySimpleName(name)) {
return info;
}
return getCardBySimpleName(CardInfo::simplifyName(name));
}
@ -71,8 +74,9 @@ QList<ExactCard> CardDatabaseQuerier::getCards(const QList<CardRef> &cardRefs) c
QList<ExactCard> cards;
for (const auto &cardRef : cardRefs) {
ExactCard card = getCard(cardRef);
if (card)
if (card) {
cards.append(card);
}
}
return cards;
@ -119,8 +123,9 @@ ExactCard CardDatabaseQuerier::guessCard(const CardRef &cardRef) const
ExactCard CardDatabaseQuerier::getRandomCard() const
{
if (db->cards.isEmpty())
if (db->cards.isEmpty()) {
return {};
}
const auto keys = db->cards.keys();
int randomIndex = QRandomGenerator::global()->bounded(keys.size());

View file

@ -306,8 +306,9 @@ void CockatriceXml4Parser::loadCardsFromXml(QXmlStreamReader &xml)
PrintingInfo printingInfo(set);
for (QXmlStreamAttribute attr : attrs) {
QString attrName = attr.name().toString();
if (attrName == "picURL")
if (attrName == "picURL") {
attrName = "picurl";
}
printingInfo.setProperty(attrName, attr.value().toString());
}

View file

@ -51,16 +51,21 @@ enum class CardMatchType
// convert string to enum
inline CardMatchType matchTypeFromString(const QString &str)
{
if (str == "equals")
if (str == "equals") {
return CardMatchType::Equals;
if (str == "notEquals")
}
if (str == "notEquals") {
return CardMatchType::NotEquals;
if (str == "contains")
}
if (str == "contains") {
return CardMatchType::Contains;
if (str == "notContains")
}
if (str == "notContains") {
return CardMatchType::NotContains;
if (str == "regex")
}
if (str == "regex") {
return CardMatchType::Regex;
}
return CardMatchType::Equals; // fallback default
}

View file

@ -31,26 +31,36 @@ QString const ColorIdentity("coloridentity");
inline static const QString getNicePropertyName(QString key)
{
if (key == CardType)
if (key == CardType) {
return QCoreApplication::translate("Mtg", "Card Type");
if (key == ConvertedManaCost)
}
if (key == ConvertedManaCost) {
return QCoreApplication::translate("Mtg", "Mana Value");
if (key == Colors)
}
if (key == Colors) {
return QCoreApplication::translate("Mtg", "Color(s)");
if (key == Loyalty)
}
if (key == Loyalty) {
return QCoreApplication::translate("Mtg", "Loyalty");
if (key == MainCardType)
}
if (key == MainCardType) {
return QCoreApplication::translate("Mtg", "Main Card Type");
if (key == ManaCost)
}
if (key == ManaCost) {
return QCoreApplication::translate("Mtg", "Mana Cost");
if (key == PowTough)
}
if (key == PowTough) {
return QCoreApplication::translate("Mtg", "P/T");
if (key == Side)
}
if (key == Side) {
return QCoreApplication::translate("Mtg", "Side");
if (key == Layout)
}
if (key == Layout) {
return QCoreApplication::translate("Mtg", "Layout");
if (key == ColorIdentity)
}
if (key == ColorIdentity) {
return QCoreApplication::translate("Mtg", "Color Identity");
}
return key;
}
} // namespace Mtg

View file

@ -33,28 +33,9 @@ QString CardSet::getCorrectedShortName() const
{
// For Windows machines.
QSet<QString> invalidFileNames;
invalidFileNames << "CON"
<< "PRN"
<< "AUX"
<< "NUL"
<< "COM1"
<< "COM2"
<< "COM3"
<< "COM4"
<< "COM5"
<< "COM6"
<< "COM7"
<< "COM8"
<< "COM9"
<< "LPT1"
<< "LPT2"
<< "LPT3"
<< "LPT4"
<< "LPT5"
<< "LPT6"
<< "LPT7"
<< "LPT8"
<< "LPT9";
invalidFileNames << "CON" << "PRN" << "AUX" << "NUL" << "COM1" << "COM2" << "COM3" << "COM4" << "COM5" << "COM6"
<< "COM7" << "COM8" << "COM9" << "LPT1" << "LPT2" << "LPT3" << "LPT4" << "LPT5" << "LPT6" << "LPT7"
<< "LPT8" << "LPT9";
return invalidFileNames.contains(shortName) ? shortName + "_" : shortName;
}