From 8e67327abc422354b5090f1a803e1b565f7d4cda Mon Sep 17 00:00:00 2001 From: Mm2PL Date: Tue, 7 Feb 2023 21:49:37 +0100 Subject: [PATCH] Clean up NOLINT comments --- src/controllers/plugins/LuaApi.cpp | 17 ++++++----------- src/controllers/plugins/LuaApi.hpp | 12 +++++++----- src/controllers/plugins/PluginController.cpp | 4 ++-- 3 files changed, 15 insertions(+), 18 deletions(-) diff --git a/src/controllers/plugins/LuaApi.cpp b/src/controllers/plugins/LuaApi.cpp index 28794edc6..42b406fcc 100644 --- a/src/controllers/plugins/LuaApi.cpp +++ b/src/controllers/plugins/LuaApi.cpp @@ -16,6 +16,9 @@ # include # include + +// NOLINTBEGIN(*vararg) +// luaL_error is a c-style vararg function, this makes clang-tidy not dislike it so much namespace chatterino::lua::api { int c2_register_command(lua_State *L) @@ -23,20 +26,18 @@ int c2_register_command(lua_State *L) auto *pl = getApp()->plugins->getPluginByStatePtr(L); if (pl == nullptr) { - luaL_error(L, "internal error: no plugin"); // NOLINT + luaL_error(L, "internal error: no plugin"); return 0; } QString name; if (!lua::peek(L, &name, 1)) { - // NOLINTNEXTLINE luaL_error(L, "cannot get string (1st arg of register_command)"); return 0; } if (lua_isnoneornil(L, 2)) { - // NOLINTNEXTLINE luaL_error(L, "missing argument for register_command: function " "\"pointer\""); return 0; @@ -80,7 +81,7 @@ int c2_system_msg(lua_State *L) if (lua_gettop(L) != 2) { qCDebug(chatterinoLua) << "system_msg: need 2 args"; - luaL_error(L, "need exactly 2 arguments"); // NOLINT + luaL_error(L, "need exactly 2 arguments"); lua::push(L, false); return 1; } @@ -113,14 +114,12 @@ int g_load(lua_State *L) utf8->toUnicode(data.constData(), data.size(), &state); if (state.invalidChars != 0) { - // NOLINTNEXTLINE luaL_error(L, "invalid utf-8 in load() is not allowed"); return 0; } } else { - // NOLINTNEXTLINE luaL_error(L, "using reader function in load() is not allowed"); return 0; } @@ -152,7 +151,6 @@ int g_dofile(lua_State *L) if (countArgs == 0) { lua_pushnil(L); - // NOLINTNEXTLINE luaL_error(L, "it is not allowed to call dofile() without arguments"); return 1; } @@ -162,7 +160,6 @@ int g_dofile(lua_State *L) if (!lua::pop(L, &fname)) { lua_pushnil(L); - // NOLINTNEXTLINE luaL_error(L, "chatterino g_dofile: expected a string for a filename"); return 1; } @@ -174,7 +171,6 @@ int g_dofile(lua_State *L) if (!dir.isParentOf(file)) { lua_pushnil(L); - // NOLINTNEXTLINE luaL_error(L, "chatterino g_dofile: filename must be inside of the " "plugin directory"); return 1; @@ -187,7 +183,6 @@ int g_dofile(lua_State *L) if (qf.size() > 10'000'000) { lua_pushnil(L); - // NOLINTNEXTLINE luaL_error(L, "chatterino g_dofile: size limit of 10MB exceeded, what " "the hell are you doing"); return 1; @@ -199,7 +194,6 @@ int g_dofile(lua_State *L) if (state.invalidChars != 0) { lua_pushnil(L); - // NOLINTNEXTLINE luaL_error(L, "invalid utf-8 in dofile() target (%s) is not allowed", fname.toStdString().c_str()); return 1; @@ -215,4 +209,5 @@ int g_dofile(lua_State *L) } } // namespace chatterino::lua::api +// NOLINTEND(*vararg) #endif diff --git a/src/controllers/plugins/LuaApi.hpp b/src/controllers/plugins/LuaApi.hpp index 186d08f8c..c4d5af45d 100644 --- a/src/controllers/plugins/LuaApi.hpp +++ b/src/controllers/plugins/LuaApi.hpp @@ -5,12 +5,14 @@ struct lua_State; namespace chatterino::lua::api { // names in this namespace reflect what's visible inside Lua and follow the lua naming scheme -int c2_register_command(lua_State *L); // NOLINT(readability-identifier-naming) -int c2_send_msg(lua_State *L); // NOLINT(readability-identifier-naming) -int c2_system_msg(lua_State *L); // NOLINT(readability-identifier-naming) +// NOLINTBEGIN(readability-identifier-naming) +int c2_register_command(lua_State *L); +int c2_send_msg(lua_State *L); +int c2_system_msg(lua_State *L); -int g_load(lua_State *L); // NOLINT(readability-identifier-naming) -int g_dofile(lua_State *L); // NOLINT(readability-identifier-naming) +int g_load(lua_State *L); +int g_dofile(lua_State *L); +// NOLINTEND(readability-identifier-naming) } // namespace chatterino::lua::api diff --git a/src/controllers/plugins/PluginController.cpp b/src/controllers/plugins/PluginController.cpp index bab71614e..f719933bd 100644 --- a/src/controllers/plugins/PluginController.cpp +++ b/src/controllers/plugins/PluginController.cpp @@ -150,7 +150,7 @@ void PluginController::openLibrariesFor(lua_State *L, lua_pop(L, 1); } - // NOLINTNEXTLINE + // NOLINTNEXTLINE(*-avoid-c-arrays) static const luaL_Reg C2LIB[] = { {"system_msg", lua::api::c2_system_msg}, {"register_command", lua::api::c2_register_command}, @@ -179,7 +179,7 @@ void PluginController::openLibrariesFor(lua_State *L, lua_getfield(L, gtable, "dofile"); lua_setfield(L, LUA_REGISTRYINDEX, "real_dofile"); - // NOLINTNEXTLINE + // NOLINTNEXTLINE(*-avoid-c-arrays) static const luaL_Reg replacementFuncs[] = { {"load", lua::api::g_load},