Skip to content

Commit

Permalink
telemetry - fix clang-tidy warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
SiskaPavel committed Oct 3, 2024
1 parent 1da5265 commit e721bfa
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 11 deletions.
2 changes: 1 addition & 1 deletion include/telemetry/aggFile.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class AggregatedFile : public File {

FileOps getOps();

const std::string m_filesRegexPattern;
const std::string M_FILES_REGEX_PATTERN;

std::shared_ptr<Directory> m_patternRootDir;
std::vector<std::string> m_paths;
Expand Down
5 changes: 5 additions & 0 deletions include/telemetry/aggMethod.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ enum class AggMethodType { AVG, SUM, JOIN };
*/
struct AggOperation {
AggMethodType method; ///< Aggregation method
// NOLINTNEXTLINE(readability-redundant-string-init)
std::string dictFieldName = ""; ///< Name of the field in the dictionary
// NOLINTNEXTLINE(readability-redundant-string-init)
std::string dictResultName = ""; ///< Name of the field in the aggregated dictionary
};

Expand Down Expand Up @@ -78,6 +80,9 @@ class AggMethod {
protected:
AggContent getAggContent(const Content& content, bool useDictResultName = false);

[[nodiscard]] std::string getDictResultName() const { return m_dictResultname; }

private:
std::string m_dictFieldName;
std::string m_dictResultname;
};
Expand Down
4 changes: 3 additions & 1 deletion include/telemetry/node.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,11 @@ class Node : public std::enable_shared_from_this<Node> {
std::string getFullPath();

protected:
std::shared_ptr<Node> m_parent;
std::shared_ptr<Node> getParent() { return m_parent; };

private:
std::shared_ptr<Node> m_parent;

std::mutex m_mutex;
std::string m_name;

Expand Down
6 changes: 3 additions & 3 deletions src/telemetry/aggFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,10 @@ Content AggregatedFile::read()
if (m_patternRootDir) {
patternRootDir = m_patternRootDir;
} else {
patternRootDir = std::dynamic_pointer_cast<Directory>(m_parent);
patternRootDir = std::dynamic_pointer_cast<Directory>(getParent());
}

const auto files = getFilesMatchingPattern(m_filesRegexPattern, patternRootDir);
const auto files = getFilesMatchingPattern(M_FILES_REGEX_PATTERN, patternRootDir);
if (files.empty()) {
return content;
}
Expand Down Expand Up @@ -159,7 +159,7 @@ AggregatedFile::AggregatedFile(
const std::vector<AggOperation>& ops,
std::shared_ptr<Directory> patternRootDir)
: File(parent, name, getOps())
, m_filesRegexPattern(std::move(aggFilesPattern))
, M_FILES_REGEX_PATTERN(std::move(aggFilesPattern))
, m_patternRootDir(std::move(patternRootDir))
{
validateAggOperations(ops);
Expand Down
6 changes: 3 additions & 3 deletions src/telemetry/aggregator/aggCommon.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ static ScalarWithUnit getReferenceVariant(const std::vector<AggContent>& values)

if (std::holds_alternative<Array>(values.front())) {
for (const auto& value : values) {
const Array& array = std::get<Array>(value);
const auto& array = std::get<Array>(value);
if (!array.empty()) {
return {array.front(), ""};
}
Expand Down Expand Up @@ -102,7 +102,7 @@ static bool containsSameScalarAlternative(const std::vector<AggContent>& values)
return false;
}

size_t refIndex = refScalar.index();
const size_t refIndex = refScalar.index();

for (const auto& value : values) {
if (std::holds_alternative<Scalar>(value)) {
Expand All @@ -119,7 +119,7 @@ static bool containsSameScalarAlternative(const std::vector<AggContent>& values)
return false;
}
} else if (std::holds_alternative<Array>(value)) {
const Array& array = std::get<Array>(value);
const auto& array = std::get<Array>(value);
if (std::any_of(array.begin(), array.end(), [&](const auto& scalar) {
return scalar.index() != refIndex;
})) {
Expand Down
2 changes: 1 addition & 1 deletion src/telemetry/aggregator/aggJoin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ Content AggMethodJoin::aggregate(const std::vector<Content>& contents)
}

const auto& result = aggregateGatheredValues(values);
return createContent(m_dictResultname, result);
return createContent(getDictResultName(), result);
}

} // namespace telemetry
Expand Down
5 changes: 3 additions & 2 deletions src/telemetry/aggregator/aggSum.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,9 @@ static Content createDictContent(const std::string& dictKey, const ResultType& r

Content AggMethodSum::createContent(const ResultType& result)
{
if (!m_dictResultname.empty()) {
return createDictContent(m_dictResultname, result);
const auto dictResultName = getDictResultName();
if (!dictResultName.empty()) {
return createDictContent(dictResultName, result);
}

auto visitor = [&](const auto& arg) -> Content { return arg; };
Expand Down

0 comments on commit e721bfa

Please sign in to comment.