Skip to content

Commit e6d783e

Browse files
committed
Fix a few clang-tidy warnings
1 parent ee7fe38 commit e6d783e

File tree

2 files changed

+10
-12
lines changed

2 files changed

+10
-12
lines changed

src/cmake_generator.cpp

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
#include "cmake_generator.hpp"
2-
#include "error.hpp"
32
#include "literals.hpp"
43
#include <resources/cmkr.hpp>
54

65
#include "fs.hpp"
76
#include "project_parser.hpp"
87
#include <cstdio>
9-
#include <fstream>
108
#include <memory>
119
#include <sstream>
1210
#include <stdexcept>
@@ -43,7 +41,7 @@ static tsl::ordered_map<std::string, std::vector<std::string>> known_languages =
4341
{"Swift", {".swift"}},
4442
};
4543

46-
static std::string format(const char *format, tsl::ordered_map<std::string, std::string> variables) {
44+
static std::string format(const char *format, const tsl::ordered_map<std::string, std::string> &variables) {
4745
std::string s = format;
4846
for (const auto &itr : variables) {
4947
size_t start_pos = 0;
@@ -249,7 +247,7 @@ void generate_project(const std::string &type) {
249247

250248
struct CommandEndl {
251249
std::stringstream &ss;
252-
CommandEndl(std::stringstream &ss) : ss(ss) {
250+
explicit CommandEndl(std::stringstream &ss) : ss(ss) {
253251
}
254252
void endl() {
255253
ss << '\n';
@@ -258,7 +256,7 @@ struct CommandEndl {
258256

259257
struct RawArg {
260258
RawArg() = default;
261-
RawArg(std::string arg) : arg(std::move(arg)) {
259+
explicit RawArg(std::string arg) : arg(std::move(arg)) {
262260
}
263261

264262
std::string arg;
@@ -293,7 +291,7 @@ struct Command {
293291
// https://cmake.org/cmake/help/latest/manual/cmake-language.7.html#unquoted-argument
294292
// NOTE: Normally '/' does not require quoting according to the documentation but this has been the case here
295293
// previously, so for backwards compatibility its still here.
296-
if (str.find_first_of("()#\"\\'> |/;") == str.npos)
294+
if (str.find_first_of("()#\"\\'> |/;") == std::string::npos)
297295
return str;
298296
std::string result;
299297
result += "\"";
@@ -442,10 +440,10 @@ static std::string tolf(const std::string &str) {
442440
}
443441
}
444442
return result;
445-
};
443+
}
446444

447445
struct Generator {
448-
Generator(const parser::Project &project, const fs::path &path) : project(project), path(path) {
446+
Generator(const parser::Project &project, fs::path path) : project(project), path(std::move(path)) {
449447
}
450448
Generator(const Generator &) = delete;
451449

@@ -893,7 +891,7 @@ void generate_cmake(const char *path, const parser::Project *parent_project) {
893891
gen.conditional_includes(content.include_before);
894892
gen.conditional_cmake(content.cmake_before);
895893

896-
std::string version_info = "";
894+
std::string version_info;
897895
if (content.arguments.contains("GIT_TAG")) {
898896
version_info = " (" + content.arguments.at("GIT_TAG") + ")";
899897
} else if (content.arguments.contains("SVN_REVISION")) {

src/project_parser.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ static std::string format_key_message(const std::string &message, const toml::ke
3636
auto loc = value.location();
3737
auto line_number_str = std::to_string(loc.line());
3838
auto line_width = line_number_str.length();
39-
auto line_str = loc.line_str();
39+
const auto& line_str = loc.line_str();
4040

4141
std::ostringstream oss;
4242
oss << message << "\n";
@@ -73,7 +73,7 @@ class TomlChecker {
7373
public:
7474
TomlChecker(const TomlBasicValue &v, const toml::key &ky) : m_v(toml::find(v, ky)) {
7575
}
76-
TomlChecker(const TomlBasicValue &v) : m_v(v) {
76+
explicit TomlChecker(const TomlBasicValue &v) : m_v(v) {
7777
}
7878
TomlChecker(const TomlChecker &) = delete;
7979
TomlChecker(TomlChecker &&) = delete;
@@ -175,7 +175,7 @@ class TomlCheckerRoot {
175175
bool m_checked = false;
176176

177177
public:
178-
TomlCheckerRoot(const TomlBasicValue &root) : m_root(root) {
178+
explicit TomlCheckerRoot(const TomlBasicValue &root) : m_root(root) {
179179
}
180180
TomlCheckerRoot(const TomlCheckerRoot &) = delete;
181181
TomlCheckerRoot(TomlCheckerRoot &&) = delete;

0 commit comments

Comments
 (0)