aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-02-17 00:00:21 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-02-17 00:00:21 +0000
commit3faf2847cc1bf2d2b701b171627529ddb6ce48d8 (patch)
treef2c50ff6a56deaf9c7f2466a098f489fe7cfafc9
parent50e2f4d44710c5f521cecc1515721c56d8e7f0ae (diff)
downloadpaludis-3faf2847cc1bf2d2b701b171627529ddb6ce48d8.tar.gz
paludis-3faf2847cc1bf2d2b701b171627529ddb6ce48d8.tar.xz
Check for too many ebuilds
-rw-r--r--paludis/qa/ebuild_count.cc52
-rw-r--r--paludis/qa/ebuild_count.hh51
-rw-r--r--paludis/qa/files.m41
3 files changed, 104 insertions, 0 deletions
diff --git a/paludis/qa/ebuild_count.cc b/paludis/qa/ebuild_count.cc
new file mode 100644
index 0000000..6384d48
--- /dev/null
+++ b/paludis/qa/ebuild_count.cc
@@ -0,0 +1,52 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2006 Ciaran McCreesh <ciaranm@gentoo.org>
+ *
+ * This file is part of the Paludis package manager. Paludis is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU General
+ * Public License version 2, as published by the Free Software Foundation.
+ *
+ * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include "ebuild_count.hh"
+#include <paludis/is_file_with_extension.hh>
+#include <paludis/dir_iterator.hh>
+#include <algorithm>
+
+using namespace paludis;
+using namespace paludis::qa;
+
+EbuildCountCheck::EbuildCountCheck()
+{
+}
+
+CheckResult
+EbuildCountCheck::operator() (const FSEntry & d) const
+{
+ CheckResult result(d, identifier());
+
+ std::size_t count(std::count_if(DirIterator(d), DirIterator(), IsFileWithExtension(".ebuild")));
+ if (count > 10)
+ result << Message(qal_minor, "Found " + stringify(count) +
+ " ebuilds, which is too many to count on my fingers");
+
+ return result;
+}
+
+const std::string &
+EbuildCountCheck::identifier()
+{
+ static const std::string id("ebuild count");
+ return id;
+}
+
+
diff --git a/paludis/qa/ebuild_count.hh b/paludis/qa/ebuild_count.hh
new file mode 100644
index 0000000..8358d69
--- /dev/null
+++ b/paludis/qa/ebuild_count.hh
@@ -0,0 +1,51 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2006 Ciaran McCreesh <ciaranm@gentoo.org>
+ *
+ * This file is part of the Paludis package manager. Paludis is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU General
+ * Public License version 2, as published by the Free Software Foundation.
+ *
+ * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#ifndef PALUDIS_GUARD_PALUDIS_QA_EBUILD_COUNT_HH
+#define PALUDIS_GUARD_PALUDIS_QA_EBUILD_COUNT_HH 1
+
+#include <paludis/qa/package_dir_check.hh>
+#include <string>
+
+namespace paludis
+{
+ namespace qa
+ {
+ class EbuildCountCheck :
+ public PackageDirCheck
+ {
+ public:
+ EbuildCountCheck();
+
+ CheckResult operator() (const FSEntry &) const;
+
+ static const std::string & identifier();
+
+ virtual std::string describe() const
+ {
+ return "Checks for a sane number of ebuilds";
+ }
+ };
+
+ static const PackageDirCheckMaker::RegisterMaker register_ebuild_count_check(
+ EbuildCountCheck::identifier(), &MakePackageDirCheck<EbuildCountCheck>::make_package_dir_check);
+ }
+}
+
+#endif
diff --git a/paludis/qa/files.m4 b/paludis/qa/files.m4
index 12d509c..2d6c0fe 100644
--- a/paludis/qa/files.m4
+++ b/paludis/qa/files.m4
@@ -18,6 +18,7 @@ add(`deps_exist_check', `hh', `cc')
add(`deps_visible_check', `hh', `cc')
add(`description_check', `hh', `cc')
add(`ebuild_check', `hh', `cc')
+add(`ebuild_count', `hh', `cc')
add(`environment', `hh', `cc')
add(`file_check', `hh', `cc')
add(`file_name_check', `hh', `cc')