changeset 584:2c3122f23a04

Misc: pet vera
author David Demelier <markand@malikania.fr>
date Mon, 04 Dec 2017 15:23:53 +0100
parents 55cc4ba15026
children 1ad88e2e3086
files cmake/function/IrccdVeraCheck.cmake irccdctl/main.cpp irccdctl/plugin_unload_cli.cpp libcommon/irccd/string_util.cpp libcommon/irccd/string_util.hpp libcommon/irccd/system.cpp libcommon/irccd/util.hpp libirccd-js/irccd/js/util_jsapi.cpp libirccd/irccd/rule_service.cpp libirccd/irccd/server_service.cpp tests/src/file-jsapi/main.cpp tests/src/plugin-hangman/main.cpp
diffstat 12 files changed, 36 insertions(+), 16 deletions(-) [+]
line wrap: on
line diff
--- a/cmake/function/IrccdVeraCheck.cmake	Mon Dec 04 14:30:31 2017 +0100
+++ b/cmake/function/IrccdVeraCheck.cmake	Mon Dec 04 15:23:53 2017 +0100
@@ -36,6 +36,7 @@
 
         # Cleanup non relevant files.
         foreach (s ${sources})
+            get_filename_component(s ${s} ABSOLUTE)
             get_filename_component(ext ${s} EXT)
 
             foreach (e ${valid})
--- a/irccdctl/main.cpp	Mon Dec 04 14:30:31 2017 +0100
+++ b/irccdctl/main.cpp	Mon Dec 04 15:23:53 2017 +0100
@@ -243,7 +243,8 @@
          * argument is a command name.
          */
         if (option.size() == 1 && option[0].empty())
-            throw std::runtime_error(string_util::sprintf("alias %s: missing command name in '%s'", name, option.key()));
+            throw std::runtime_error(string_util::sprintf("alias %s: missing command name in '%s'",
+                name, option.key()));
 
         std::string command = option[0];
         std::vector<alias_arg> args(option.begin() + 1, option.end());
@@ -416,7 +417,8 @@
         for (const auto& arg : cmd.args()) {
             if (arg.is_placeholder()) {
                 if (args.size() < arg.index() + 1)
-                    throw std::invalid_argument(string_util::sprintf("missing argument for placeholder %d", arg.index()));
+                    throw std::invalid_argument(
+                        string_util::sprintf("missing argument for placeholder %d", arg.index()));
 
                 cmd_args.push_back(args[arg.index()]);
 
--- a/irccdctl/plugin_unload_cli.cpp	Mon Dec 04 14:30:31 2017 +0100
+++ b/irccdctl/plugin_unload_cli.cpp	Mon Dec 04 15:23:53 2017 +0100
@@ -35,7 +35,6 @@
     request(ctl, {{ "plugin", args[0] }});
 }
 
-
 } // !ctl
 
 } // !irccd
--- a/libcommon/irccd/string_util.cpp	Mon Dec 04 14:30:31 2017 +0100
+++ b/libcommon/irccd/string_util.cpp	Mon Dec 04 15:23:53 2017 +0100
@@ -184,7 +184,10 @@
 #endif
 }
 
