mirror of
https://github.com/pantor/inja.git
synced 2026-02-17 09:03:58 +00:00
fix codacy issues II
This commit is contained in:
@@ -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).
|
||||
|
||||
@@ -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) + ":" +
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user