fix codacy issues II

This commit is contained in:
pantor
2020-08-08 13:41:16 +02:00
parent e29a04cbca
commit 73c04e6995
5 changed files with 13 additions and 13 deletions

View File

@@ -315,8 +315,8 @@ render("Hello{# Todo #}!", data); // "Hello!"
Inja uses `string_view` from C++17, but includes the [polyfill](https://github.com/martinmoene/string-view-lite) from martinmoene. This way, the minimum version is C++11. Currently, the following compilers are tested:
- GCC 4.8 - 9 (and possibly later)
- Clang 3.5 - 9 (and possibly later)
- Microsoft Visual C++ 2016 - 2019 (and possibly later)
- GCC 4.8 - 9 (and possibly later)
- Clang 3.5 - 9 (and possibly later)
- Microsoft Visual C++ 2016 - 2019 (and possibly later)
The unit tests fail to compile with GCC 4.8 but should just work fine. A complete list of supported compiler / os versions can be found in the [CI definition](https://github.com/pantor/inja/blob/master/.github/workflows/ci.yml).

View File

@@ -20,7 +20,7 @@ struct InjaError : public std::runtime_error {
SourceLocation location;
explicit InjaError(const std::string &type, const std::string &message)
: std::runtime_error("[inja.exception." + type + "] " + message), type(type), message(message) {}
: std::runtime_error("[inja.exception." + type + "] " + message), type(type), message(message), location({0, 0}) {}
explicit InjaError(const std::string &type, const std::string &message, SourceLocation location)
: std::runtime_error("[inja.exception." + type + "] (at " + std::to_string(location.line) + ":" +

View File

@@ -37,8 +37,8 @@ class Lexer {
const LexerConfig &config;
State state {State::Text};
MinusState minus_state {MinusState::Number};
State state;
MinusState minus_state;
nonstd::string_view m_in;
size_t tok_start;
size_t pos;
@@ -268,7 +268,7 @@ class Lexer {
}
public:
explicit Lexer(const LexerConfig &config) : config(config) {}
explicit Lexer(const LexerConfig &config) : config(config), state(State::Text), minus_state(MinusState::Number) {}
SourceLocation current_position() const {
return get_source_location(m_in, tok_start);

View File

@@ -56,7 +56,7 @@ inline SourceLocation get_source_location(nonstd::string_view content, size_t po
size_t search_start = 0;
while (search_start <= sliced.size()) {
search_start = sliced.find("\n", search_start) + 1;
if (search_start <= 0) {
if (search_start == 0) {
break;
}
count_lines += 1;

View File

@@ -1687,7 +1687,7 @@ struct InjaError : public std::runtime_error {
SourceLocation location;
explicit InjaError(const std::string &type, const std::string &message)
: std::runtime_error("[inja.exception." + type + "] " + message), type(type), message(message) {}
: std::runtime_error("[inja.exception." + type + "] " + message), type(type), message(message), location({0, 0}) {}
explicit InjaError(const std::string &type, const std::string &message, SourceLocation location)
: std::runtime_error("[inja.exception." + type + "] (at " + std::to_string(location.line) + ":" +
@@ -1869,7 +1869,7 @@ inline SourceLocation get_source_location(nonstd::string_view content, size_t po
size_t search_start = 0;
while (search_start <= sliced.size()) {
search_start = sliced.find("\n", search_start) + 1;
if (search_start <= 0) {
if (search_start == 0) {
break;
}
count_lines += 1;
@@ -1910,8 +1910,8 @@ class Lexer {
const LexerConfig &config;
State state {State::Text};
MinusState minus_state {MinusState::Number};
State state;
MinusState minus_state;
nonstd::string_view m_in;
size_t tok_start;
size_t pos;
@@ -2141,7 +2141,7 @@ class Lexer {
}
public:
explicit Lexer(const LexerConfig &config) : config(config) {}
explicit Lexer(const LexerConfig &config) : config(config), state(State::Text), minus_state(MinusState::Number) {}
SourceLocation current_position() const {
return get_source_location(m_in, tok_start);