Skip to content

Commit ebf4d0f

Browse files
committed
fix some clang-tidy warnings
1 parent 5b4d92c commit ebf4d0f

File tree

4 files changed

+12
-10
lines changed

4 files changed

+12
-10
lines changed

.clang-tidy

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ Checks: >
22
*,
33
-abseil-*,
44
-altera-*,
5+
-boost-*,
56
-cppcoreguidelines-avoid-goto,
67
-cppcoreguidelines-non-private-member-variables-in-classes,
78
-fuchsia-*,
@@ -11,7 +12,8 @@ Checks: >
1112
-misc-non-private-member-variables-in-classes,
1213
-modernize-*,
1314
-readability-function-cognitive-complexity,
14-
-readability-identifier-length
15+
-readability-identifier-length,
16+
-readability-named-parameter
1517
1618
# Turn all the warnings from the checks above into errors.
1719
HeaderFilterRegex: '.*/include/inja/.*\.hpp$'

include/inja/parser.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -517,7 +517,7 @@ class Parser {
517517
throw_parser_error("expected id, got '" + tok.describe() + "'");
518518
}
519519

520-
const Token key_token = std::move(value_token);
520+
const Token key_token = value_token;
521521
value_token = tok;
522522
get_next_token();
523523

@@ -667,13 +667,13 @@ class Parser {
667667
const FunctionStorage& function_storage)
668668
: config(parser_config), lexer(lexer_config), template_storage(template_storage), function_storage(function_storage) {}
669669

670-
Template parse(std::string_view input, std::filesystem::path path) {
670+
Template parse(std::string_view input, const std::filesystem::path& path) {
671671
auto result = Template(std::string(input));
672672
parse_into(result, path);
673673
return result;
674674
}
675675

676-
void parse_into_template(Template& tmpl, std::filesystem::path filename) {
676+
void parse_into_template(Template& tmpl, const std::filesystem::path& filename) {
677677
auto sub_parser = Parser(config, lexer.get_config(), template_storage, function_storage);
678678
sub_parser.parse_into(tmpl, filename.parent_path());
679679
}

include/inja/renderer.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ class Renderer : public NodeVisitor {
115115
const auto result = data_eval_stack.top();
116116
data_eval_stack.pop();
117117

118-
if (!result) {
118+
if (result == nullptr) {
119119
if (not_found_stack.empty()) {
120120
throw_renderer_error("expression could not be evaluated", expression_list);
121121
}
@@ -661,7 +661,7 @@ class Renderer : public NodeVisitor {
661661
output_stream = &os;
662662
current_template = &tmpl;
663663
data_input = &data;
664-
if (loop_data) {
664+
if (loop_data != nullptr) {
665665
additional_data = *loop_data;
666666
current_loop_data = &additional_data["loop"];
667667
}

single_include/inja/inja.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2117,13 +2117,13 @@ class Parser {
21172117
const FunctionStorage& function_storage)
21182118
: config(parser_config), lexer(lexer_config), template_storage(template_storage), function_storage(function_storage) {}
21192119

2120-
Template parse(std::string_view input, std::filesystem::path path) {
2120+
Template parse(std::string_view input, const std::filesystem::path& path) {
21212121
auto result = Template(std::string(input));
21222122
parse_into(result, path);
21232123
return result;
21242124
}
21252125

2126-
void parse_into_template(Template& tmpl, std::filesystem::path filename) {
2126+
void parse_into_template(Template& tmpl, const std::filesystem::path& filename) {
21272127
auto sub_parser = Parser(config, lexer.get_config(), template_storage, function_storage);
21282128
sub_parser.parse_into(tmpl, filename.parent_path());
21292129
}
@@ -2268,7 +2268,7 @@ class Renderer : public NodeVisitor {
22682268
const auto result = data_eval_stack.top();
22692269
data_eval_stack.pop();
22702270

2271-
if (!result) {
2271+
if (result == nullptr) {
22722272
if (not_found_stack.empty()) {
22732273
throw_renderer_error("expression could not be evaluated", expression_list);
22742274
}
@@ -2814,7 +2814,7 @@ class Renderer : public NodeVisitor {
28142814
output_stream = &os;
28152815
current_template = &tmpl;
28162816
data_input = &data;
2817-
if (loop_data) {
2817+
if (loop_data != nullptr) {
28182818
additional_data = *loop_data;
28192819
current_loop_data = &additional_data["loop"];
28202820
}

0 commit comments

Comments
 (0)