fix some clang-tidy warnings

This commit is contained in:
pantor
2025-10-18 06:49:33 -07:00
parent 5b4d92c473
commit ebf4d0f42d
4 changed files with 12 additions and 10 deletions

View File

@@ -2,6 +2,7 @@ Checks: >
*,
-abseil-*,
-altera-*,
-boost-*,
-cppcoreguidelines-avoid-goto,
-cppcoreguidelines-non-private-member-variables-in-classes,
-fuchsia-*,
@@ -11,7 +12,8 @@ Checks: >
-misc-non-private-member-variables-in-classes,
-modernize-*,
-readability-function-cognitive-complexity,
-readability-identifier-length
-readability-identifier-length,
-readability-named-parameter
# Turn all the warnings from the checks above into errors.
HeaderFilterRegex: '.*/include/inja/.*\.hpp$'

View File

@@ -517,7 +517,7 @@ class Parser {
throw_parser_error("expected id, got '" + tok.describe() + "'");
}
const Token key_token = std::move(value_token);
const Token key_token = value_token;
value_token = tok;
get_next_token();
@@ -667,13 +667,13 @@ public:
const FunctionStorage& function_storage)
: config(parser_config), lexer(lexer_config), template_storage(template_storage), function_storage(function_storage) {}
Template parse(std::string_view input, std::filesystem::path path) {
Template parse(std::string_view input, const std::filesystem::path& path) {
auto result = Template(std::string(input));
parse_into(result, path);
return result;
}
void parse_into_template(Template& tmpl, std::filesystem::path filename) {
void parse_into_template(Template& tmpl, const std::filesystem::path& filename) {
auto sub_parser = Parser(config, lexer.get_config(), template_storage, function_storage);
sub_parser.parse_into(tmpl, filename.parent_path());
}

View File

@@ -115,7 +115,7 @@ class Renderer : public NodeVisitor {
const auto result = data_eval_stack.top();
data_eval_stack.pop();
if (!result) {
if (result == nullptr) {
if (not_found_stack.empty()) {
throw_renderer_error("expression could not be evaluated", expression_list);
}
@@ -661,7 +661,7 @@ public:
output_stream = &os;
current_template = &tmpl;
data_input = &data;
if (loop_data) {
if (loop_data != nullptr) {
additional_data = *loop_data;
current_loop_data = &additional_data["loop"];
}

View File

@@ -2117,13 +2117,13 @@ public:
const FunctionStorage& function_storage)
: config(parser_config), lexer(lexer_config), template_storage(template_storage), function_storage(function_storage) {}
Template parse(std::string_view input, std::filesystem::path path) {
Template parse(std::string_view input, const std::filesystem::path& path) {
auto result = Template(std::string(input));
parse_into(result, path);
return result;
}
void parse_into_template(Template& tmpl, std::filesystem::path filename) {
void parse_into_template(Template& tmpl, const std::filesystem::path& filename) {
auto sub_parser = Parser(config, lexer.get_config(), template_storage, function_storage);
sub_parser.parse_into(tmpl, filename.parent_path());
}
@@ -2268,7 +2268,7 @@ class Renderer : public NodeVisitor {
const auto result = data_eval_stack.top();
data_eval_stack.pop();
if (!result) {
if (result == nullptr) {
if (not_found_stack.empty()) {
throw_renderer_error("expression could not be evaluated", expression_list);
}
@@ -2814,7 +2814,7 @@ public:
output_stream = &os;
current_template = &tmpl;
data_input = &data;
if (loop_data) {
if (loop_data != nullptr) {
additional_data = *loop_data;
current_loop_data = &additional_data["loop"];
}