From 7d1b4600b68595085a949743331c2e5673f511ea Mon Sep 17 00:00:00 2001 From: pantor Date: Sat, 18 Oct 2025 07:00:03 -0700 Subject: [PATCH] fix more clang-tidy warnings --- include/inja/renderer.hpp | 6 +++--- include/inja/statistics.hpp | 4 ++-- single_include/inja/inja.hpp | 10 +++++----- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/include/inja/renderer.hpp b/include/inja/renderer.hpp index a546664..e135158 100644 --- a/include/inja/renderer.hpp +++ b/include/inja/renderer.hpp @@ -350,7 +350,7 @@ class Renderer : public NodeVisitor { } break; case Op::Default: { const auto test_arg = get_arguments<1, 0, false>(node)[0]; - data_eval_stack.push(test_arg ? test_arg : get_arguments<1, 1>(node)[0]); + data_eval_stack.push((test_arg != nullptr) ? test_arg : get_arguments<1, 1>(node)[0]); } break; case Op::DivisibleBy: { const auto args = get_arguments<2>(node); @@ -425,7 +425,7 @@ class Renderer : public NodeVisitor { const auto precision = args[1]->get(); const double result = std::round(args[0]->get() * std::pow(10.0, precision)) / std::pow(10.0, precision); if (precision == 0) { - make_result(int(result)); + make_result(static_cast(result)); } else { make_result(result); } @@ -557,7 +557,7 @@ class Renderer : public NodeVisitor { additional_data[static_cast(node.value)].clear(); if (!(*current_loop_data)["parent"].empty()) { const auto tmp = (*current_loop_data)["parent"]; - *current_loop_data = std::move(tmp); + *current_loop_data = tmp; } else { current_loop_data = &additional_data["loop"]; } diff --git a/include/inja/statistics.hpp b/include/inja/statistics.hpp index 3405080..dbee265 100644 --- a/include/inja/statistics.hpp +++ b/include/inja/statistics.hpp @@ -63,9 +63,9 @@ class StatisticsVisitor : public NodeVisitor { void visit(const SetStatementNode&) override {} public: - size_t variable_counter; + size_t variable_counter {0}; - explicit StatisticsVisitor(): variable_counter(0) {} + explicit StatisticsVisitor() {} }; } // namespace inja diff --git a/single_include/inja/inja.hpp b/single_include/inja/inja.hpp index 1e85cf2..db597fa 100644 --- a/single_include/inja/inja.hpp +++ b/single_include/inja/inja.hpp @@ -807,9 +807,9 @@ class StatisticsVisitor : public NodeVisitor { void visit(const SetStatementNode&) override {} public: - size_t variable_counter; + size_t variable_counter {0}; - explicit StatisticsVisitor(): variable_counter(0) {} + explicit StatisticsVisitor() {} }; } // namespace inja @@ -2503,7 +2503,7 @@ class Renderer : public NodeVisitor { } break; case Op::Default: { const auto test_arg = get_arguments<1, 0, false>(node)[0]; - data_eval_stack.push(test_arg ? test_arg : get_arguments<1, 1>(node)[0]); + data_eval_stack.push((test_arg != nullptr) ? test_arg : get_arguments<1, 1>(node)[0]); } break; case Op::DivisibleBy: { const auto args = get_arguments<2>(node); @@ -2578,7 +2578,7 @@ class Renderer : public NodeVisitor { const auto precision = args[1]->get(); const double result = std::round(args[0]->get() * std::pow(10.0, precision)) / std::pow(10.0, precision); if (precision == 0) { - make_result(int(result)); + make_result(static_cast(result)); } else { make_result(result); } @@ -2710,7 +2710,7 @@ class Renderer : public NodeVisitor { additional_data[static_cast(node.value)].clear(); if (!(*current_loop_data)["parent"].empty()) { const auto tmp = (*current_loop_data)["parent"]; - *current_loop_data = std::move(tmp); + *current_loop_data = tmp; } else { current_loop_data = &additional_data["loop"]; }