Fix a few clang-tidy warnings

main
Duncan Ogilvie 2 years ago
parent ee7fe38a7b
commit e6d783ea20

@ -1,12 +1,10 @@
#include "cmake_generator.hpp" #include "cmake_generator.hpp"
#include "error.hpp"
#include "literals.hpp" #include "literals.hpp"
#include <resources/cmkr.hpp> #include <resources/cmkr.hpp>
#include "fs.hpp" #include "fs.hpp"
#include "project_parser.hpp" #include "project_parser.hpp"
#include <cstdio> #include <cstdio>
#include <fstream>
#include <memory> #include <memory>
#include <sstream> #include <sstream>
#include <stdexcept> #include <stdexcept>
@ -43,7 +41,7 @@ static tsl::ordered_map<std::string, std::vector<std::string>> known_languages =
{"Swift", {".swift"}}, {"Swift", {".swift"}},
}; };
static std::string format(const char *format, tsl::ordered_map<std::string, std::string> variables) { static std::string format(const char *format, const tsl::ordered_map<std::string, std::string> &variables) {
std::string s = format; std::string s = format;
for (const auto &itr : variables) { for (const auto &itr : variables) {
size_t start_pos = 0; size_t start_pos = 0;
@ -249,7 +247,7 @@ void generate_project(const std::string &type) {
struct CommandEndl { struct CommandEndl {
std::stringstream &ss; std::stringstream &ss;
CommandEndl(std::stringstream &ss) : ss(ss) { explicit CommandEndl(std::stringstream &ss) : ss(ss) {
} }
void endl() { void endl() {
ss << '\n'; ss << '\n';
@ -258,7 +256,7 @@ struct CommandEndl {
struct RawArg { struct RawArg {
RawArg() = default; RawArg() = default;
RawArg(std::string arg) : arg(std::move(arg)) { explicit RawArg(std::string arg) : arg(std::move(arg)) {
} }
std::string arg; std::string arg;
@ -293,7 +291,7 @@ struct Command {
// https://cmake.org/cmake/help/latest/manual/cmake-language.7.html#unquoted-argument // https://cmake.org/cmake/help/latest/manual/cmake-language.7.html#unquoted-argument
// NOTE: Normally '/' does not require quoting according to the documentation but this has been the case here // NOTE: Normally '/' does not require quoting according to the documentation but this has been the case here
// previously, so for backwards compatibility its still here. // previously, so for backwards compatibility its still here.
if (str.find_first_of("()#\"\\'> |/;") == str.npos) if (str.find_first_of("()#\"\\'> |/;") == std::string::npos)
return str; return str;
std::string result; std::string result;
result += "\""; result += "\"";
@ -442,10 +440,10 @@ static std::string tolf(const std::string &str) {
} }
} }
return result; return result;
}; }
struct Generator { struct Generator {
Generator(const parser::Project &project, const fs::path &path) : project(project), path(path) { Generator(const parser::Project &project, fs::path path) : project(project), path(std::move(path)) {
} }
Generator(const Generator &) = delete; Generator(const Generator &) = delete;
@ -893,7 +891,7 @@ void generate_cmake(const char *path, const parser::Project *parent_project) {
gen.conditional_includes(content.include_before); gen.conditional_includes(content.include_before);
gen.conditional_cmake(content.cmake_before); gen.conditional_cmake(content.cmake_before);
std::string version_info = ""; std::string version_info;
if (content.arguments.contains("GIT_TAG")) { if (content.arguments.contains("GIT_TAG")) {
version_info = " (" + content.arguments.at("GIT_TAG") + ")"; version_info = " (" + content.arguments.at("GIT_TAG") + ")";
} else if (content.arguments.contains("SVN_REVISION")) { } else if (content.arguments.contains("SVN_REVISION")) {

@ -36,7 +36,7 @@ static std::string format_key_message(const std::string &message, const toml::ke
auto loc = value.location(); auto loc = value.location();
auto line_number_str = std::to_string(loc.line()); auto line_number_str = std::to_string(loc.line());
auto line_width = line_number_str.length(); auto line_width = line_number_str.length();
auto line_str = loc.line_str(); const auto& line_str = loc.line_str();
std::ostringstream oss; std::ostringstream oss;
oss << message << "\n"; oss << message << "\n";
@ -73,7 +73,7 @@ class TomlChecker {
public: public:
TomlChecker(const TomlBasicValue &v, const toml::key &ky) : m_v(toml::find(v, ky)) { TomlChecker(const TomlBasicValue &v, const toml::key &ky) : m_v(toml::find(v, ky)) {
} }
TomlChecker(const TomlBasicValue &v) : m_v(v) { explicit TomlChecker(const TomlBasicValue &v) : m_v(v) {
} }
TomlChecker(const TomlChecker &) = delete; TomlChecker(const TomlChecker &) = delete;
TomlChecker(TomlChecker &&) = delete; TomlChecker(TomlChecker &&) = delete;
@ -175,7 +175,7 @@ class TomlCheckerRoot {
bool m_checked = false; bool m_checked = false;
public: public:
TomlCheckerRoot(const TomlBasicValue &root) : m_root(root) { explicit TomlCheckerRoot(const TomlBasicValue &root) : m_root(root) {
} }
TomlCheckerRoot(const TomlCheckerRoot &) = delete; TomlCheckerRoot(const TomlCheckerRoot &) = delete;
TomlCheckerRoot(TomlCheckerRoot &&) = delete; TomlCheckerRoot(TomlCheckerRoot &&) = delete;

Loading…
Cancel
Save