Skip to content

Commit

Permalink
Cleanup: move return statement to new line + trailing
Browse files Browse the repository at this point in the history
Follow-up to FreeCAD#6497
  • Loading branch information
luzpaz committed Dec 6, 2022
1 parent d08ccbf commit 7ed8b53
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 22 deletions.
36 changes: 24 additions & 12 deletions src/App/Metadata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,8 @@ DOMElement *appendSimpleXMLNode(DOMElement *baseNode, const std::string &nodeNam
const std::string &nodeContents)
{
// For convenience (and brevity of final output) don't create nodes that don't have contents
if (nodeContents.empty()) return nullptr;
if (nodeContents.empty())
return nullptr;

auto doc = baseNode->getOwnerDocument();
DOMElement *namedElement = doc->createElement(XUTF8Str(nodeName.c_str()).unicodeForm());
Expand All @@ -352,7 +353,8 @@ DOMElement *appendSimpleXMLNode(DOMElement *baseNode, const std::string &nodeNam

void addAttribute(DOMElement *node, const std::string &key, const std::string &value)
{
if (value.empty()) return;
if (value.empty())
return;

node->setAttribute(XUTF8Str(key.c_str()).unicodeForm(), XUTF8Str(value.c_str()).unicodeForm());
}
Expand Down Expand Up @@ -449,7 +451,8 @@ void Metadata::write(const fs::path &file) const

bool Metadata::satisfies(const Meta::Dependency &dep)
{
if (dep.package != _name) return false;
if (dep.package != _name)
return false;

// The "condition" attribute allows an expression to enable or disable this dependency check: it must contain a valid
// FreeCAD Expression. If it evaluates to false, this dependency is bypassed (e.g. this function returns false).
Expand All @@ -470,24 +473,30 @@ bool Metadata::satisfies(const Meta::Dependency &dep)
}
auto parsedExpression = App::Expression::parse(nullptr, dep.condition);
auto result = parsedExpression->eval();
if (!boost::any_cast<bool>(result->getValueAsAny())) return false;
if (!boost::any_cast<bool>(result->getValueAsAny()))
return false;
}

if (!dep.version_eq.empty()) return _version == Meta::Version(dep.version_eq);
if (!dep.version_eq.empty())
return _version == Meta::Version(dep.version_eq);

// Any of the others might be specified in pairs, so only return the "false" case

if (!dep.version_lt.empty())
if (!(_version < Meta::Version(dep.version_lt))) return false;
if (!(_version < Meta::Version(dep.version_lt)))
return false;

if (!dep.version_lte.empty())
if (!(_version <= Meta::Version(dep.version_lt))) return false;
if (!(_version <= Meta::Version(dep.version_lt)))
return false;

if (!dep.version_gt.empty())
if (!(_version > Meta::Version(dep.version_lt))) return false;
if (!(_version > Meta::Version(dep.version_lt)))
return false;

if (!dep.version_gte.empty())
if (!(_version >= Meta::Version(dep.version_lt))) return false;
if (!(_version >= Meta::Version(dep.version_lt)))
return false;

return true;
}
Expand All @@ -505,7 +514,8 @@ bool Metadata::supportsCurrentFreeCAD() const
fcVersion = Meta::Version(ss.str());
}

if (_freecadmin != Meta::Version() && _freecadmin > fcVersion) return false;
if (_freecadmin != Meta::Version() && _freecadmin > fcVersion)
return false;
else if (_freecadmax != Meta::Version() && _freecadmax < fcVersion)
return false;
return true;
Expand Down Expand Up @@ -739,7 +749,8 @@ Meta::Url::Url(const XERCES_CPP_NAMESPACE::DOMElement *e)

bool App::Meta::Url::operator==(const Url &rhs) const
{
if (type == UrlType::repository && branch != rhs.branch) return false;
if (type == UrlType::repository && branch != rhs.branch)
return false;
return type == rhs.type && location == rhs.location;
}

Expand Down Expand Up @@ -810,7 +821,8 @@ Meta::Version::Version(const std::string &versionString) : minor(0), patch(0)

