Skip to content

Commit 9954c25

Browse files
committed
build: Fix cppcheck issues
1 parent 9647e38 commit 9954c25

11 files changed

Lines changed: 15 additions & 24 deletions

File tree

generators/include/pl/formatters/formatter.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ namespace pl::gen::fmt {
3333
void enableMetaInformation(bool enable) { this->m_metaInformation = enable; }
3434
[[nodiscard]] bool isMetaInformationEnabled() const { return this->m_metaInformation; }
3535

36-
std::vector<std::pair<std::string, std::string>> getMetaInformation(ptrn::Pattern *pattern) const {
36+
std::vector<std::pair<std::string, std::string>> getMetaInformation(const ptrn::Pattern *pattern) const {
3737
if (!this->m_metaInformation)
3838
return { };
3939

generators/include/pl/formatters/formatter_html.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ namespace pl::gen::fmt {
1818
}
1919

2020
private:
21-
static std::string generateTooltip(std::vector<ptrn::Pattern*> &patterns) {
21+
static std::string generateTooltip(const std::vector<ptrn::Pattern*> &patterns) {
2222
if (patterns.empty())
2323
return "";
2424

lib/include/pl/api.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ namespace pl::api {
4141
std::string content;
4242
std::string source;
4343
u32 id = 0;
44-
bool mainSource;
44+
bool mainSource = false;
4545

4646
Source(std::string content, std::string source = DefaultSource, bool mainSource = false) :
4747
content(std::move(content)), source(std::move(source)), mainSource(mainSource) {

lib/include/pl/core/errors/error.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ namespace pl::core::err {
100100
}
101101

102102
private:
103-
char m_prefix;
103+
char m_prefix = 'E';
104104
u32 m_errorCode;
105105
std::string m_title;
106106
};

lib/include/pl/core/evaluator.hpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,6 @@ namespace pl::core {
328328

329329
[[nodiscard]] std::optional<Token::Literal> getEnvVariable(const std::string &name) const {
330330
if (this->m_envVariables.contains(name)) {
331-
auto value = this->m_envVariables.at(name);
332331
return this->m_envVariables.at(name);
333332
} else
334333
return std::nullopt;
@@ -477,7 +476,7 @@ namespace pl::core {
477476
}
478477

479478
private:
480-
PatternLanguage *m_patternLanguage;
479+
PatternLanguage *m_patternLanguage = nullptr;
481480
std::list<PatternLanguage> m_subRuntimes;
482481

483482
u64 m_currOffset = 0x00;

lib/include/pl/core/lexer.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,6 @@ namespace pl::core {
6767
u32 m_line = 0;
6868
u32 m_lineBegin = 0;
6969
size_t m_longestLineLength = 0;
70-
u32 m_errorLength;
70+
u32 m_errorLength = 0;
7171
};
7272
}

lib/include/pl/core/token.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ namespace pl::core {
248248

249249
using ValueTypes = std::variant<Keyword, Identifier, Operator, Literal, ValueType, Separator, Comment, DocComment, Directive>;
250250

251-
constexpr Token(const Type type, auto value, const Location location) : type(type), value(std::move(value)), location(location) {}
251+
constexpr Token(const Type type, auto value, const Location &location) : type(type), value(std::move(value)), location(location) {}
252252

253253
[[nodiscard]] constexpr static bool isInteger(const ValueType &type) {
254254
return isUnsigned(type) || isSigned(type);
@@ -278,9 +278,9 @@ namespace pl::core {
278278
bool operator==(const ValueTypes &other) const;
279279
bool operator!=(const ValueTypes &other) const;
280280

281-
Type type;
282-
ValueTypes value;
283-
Location location;
281+
Type type = {};
282+
ValueTypes value = {};
283+
Location location = {};
284284

285285
};
286286

lib/include/pl/helpers/utils.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,15 +106,15 @@ namespace pl::hlp {
106106
}
107107

108108
template<typename T, typename... Args>
109-
void moveToVector(std::vector<T> & buffer, Args &&...rest) {
109+
void moveToVectorBuffer(std::vector<T> & buffer, Args &&...rest) {
110110
buffer.reserve(sizeof...(rest));
111111
(buffer.push_back(std::move(rest)),...);
112112
}
113113

114114
template<typename T, typename... Args>
115115
[[nodiscard]] std::vector<T> moveToVector(T &&first, Args &&...rest) {
116116
std::vector<T> result;
117-
moveToVector(result, std::move(first), std::move(rest)...);
117+
moveToVectorBuffer(result, std::move(first), std::move(rest)...);
118118

119119
return result;
120120
}

lib/include/pl/patterns/pattern.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -288,9 +288,9 @@ namespace pl::ptrn {
288288
}
289289

290290
[[nodiscard]] virtual core::Token::Literal getValue() const {
291-
auto clone = this->clone();
291+
auto pattern = this->clone();
292292

293-
return this->transformValue(std::move(clone));
293+
return this->transformValue(std::move(pattern));
294294
}
295295

296296
[[nodiscard]] virtual std::vector<std::pair<u64, Pattern*>> getChildren() {

lib/include/pl/patterns/pattern_bitfield.hpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -222,10 +222,6 @@ namespace pl::ptrn {
222222
return "enum " + Pattern::getTypeName();
223223
}
224224

225-
[[nodiscard]] std::string getTypeName() const override {
226-
return Pattern::getTypeName();
227-
}
228-
229225
void setEnumValues(const std::map<std::string, PatternEnum::EnumValue> &enumValues) {
230226
this->m_enumValues = enumValues;
231227
}
@@ -544,7 +540,7 @@ namespace pl::ptrn {
544540
: PatternBitfieldMember(evaluator, offset, size_t((totalBitSize + 7) / 8), line), m_firstBitOffset(firstBitOffset), m_totalBitSize(totalBitSize) { }
545541

546542
PatternBitfield(const PatternBitfield &other) : PatternBitfieldMember(other) {
547-
for (auto &field : other.m_fields)
543+
for (const auto &field : other.m_fields)
548544
this->m_fields.push_back(field->clone());
549545

550546
this->m_firstBitOffset = other.m_firstBitOffset;

0 commit comments

Comments
 (0)