MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / validateGroups

Function validateGroups

app/src/API/Handlers/ProjectHandler.cpp:5752–5781  ·  view source on GitHub ↗

* @brief Validates each group and its datasets against the source-id set. */

Source from the content-addressed store, hash-verified

5750 * @brief Validates each group and its datasets against the source-id set.
5751 */
5752static void validateGroups(const std::vector<DataModel::Group>& groups,
5753 const QSet<int>& sourceIds,
5754 QJsonArray& issues,
5755 bool& ok)
5756{
5757 for (const auto& g : groups) {
5758 const QString gloc = QStringLiteral("group[%1]").arg(g.groupId);
5759
5760 if (g.title.trimmed().isEmpty())
5761 addIssue(issues, QStringLiteral("warning"), gloc, QStringLiteral("Group has no title"));
5762
5763 if (g.datasets.empty())
5764 addIssue(issues,
5765 QStringLiteral("warning"),
5766 gloc,
5767 QStringLiteral("Group has no datasets; nothing to display"));
5768
5769 if (!sourceIds.contains(g.sourceId)) {
5770 ok = false;
5771 addIssue(issues,
5772 QStringLiteral("error"),
5773 gloc,
5774 QStringLiteral("Group references missing source id %1").arg(g.sourceId));
5775 }
5776
5777 QSet<int> datasetIndexes;
5778 for (const auto& d : g.datasets)
5779 validateDataset(d, g, sourceIds, datasetIndexes, issues, ok);
5780 }
5781}
5782
5783/**
5784 * @brief Validates actions (non-blocking sanity checks: titles, payloads).

Callers 1

validateMethod · 0.85

Calls 5

addIssueFunction · 0.85
validateDatasetFunction · 0.85
isEmptyMethod · 0.80
emptyMethod · 0.80
containsMethod · 0.45

Tested by

no test coverage detected