std::string Meta::Version::str() const
{
if (*this == Meta::Version()) return "";
if (*this == Meta::Version())
return "";
std::ostringstream stream;
stream << major << "." << minor << "." << patch << suffix;
return stream.str();
Expand Down
15 changes: 8 additions & 7 deletions src/Gui/DlgGeneralImp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ void DlgGeneralImp::recreatePreferencePackMenu()
ui->PreferencePacks->horizontalHeader()->setSectionResizeMode(1, QHeaderView::ResizeMode::Stretch);
ui->PreferencePacks->horizontalHeader()->setSectionResizeMode(2, QHeaderView::ResizeMode::ResizeToContents);
QStringList columnHeaders;
columnHeaders << tr("Preference Pack Name")
columnHeaders << tr("Preference Pack Name")
<< tr("Tags")
<< QString(); // for the "Load" buttons
ui->PreferencePacks->setHorizontalHeaderLabels(columnHeaders);
Expand Down Expand Up @@ -440,7 +440,7 @@ void DlgGeneralImp::revertToSavedConfig()
revertToBackupConfigDialog->open();
}

void DlgGeneralImp::newPreferencePackDialogAccepted()
void DlgGeneralImp::newPreferencePackDialogAccepted()
{
auto preferencePackTemplates = Application::Instance->prefPackManager()->templateFiles();
auto selection = newPreferencePackDialog->selectedTemplates();
Expand Down Expand Up @@ -468,11 +468,11 @@ void DlgGeneralImp::onManagePreferencePacksClicked()
this->preferencePackManagementDialog->show();
}

void DlgGeneralImp::onImportConfigClicked()
void DlgGeneralImp::onImportConfigClicked()
{
auto path = fs::path(QFileDialog::getOpenFileName(this,
tr("Choose a FreeCAD config file to import"),
QString(),
auto path = fs::path(QFileDialog::getOpenFileName(this,
tr("Choose a FreeCAD config file to import"),
QString(),
QString::fromUtf8("*.cfg")).toStdString());
if (!path.empty()) {
// Create a name from the filename:
Expand All @@ -484,7 +484,8 @@ void DlgGeneralImp::onImportConfigClicked()
auto result = QMessageBox::question(
this, tr("File exists"),
tr("A preference pack with that name already exists. Overwrite?"));
if (result == QMessageBox::No) return; // Maybe someday ask for a new name?
if (result == QMessageBox::No) // Maybe someday ask for a new name?
return;
}
Application::Instance->prefPackManager()->importConfig(packName, path);
recreatePreferencePackMenu();
Expand Down
4 changes: 3 additions & 1 deletion src/Gui/PythonWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,9 @@ class WrapperManager : public QObject
}

auto& pylist = wrappers[obj];
if (std::find_if(pylist.cbegin(), pylist.cend(), [pyobj](const Py::Object& py) { return py.ptr() == pyobj; }) == pylist.end()) {
if (std::find_if(pylist.cbegin(), pylist.cend(), [pyobj](const Py::Object& py) {
return py.ptr() == pyobj;
}) == pylist.end()) {
pylist.emplace_back(pyobj);
}
}
Expand Down
4 changes: 3 additions & 1 deletion src/Mod/Sketcher/Gui/TaskSketcherElements.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -723,7 +723,9 @@ void TaskSketcherElements::setItemVisibility(QListWidgetItem* it)
{
ElementItem* item = static_cast<ElementItem*>(it);

if (ui->filterBox->checkState() == Qt::Unchecked) { item->setHidden(false); return; }
if (ui->filterBox->checkState() == Qt::Unchecked) { item->setHidden(false);
return;
}

using GeometryState = ElementItem::GeometryState;

Expand Down
3 changes: 2 additions & 1 deletion src/Mod/TechDraw/Gui/TaskComplexSection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -761,7 +761,8 @@ bool TaskComplexSection::reject()
Gui::Command::updateActive();
Gui::Command::doCommand(Gui::Command::Gui, "Gui.ActiveDocument.resetEdit()");

return false;}
return false;
}

void TaskComplexSection::changeEvent(QEvent* event)
{
Expand Down

0 comments on commit 7ed8b53

Please sign in to comment.