Skip to content

Commit

Permalink
Merge pull request #16 from CESNET/clang-tidy
Browse files Browse the repository at this point in the history
clang-tidy - update clang tidy configuration
  • Loading branch information
SiskaPavel authored Oct 4, 2024
2 parents 0c9304a + e721bfa commit f4224bc
Show file tree
Hide file tree
Showing 9 changed files with 30 additions and 15 deletions.
5 changes: 4 additions & 1 deletion .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Checks: '
-*,
bugprone-*,
-bugprone-easily-swappable-parameters,
clang-analyzer-*,
misc-*,
-misc-no-recursion,
Expand All @@ -22,7 +23,7 @@ WarningsAsErrors: '*'

CheckOptions:
- key: readability-identifier-naming.NamespaceCase
value: 'CamelCase'
value: 'camelBack'
- key: readability-identifier-naming.StructCase
value: 'CamelCase'
- key: readability-identifier-naming.FunctionCase
Expand All @@ -45,6 +46,8 @@ CheckOptions:
value: 'camelBack'
- key: readability-identifier-naming.PrivateMemberPrefix
value: 'm_'
- key: readability-identifier-naming.ProtectedMemberPrefix
value: 'm_'
- key: readability-identifier-naming.ConstantMemberCase
value: 'UPPER_CASE'
- key: readability-identifier-naming.EnumConstantCase
Expand Down
10 changes: 7 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@ ifeq ($(RUN_CLANG_TIDY),)
RUN_CLANG_TIDY := run-clang-tidy
endif

SOURCE_DIR = src/ include/
SRC_DIR = "$(shell pwd)/src"
INC_DIR = "$(shell pwd)/include"

HEADE_FILTER = "$(SRC_DIR)|$(INC_DIR)"
SOURCE_DIR = "$(SRC_DIR)" "$(INC_DIR)"
SOURCE_REGEX = '.*\.\(cpp\|hpp\)'

.PHONY: all
Expand All @@ -40,11 +44,11 @@ format-fix:

.PHONY: tidy
tidy: all
$(RUN_CLANG_TIDY) -p build -quiet -j $(shell nproc) $(SOURCE_DIR)
$(RUN_CLANG_TIDY) -p build -quiet -j $(shell nproc) -header-filter=$(HEADE_FILTER) $(SOURCE_DIR)

.PHONY: tidy-fix
tidy-fix: all
$(RUN_CLANG_TIDY) -p build -quiet -fix -j $(shell nproc) $(SOURCE_DIR)
$(RUN_CLANG_TIDY) -p build -quiet -fix -j $(shell nproc) -header-filter=$(HEADE_FILTER) $(SOURCE_DIR)

.PHONY: test
test: build
Expand Down
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 f4224bc

Please sign in to comment.