Skip to content

Commit

Permalink
style: clang-tidy auto fixes (#1659)
Browse files Browse the repository at this point in the history
Fixes #1658. Please review and commit clang-tidy fixes.

Co-authored-by: kuznetsss <[email protected]>
  • Loading branch information
github-actions[bot] and kuznetsss committed Sep 25, 2024
1 parent 4185113 commit 3f791c1
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 26 deletions.
2 changes: 0 additions & 2 deletions src/util/newconfig/ConfigConstraints.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@
#include "util/newconfig/Error.hpp"
#include "util/newconfig/Types.hpp"

#include <fmt/core.h>

#include <cstdint>
#include <optional>
#include <regex>
Expand Down
27 changes: 11 additions & 16 deletions src/util/newconfig/ConfigConstraints.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ class Constraint {
// see here for more info:
// https://stackoverflow.com/questions/72835571/constexpr-c-error-destructor-used-before-its-definition
// https://godbolt.org/z/eMdWThaMY
constexpr virtual ~Constraint() noexcept {};
constexpr virtual ~Constraint() noexcept = default;

/**
* @brief Check if the value meets the specific constraint.
Expand Down Expand Up @@ -155,9 +155,8 @@ class Constraint {
*/
class PortConstraint final : public Constraint {
public:
constexpr ~PortConstraint()
{
}
constexpr ~PortConstraint() override
= default;

private:
/**
Expand Down Expand Up @@ -187,9 +186,8 @@ class PortConstraint final : public Constraint {
*/
class ValidIPConstraint final : public Constraint {
public:
constexpr ~ValidIPConstraint()
{
}
constexpr ~ValidIPConstraint() override
= default;

private:
/**
Expand Down Expand Up @@ -229,9 +227,8 @@ class OneOf final : public Constraint {
{
}

constexpr ~OneOf()
{
}
constexpr ~OneOf() override
= default;

private:
/**
Expand Down Expand Up @@ -285,9 +282,8 @@ class NumberValueConstraint final : public Constraint {
{
}

constexpr ~NumberValueConstraint()
{
}
constexpr ~NumberValueConstraint() override
= default;

private:
/**
Expand Down Expand Up @@ -328,9 +324,8 @@ class NumberValueConstraint final : public Constraint {
*/
class PositiveDouble final : public Constraint {
public:
constexpr ~PositiveDouble()
{
}
constexpr ~PositiveDouble() override
= default;

private:
/**
Expand Down
4 changes: 2 additions & 2 deletions src/util/newconfig/ConfigFileJson.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,15 +133,15 @@ void
ConfigFileJson::flattenJson(boost::json::object const& obj, std::string const& prefix)
{
for (auto const& [key, value] : obj) {
std::string fullKey = prefix.empty() ? std::string(key) : fmt::format("{}.{}", prefix, std::string(key));
std::string const fullKey = prefix.empty() ? std::string(key) : fmt::format("{}.{}", prefix, std::string(key));

// In ClioConfigDefinition, value must be a primitive or array
if (value.is_object()) {
flattenJson(value.as_object(), fullKey);
} else if (value.is_array()) {
auto const& arr = value.as_array();
for (std::size_t i = 0; i < arr.size(); ++i) {
std::string arrayPrefix = fullKey + ".[]";
std::string const arrayPrefix = fullKey + ".[]";
if (arr[i].is_object()) {
flattenJson(arr[i].as_object(), arrayPrefix);
} else {
Expand Down
6 changes: 3 additions & 3 deletions tests/unit/util/newconfig/ArrayTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,19 +47,19 @@ TEST(ArrayTest, addAndCheckMultipleValues)
EXPECT_EQ(arr.size(), 3);

auto const cv = arr.at(0);
ValueView vv{cv};
ValueView const vv{cv};
EXPECT_EQ(vv.asDouble(), 111.11);

auto const cv2 = arr.at(1);
ValueView vv2{cv2};
ValueView const vv2{cv2};
EXPECT_EQ(vv2.asDouble(), 222.22);

EXPECT_EQ(arr.size(), 3);
arr.addValue(444.44);

EXPECT_EQ(arr.size(), 4);
auto const cv4 = arr.at(3);
ValueView vv4{cv4};
ValueView const vv4{cv4};
EXPECT_EQ(vv4.asDouble(), 444.44);
}

Expand Down
4 changes: 1 addition & 3 deletions tests/unit/util/newconfig/ClioConfigDefinitionTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,9 @@
#include "util/newconfig/Types.hpp"
#include "util/newconfig/ValueView.hpp"

#include <boost/filesystem/operations.hpp>
#include <boost/json/object.hpp>
#include <boost/json/parse.hpp>
#include <boost/json/value.hpp>
#include <boost/json/value_to.hpp>
#include <gtest/gtest.h>

#include <algorithm>
Expand Down Expand Up @@ -287,7 +285,7 @@ TEST_F(IncorrectOverrideValues, InvalidJsonErrors)
EXPECT_TRUE(errors.has_value());

// Expected error messages
std::unordered_set<std::string_view> expectedErrors{
std::unordered_set<std::string_view> const expectedErrors{
"dosguard.whitelist.[] value does not match type string",
"higher.[].low.section key is required in user Config",
"higher.[].low.admin key is required in user Config",
Expand Down

0 comments on commit 3f791c1

Please sign in to comment.