-std::string substitute(std::string::const_iterator& it, std::string::const_iterator& end, char token, const subst& params)
+std::string substitute(std::string::const_iterator& it,
+                       std::string::const_iterator& end,
+                       char token,
+                       const subst& params)
 {
     assert(is_reserved(token));
 
--- a/libcommon/irccd/string_util.hpp	Mon Dec 04 14:30:31 2017 +0100
+++ b/libcommon/irccd/string_util.hpp	Mon Dec 04 15:23:53 2017 +0100
@@ -233,6 +233,7 @@
  * \param first the first iterator
  * \param last the last iterator
  * \param delim the optional delimiter
+ * \return the string
  */
 template <typename InputIt, typename DelimType = char>
 std::string join(InputIt first, InputIt last, DelimType delim = ':')
@@ -250,6 +251,19 @@
 }
 
 /**
+ * Overloaded function that takes a container.
+ *
+ * \param c the container
+ * \param delim the optional delimiter
+ * \return the string
+ */
+template <typename Container, typename DelimType = char>
+std::string join(const Container& c, DelimType delim = ':')
+{
+    return join(c.begin(), c.end(), delim);
+}
+
+/**
  * Convenient overload.
  *
  * \param list the initializer list
--- a/libcommon/irccd/system.cpp	Mon Dec 04 14:30:31 2017 +0100
+++ b/libcommon/irccd/system.cpp	Mon Dec 04 15:23:53 2017 +0100
@@ -39,7 +39,10 @@
 #   include <cerrno>
 #   include <climits>
 #   include <cstring>
-#elif defined(IRCCD_SYSTEM_FREEBSD) || defined(IRCCD_SYSTEM_DRAGONFLYBSD) || defined(IRCCD_SYSTEM_NETBSD) || defined(IRCCD_SYSTEM_OPENBSD)
+#elif defined(IRCCD_SYSTEM_FREEBSD)                                         \
+    || defined(IRCCD_SYSTEM_DRAGONFLYBSD)                                   \
+    || defined(IRCCD_SYSTEM_NETBSD)                                         \
+    || defined(IRCCD_SYSTEM_OPENBSD)
 #   if defined(IRCCD_SYSTEM_NETBSD)
 #       include <sys/param.h>
 #   else
--- a/libcommon/irccd/util.hpp	Mon Dec 04 14:30:31 2017 +0100
+++ b/libcommon/irccd/util.hpp	Mon Dec 04 15:23:53 2017 +0100
@@ -55,7 +55,6 @@
 {
 }
 
-
 } // !util
 
 } // !irccd
--- a/libirccd-js/irccd/js/util_jsapi.cpp	Mon Dec 04 14:30:31 2017 +0100
+++ b/libirccd-js/irccd/js/util_jsapi.cpp	Mon Dec 04 15:23:53 2017 +0100
@@ -57,7 +57,6 @@
                 dukx_get<std::string>(ctx, -1)
             });
 
-
         duk_pop_n(ctx, 2);
     }
 
--- a/libirccd/irccd/rule_service.cpp	Mon Dec 04 14:30:31 2017 +0100
+++ b/libirccd/irccd/rule_service.cpp	Mon Dec 04 15:23:53 2017 +0100
@@ -70,13 +70,15 @@
 
     int i = 0;
     for (const auto& rule : rules_) {
+        auto action = rule.action() == rule::action_type::accept ? "accept" : "drop";
+
         log::debug() << "  candidate "   << i++ << ":\n"
-                     << "    servers: "  << string_util::join(rule.servers().begin(), rule.servers().end()) << "\n"
-                     << "    channels: " << string_util::join(rule.channels().begin(), rule.channels().end()) << "\n"
-                     << "    origins: "  << string_util::join(rule.origins().begin(), rule.origins().end()) << "\n"
-                     << "    plugins: "  << string_util::join(rule.plugins().begin(), rule.plugins().end()) << "\n"
-                     << "    events: "   << string_util::join(rule.events().begin(), rule.events().end()) << "\n"
-                     << "    action: "   << ((rule.action() == rule::action_type::accept) ? "accept" : "drop") << std::endl;
+                     << "    servers: "  << string_util::join(rule.servers()) << "\n"
+                     << "    channels: " << string_util::join(rule.channels()) << "\n"
+                     << "    origins: "  << string_util::join(rule.origins()) << "\n"
+                     << "    plugins: "  << string_util::join(rule.plugins()) << "\n"
+                     << "    events: "   << string_util::join(rule.events()) << "\n"
+                     << "    action: "   << action << std::endl;
 
         if (rule.match(server, channel, origin, plugin, event))
             result = rule.action() == rule::action_type::accept;
--- a/libirccd/irccd/server_service.cpp	Mon Dec 04 14:30:31 2017 +0100
+++ b/libirccd/irccd/server_service.cpp	Mon Dec 04 15:23:53 2017 +0100
@@ -376,7 +376,7 @@
     log::debug() << "  username: " << ev.whois.user << "\n";
     log::debug() << "  host: " << ev.whois.host << "\n";
     log::debug() << "  realname: " << ev.whois.realname << "\n";
-    log::debug() << "  channels: " << string_util::join(ev.whois.channels.begin(), ev.whois.channels.end(), ", ") << std::endl;
+    log::debug() << "  channels: " << string_util::join(ev.whois.channels, ", ") << std::endl;
 
     irccd_.transports().broadcast(nlohmann::json::object({
         { "event",      "onWhois"           },
--- a/tests/src/file-jsapi/main.cpp	Mon Dec 04 14:30:31 2017 +0100
+++ b/tests/src/file-jsapi/main.cpp	Mon Dec 04 15:23:53 2017 +0100
@@ -47,7 +47,6 @@
     BOOST_TEST("/usr/local/etc" == duk_get_string(plugin_->context(), -1));
 }
 
-
 BOOST_AUTO_TEST_CASE(function_exists)
 {
     if (duk_peval_string(plugin_->context(), "result = Irccd.File.exists(CMAKE_SOURCE_DIR + '/tests/root/file-1.txt')"))
--- a/tests/src/plugin-hangman/main.cpp	Mon Dec 04 14:30:31 2017 +0100
+++ b/tests/src/plugin-hangman/main.cpp	Mon Dec 04 15:23:53 2017 +0100
@@ -110,7 +110,6 @@
     BOOST_TEST(cmd["message"].get<std::string>() == "dead=hangman:!hangman:test:#hangman:jean!jean@localhost:jean:sky");
 }
 
-
 BOOST_AUTO_TEST_CASE(found)
 {
     load({{ "collaborative", "false" }});