mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-06-30 18:43:55 -07:00
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:
parent
7153f7d4c1
commit
aadee34238
173 changed files with 2725 additions and 1461 deletions
|
|
@ -143,12 +143,14 @@ bool DeckList::loadFromXml(QXmlStreamReader *xml)
|
|||
while (!xml->atEnd()) {
|
||||
xml->readNext();
|
||||
if (xml->isStartElement()) {
|
||||
if (xml->name().toString() != "cockatrice_deck")
|
||||
if (xml->name().toString() != "cockatrice_deck") {
|
||||
return false;
|
||||
}
|
||||
while (!xml->atEnd()) {
|
||||
xml->readNext();
|
||||
if (!readElement(xml))
|
||||
if (!readElement(xml)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -291,8 +293,9 @@ bool DeckList::loadFromStream_Plain(QTextStream &in,
|
|||
for (; index < max_line; ++index) {
|
||||
// check if line is a card
|
||||
match = reCardLine.match(inputs.at(index));
|
||||
if (!match.hasMatch())
|
||||
if (!match.hasMatch()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
QString cardName = match.captured().simplified();
|
||||
bool sideboard = false;
|
||||
|
|
@ -305,8 +308,9 @@ bool DeckList::loadFromStream_Plain(QTextStream &in,
|
|||
cardName = match.captured(1);
|
||||
}
|
||||
} else {
|
||||
if (index == sBStart)
|
||||
if (index == sBStart) {
|
||||
continue;
|
||||
}
|
||||
sideboard = index > sBStart;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -16,8 +16,9 @@ void DeckListHistoryManager::clear()
|
|||
|
||||
void DeckListHistoryManager::undo(DeckList *deck)
|
||||
{
|
||||
if (undoStack.isEmpty())
|
||||
if (undoStack.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Peek at the memento we are going to restore
|
||||
const DeckListMemento &mementoToRestore = undoStack.top();
|
||||
|
|
@ -35,8 +36,9 @@ void DeckListHistoryManager::undo(DeckList *deck)
|
|||
|
||||
void DeckListHistoryManager::redo(DeckList *deck)
|
||||
{
|
||||
if (redoStack.isEmpty())
|
||||
if (redoStack.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Peek at the memento we are going to restore
|
||||
const DeckListMemento &mementoToRestore = redoStack.top();
|
||||
|
|
|
|||
|
|
@ -58,8 +58,9 @@ QList<const InnerDecklistNode *> DecklistNodeTree::getZoneNodes(const QSet<QStri
|
|||
QList<const InnerDecklistNode *> zones;
|
||||
for (auto *node : *root) {
|
||||
InnerDecklistNode *currentZone = dynamic_cast<InnerDecklistNode *>(node);
|
||||
if (!currentZone)
|
||||
if (!currentZone) {
|
||||
continue;
|
||||
}
|
||||
if (!restrictToZones.isEmpty() && !restrictToZones.contains(currentZone->getName())) {
|
||||
continue;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,28 +18,30 @@ bool SideboardPlan::readElement(QXmlStreamReader *xml)
|
|||
xml->readNext();
|
||||
const QString childName = xml->name().toString();
|
||||
if (xml->isStartElement()) {
|
||||
if (childName == "name")
|
||||
if (childName == "name") {
|
||||
name = xml->readElementText();
|
||||
else if (childName == "move_card_to_zone") {
|
||||
} else if (childName == "move_card_to_zone") {
|
||||
MoveCard_ToZone m;
|
||||
while (!xml->atEnd()) {
|
||||
xml->readNext();
|
||||
const QString childName2 = xml->name().toString();
|
||||
if (xml->isStartElement()) {
|
||||
if (childName2 == "card_name")
|
||||
if (childName2 == "card_name") {
|
||||
m.set_card_name(xml->readElementText().toStdString());
|
||||
else if (childName2 == "start_zone")
|
||||
} else if (childName2 == "start_zone") {
|
||||
m.set_start_zone(xml->readElementText().toStdString());
|
||||
else if (childName2 == "target_zone")
|
||||
} else if (childName2 == "target_zone") {
|
||||
m.set_target_zone(xml->readElementText().toStdString());
|
||||
}
|
||||
} else if (xml->isEndElement() && (childName2 == "move_card_to_zone")) {
|
||||
moveList.append(m);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (xml->isEndElement() && (childName == "sideboard_plan"))
|
||||
} else if (xml->isEndElement() && (childName == "sideboard_plan")) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,8 +38,9 @@ bool AbstractDecklistCardNode::readElement(QXmlStreamReader *xml)
|
|||
{
|
||||
while (!xml->atEnd()) {
|
||||
xml->readNext();
|
||||
if (xml->isEndElement() && xml->name().toString() == "card")
|
||||
if (xml->isEndElement() && xml->name().toString() == "card") {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -48,8 +48,9 @@ QString InnerDecklistNode::getVisibleName() const
|
|||
|
||||
void InnerDecklistNode::clearTree()
|
||||
{
|
||||
for (int i = 0; i < size(); i++)
|
||||
for (int i = 0; i < size(); i++) {
|
||||
delete at(i);
|
||||
}
|
||||
clear();
|
||||
}
|
||||
|
||||
|
|
@ -154,8 +155,9 @@ bool InnerDecklistNode::readElement(QXmlStreamReader *xml)
|
|||
xml->attributes().value("collectorNumber").toString(), xml->attributes().value("uuid").toString());
|
||||
newCard->readElement(xml);
|
||||
}
|
||||
} else if (xml->isEndElement() && (childName == "zone"))
|
||||
} else if (xml->isEndElement() && (childName == "zone")) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
@ -164,8 +166,9 @@ void InnerDecklistNode::writeElement(QXmlStreamWriter *xml)
|
|||
{
|
||||
xml->writeStartElement("zone");
|
||||
xml->writeAttribute("name", name);
|
||||
for (int i = 0; i < size(); i++)
|
||||
for (int i = 0; i < size(); i++) {
|
||||
at(i)->writeElement(xml);
|
||||
}
|
||||
xml->writeEndElement(); // zone
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue