aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2007-07-25 20:37:18 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2007-07-25 20:37:18 +0000
commit22907f3d2928f97b7e70eb9f383acf81d30add5c (patch)
tree3ef77a3a4aed04e6a4f6e71494f3a76ff7645487
parent2640c9834f9783d13d7cec3e771a1c606e2cd342 (diff)
downloadpaludis-22907f3d2928f97b7e70eb9f383acf81d30add5c.tar.gz
paludis-22907f3d2928f97b7e70eb9f383acf81d30add5c.tar.xz
More QA checks
-rw-r--r--paludis/repositories/e/qa/Makefile.am10
-rw-r--r--paludis/repositories/e/qa/eapi_supported.cc42
-rw-r--r--paludis/repositories/e/qa/eapi_supported.hh37
-rw-r--r--paludis/repositories/e/qa/homepage_key.cc101
-rw-r--r--paludis/repositories/e/qa/homepage_key.hh37
-rw-r--r--paludis/repositories/e/qa/qa_checks.cc21
-rw-r--r--paludis/repositories/e/qa/qa_checks.hh10
-rw-r--r--paludis/repositories/e/qa/qa_checks_group.cc1
-rw-r--r--paludis/repositories/e/qa/qa_controller.cc21
-rw-r--r--paludis/repositories/e/qa/short_description_key.cc48
-rw-r--r--paludis/repositories/e/qa/short_description_key.hh37
11 files changed, 362 insertions, 3 deletions
diff --git a/paludis/repositories/e/qa/Makefile.am b/paludis/repositories/e/qa/Makefile.am
index 4fee025..74552a5 100644
--- a/paludis/repositories/e/qa/Makefile.am
+++ b/paludis/repositories/e/qa/Makefile.am
@@ -14,17 +14,23 @@ if ENABLE_QA
paludis_repositories_e_includedir = $(includedir)/paludis-$(PALUDIS_PC_SLOT)/paludis/repositories/e/
paludis_repositories_e_include_HEADERS = \
+ eapi_supported.hh \
+ homepage_key.hh \
+ qa_checks.hh \
qa_checks_group.hh \
qa_controller.hh \
- qa_checks.hh \
+ short_description_key.hh \
stray_files.hh
noinst_LTLIBRARIES = libpaludiserepositoryqa.la
libpaludiserepositoryqa_la_SOURCES = \
+ eapi_supported.cc \
+ homepage_key.cc \
+ qa_checks.cc \
qa_checks_group.cc \
qa_controller.cc \
- qa_checks.cc \
+ short_description_key.cc \
stray_files.cc \
$(paludis_repositories_e_include_HEADERS)
diff --git a/paludis/repositories/e/qa/eapi_supported.cc b/paludis/repositories/e/qa/eapi_supported.cc
new file mode 100644
index 0000000..12274a2
--- /dev/null
+++ b/paludis/repositories/e/qa/eapi_supported.cc
@@ -0,0 +1,42 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2007 Ciaran McCreesh <ciaranm@ciaranm.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 "eapi_supported.hh"
+#include <paludis/package_id.hh>
+#include <paludis/qa.hh>
+#include <paludis/repositories/e/eapi.hh>
+#include <paludis/repositories/e/e_repository_id.hh>
+#include <paludis/util/stringify.hh>
+
+bool
+paludis::erepository::eapi_supported_check(
+ QAReporter & reporter,
+ const tr1::shared_ptr<const ERepositoryID> & id,
+ const std::string & name)
+{
+ if (! id->eapi()->supported)
+ {
+ reporter.message(qaml_severe, name, "EAPI '" + stringify(id->eapi()->name) + "' not supported");
+ return false;
+ }
+
+ return true;
+}
+
+
diff --git a/paludis/repositories/e/qa/eapi_supported.hh b/paludis/repositories/e/qa/eapi_supported.hh
new file mode 100644
index 0000000..3fc5d7a
--- /dev/null
+++ b/paludis/repositories/e/qa/eapi_supported.hh
@@ -0,0 +1,37 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2007 Ciaran McCreesh <ciaranm@ciaranm.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_REPOSITORIES_E_QA_EAPI_SUPPORTED_HH
+#define PALUDIS_GUARD_PALUDIS_REPOSITORIES_E_QA_EAPI_SUPPORTED_HH 1
+
+#include <paludis/qa-fwd.hh>
+#include <paludis/repositories/e/e_repository_id.hh>
+
+namespace paludis
+{
+ namespace erepository
+ {
+ bool eapi_supported_check(
+ QAReporter &,
+ const tr1::shared_ptr<const ERepositoryID> &,
+ const std::string &);
+ }
+}
+
+#endif
diff --git a/paludis/repositories/e/qa/homepage_key.cc b/paludis/repositories/e/qa/homepage_key.cc
new file mode 100644
index 0000000..a4da01b
--- /dev/null
+++ b/paludis/repositories/e/qa/homepage_key.cc
@@ -0,0 +1,101 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2007 Ciaran McCreesh <ciaranm@ciaranm.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 "homepage_key.hh"
+#include <paludis/qa.hh>
+#include <paludis/metadata_key.hh>
+#include <paludis/util/stringify.hh>
+#include <paludis/util/visitor-impl.hh>
+#include <paludis/name.hh>
+#include <paludis/dep_spec.hh>
+#include <paludis/package_id.hh>
+
+using namespace paludis;
+using namespace paludis::erepository;
+
+namespace
+{
+ struct HomepageChecker :
+ ConstVisitor<URISpecTree>,
+ ConstVisitor<URISpecTree>::VisitConstSequence<HomepageChecker, AllDepSpec>,
+ ConstVisitor<URISpecTree>::VisitConstSequence<HomepageChecker, UseDepSpec>
+ {
+ using ConstVisitor<URISpecTree>::VisitConstSequence<HomepageChecker, UseDepSpec>::visit_sequence;
+ using ConstVisitor<URISpecTree>::VisitConstSequence<HomepageChecker, AllDepSpec>::visit_sequence;
+
+ QAReporter & reporter;
+ const tr1::shared_ptr<const ERepositoryID> id;
+ const std::string name;
+ bool found_one;
+
+ HomepageChecker(
+ QAReporter & r,
+ const tr1::shared_ptr<const ERepositoryID> & i,
+ const std::string & n) :
+ reporter(r),
+ id(i),
+ name(n),
+ found_one(false)
+ {
+ }
+
+ ~HomepageChecker()
+ {
+ if (! found_one)
+ reporter.message(qaml_normal, name, "Homepage '" + stringify(*id) + "' specifies no URIs");
+ }
+
+ void visit_leaf(const URIDepSpec & u)
+ {
+ found_one = true;
+
+ if (! u.renamed_url_suffix().empty())
+ reporter.message(qaml_normal, name, "Homepage for '" + stringify(*id) + "' uses -> in part '" + u.text() + "'");
+
+ if (0 == u.original_url().compare(0, 7, "http://") &&
+ 0 == u.original_url().compare(0, 8, "https://") &&
+ 0 == u.original_url().compare(0, 6, "ftp://"))
+ reporter.message(qaml_normal, name, "Homepage for '" + stringify(*id) + "' uses no or unknown protocol in part '" + u.text() + "'");
+ }
+
+ void visit_leaf(const LabelsDepSpec<URILabelVisitorTypes> &)
+ {
+ reporter.message(qaml_normal, name, "Homepage '" + stringify(*id) + "' uses labels");
+ }
+ };
+}
+
+bool
+paludis::erepository::homepage_key_check(
+ QAReporter & reporter,
+ const tr1::shared_ptr<const ERepositoryID> & id,
+ const std::string & name)
+{
+ if (! id->homepage_key())
+ reporter.message(qaml_normal, name, "No homepage available for '" + stringify(*id) + "'");
+ else
+ {
+ HomepageChecker h(reporter, id, name);
+ id->homepage_key()->value()->accept(h);
+ }
+
+ return true;
+}
+
+
diff --git a/paludis/repositories/e/qa/homepage_key.hh b/paludis/repositories/e/qa/homepage_key.hh
new file mode 100644
index 0000000..4f50b59
--- /dev/null
+++ b/paludis/repositories/e/qa/homepage_key.hh
@@ -0,0 +1,37 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2007 Ciaran McCreesh <ciaranm@ciaranm.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_REPOSITORIES_E_QA_HOMEPAGE_KEY_HH
+#define PALUDIS_GUARD_PALUDIS_REPOSITORIES_E_QA_HOMEPAGE_KEY_HH 1
+
+#include <paludis/qa-fwd.hh>
+#include <paludis/repositories/e/e_repository_id.hh>
+
+namespace paludis
+{
+ namespace erepository
+ {
+ bool homepage_key_check(
+ QAReporter &,
+ const tr1::shared_ptr<const ERepositoryID> &,
+ const std::string &);
+ }
+}
+
+#endif
diff --git a/paludis/repositories/e/qa/qa_checks.cc b/paludis/repositories/e/qa/qa_checks.cc
index 1961350..a59ed34 100644
--- a/paludis/repositories/e/qa/qa_checks.cc
+++ b/paludis/repositories/e/qa/qa_checks.cc
@@ -22,6 +22,9 @@
#include <paludis/util/instantiation_policy-impl.hh>
#include <paludis/repositories/e/qa/stray_files.hh>
+#include <paludis/repositories/e/qa/eapi_supported.hh>
+#include <paludis/repositories/e/qa/short_description_key.hh>
+#include <paludis/repositories/e/qa/homepage_key.hh>
using namespace paludis;
using namespace paludis::erepository;
@@ -35,10 +38,12 @@ namespace paludis
{
const tr1::shared_ptr<QAChecksGroup<TreeCheckFunction> > tree_checks_group;
const tr1::shared_ptr<QAChecksGroup<CategoryDirCheckFunction> > category_dir_checks_group;
+ const tr1::shared_ptr<QAChecksGroup<PackageIDCheckFunction> > package_id_checks_group;
Implementation() :
tree_checks_group(new QAChecksGroup<TreeCheckFunction>),
- category_dir_checks_group(new QAChecksGroup<CategoryDirCheckFunction>)
+ category_dir_checks_group(new QAChecksGroup<CategoryDirCheckFunction>),
+ package_id_checks_group(new QAChecksGroup<PackageIDCheckFunction>)
{
}
};
@@ -54,6 +59,15 @@ QAChecks::QAChecks() :
_imp->category_dir_checks_group->add_check("stray_category_dir_files",
tr1::bind(stray_files_check, _1, _3, _4, is_stray_at_category_dir, "stray_category_dir_files"));
+
+ _imp->package_id_checks_group->add_check("eapi_supported",
+ tr1::bind(eapi_supported_check, _1, _4, "eapi_supported"));
+ _imp->package_id_checks_group->add_check("short_description_key",
+ tr1::bind(short_description_key_check, _1, _4, "short_description_key"));
+ _imp->package_id_checks_group->add_prerequirement("short_description_key", "eapi_supported");
+ _imp->package_id_checks_group->add_check("homepage_key",
+ tr1::bind(homepage_key_check, _1, _4, "homepage_key"));
+ _imp->package_id_checks_group->add_prerequirement("homepage_key", "eapi_supported");
}
QAChecks::~QAChecks()
@@ -72,4 +86,9 @@ QAChecks::category_dir_checks_group()
return _imp->category_dir_checks_group;
}
+const tr1::shared_ptr<QAChecksGroup<PackageIDCheckFunction> >
+QAChecks::package_id_checks_group()
+{
+ return _imp->package_id_checks_group;
+}
diff --git a/paludis/repositories/e/qa/qa_checks.hh b/paludis/repositories/e/qa/qa_checks.hh
index 6db6a50..ae25d5f 100644
--- a/paludis/repositories/e/qa/qa_checks.hh
+++ b/paludis/repositories/e/qa/qa_checks.hh
@@ -29,8 +29,10 @@
#include <paludis/environment-fwd.hh>
#include <paludis/qa-fwd.hh>
+#include <paludis/package_id-fwd.hh>
#include <paludis/repositories/e/qa/qa_checks_group.hh>
+#include <paludis/repositories/e/e_repository_id.hh>
namespace paludis
{
@@ -52,6 +54,13 @@ namespace paludis
const FSEntry &
)> CategoryDirCheckFunction;
+ typedef tr1::function<bool (
+ QAReporter &,
+ const Environment * const,
+ const tr1::shared_ptr<const ERepository> &,
+ const tr1::shared_ptr<const ERepositoryID> &
+ )> PackageIDCheckFunction;
+
class QAChecks :
private PrivateImplementationPattern<QAChecks>,
public InstantiationPolicy<QAChecks, instantiation_method::SingletonTag>
@@ -65,6 +74,7 @@ namespace paludis
public:
const tr1::shared_ptr<QAChecksGroup<TreeCheckFunction> > tree_checks_group() PALUDIS_ATTRIBUTE((warn_unused_result));
const tr1::shared_ptr<QAChecksGroup<CategoryDirCheckFunction> > category_dir_checks_group() PALUDIS_ATTRIBUTE((warn_unused_result));
+ const tr1::shared_ptr<QAChecksGroup<PackageIDCheckFunction> > package_id_checks_group() PALUDIS_ATTRIBUTE((warn_unused_result));
};
}
}
diff --git a/paludis/repositories/e/qa/qa_checks_group.cc b/paludis/repositories/e/qa/qa_checks_group.cc
index 5b2039e..1e8fb2d 100644
--- a/paludis/repositories/e/qa/qa_checks_group.cc
+++ b/paludis/repositories/e/qa/qa_checks_group.cc
@@ -105,4 +105,5 @@ QAChecksGroup<T_>::need_ordering() const
}
template class QAChecksGroup<TreeCheckFunction>;
+template class QAChecksGroup<PackageIDCheckFunction>;
diff --git a/paludis/repositories/e/qa/qa_controller.cc b/paludis/repositories/e/qa/qa_controller.cc
index 47f003b..743f7ef 100644
--- a/paludis/repositories/e/qa/qa_controller.cc
+++ b/paludis/repositories/e/qa/qa_controller.cc
@@ -23,6 +23,7 @@
#include <paludis/util/private_implementation_pattern-impl.hh>
#include <paludis/util/tr1_functional.hh>
#include <paludis/util/set.hh>
+#include <paludis/util/sequence.hh>
#include <libwrapiter/libwrapiter_forward_iterator.hh>
@@ -94,6 +95,7 @@ QAController::run()
tr1::shared_ptr<const CategoryNamePartSet> categories(_imp->repo->category_names());
for (CategoryNamePartSet::Iterator c(categories->begin()), c_end(categories->end()) ;
c != c_end ; ++c)
+ {
std::find_if(
QAChecks::get_instance()->category_dir_checks_group()->begin(),
QAChecks::get_instance()->category_dir_checks_group()->end(),
@@ -101,5 +103,24 @@ QAController::run()
tr1::bind<bool>(tr1::mem_fn(&CategoryDirCheckFunction::operator() ),
_1, tr1::ref(_imp->reporter), _imp->env, _imp->repo, _imp->repo->layout()->category_directory(*c))));
+ tr1::shared_ptr<const QualifiedPackageNameSet> packages(_imp->repo->package_names(*c));
+ for (QualifiedPackageNameSet::Iterator p(packages->begin()), p_end(packages->end()) ;
+ p != p_end ; ++p)
+ {
+
+ tr1::shared_ptr<const PackageIDSequence> ids(_imp->repo->package_ids(*p));
+ for (PackageIDSequence::Iterator i(ids->begin()), i_end(ids->end()) ;
+ i != i_end ; ++i)
+ {
+ std::find_if(
+ QAChecks::get_instance()->package_id_checks_group()->begin(),
+ QAChecks::get_instance()->package_id_checks_group()->end(),
+ tr1::bind(std::equal_to<bool>(), false,
+ tr1::bind<bool>(tr1::mem_fn(&PackageIDCheckFunction::operator() ),
+ _1, tr1::ref(_imp->reporter), _imp->env, _imp->repo, tr1::static_pointer_cast<const ERepositoryID>(*i))));
+ }
+ }
+ }
+
}
diff --git a/paludis/repositories/e/qa/short_description_key.cc b/paludis/repositories/e/qa/short_description_key.cc
new file mode 100644
index 0000000..cb4c010
--- /dev/null
+++ b/paludis/repositories/e/qa/short_description_key.cc
@@ -0,0 +1,48 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2007 Ciaran McCreesh <ciaranm@ciaranm.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 "short_description_key.hh"
+#include <paludis/qa.hh>
+#include <paludis/metadata_key.hh>
+#include <paludis/util/stringify.hh>
+#include <paludis/name.hh>
+
+bool
+paludis::erepository::short_description_key_check(
+ QAReporter & reporter,
+ const tr1::shared_ptr<const ERepositoryID> & id,
+ const std::string & name)
+{
+ if (! id->short_description_key())
+ reporter.message(qaml_normal, name, "No description available for '" + stringify(*id) + "'");
+ else if (id->short_description_key()->value() == stringify(id->name()))
+ reporter.message(qaml_normal, name, "Description for '" + stringify(*id) + "' is equal to PN");
+ else if (std::string::npos != id->short_description_key()->value().find("Based on the")
+ && std::string::npos != id->short_description_key()->value().find("eclass"))
+ reporter.message(qaml_normal, name, "Description for '" + stringify(*id) + "' is about as useful as a chocolate teapot");
+ else if (id->short_description_key()->value().length() < 10)
+ reporter.message(qaml_normal, name, "Description for '" + stringify(*id) + "' is suspiciously short");
+ else if (id->short_description_key()->value().length() > 300)
+ reporter.message(qaml_normal, name, "Description for '" + stringify(*id) + "' written by Duncan?");
+ else if (id->short_description_key()->value().length() > 120)
+ reporter.message(qaml_normal, name, "Description for '" + stringify(*id) + "' is too long");
+
+ return true;
+}
+
diff --git a/paludis/repositories/e/qa/short_description_key.hh b/paludis/repositories/e/qa/short_description_key.hh
new file mode 100644
index 0000000..9ec1614
--- /dev/null
+++ b/paludis/repositories/e/qa/short_description_key.hh
@@ -0,0 +1,37 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2007 Ciaran McCreesh <ciaranm@ciaranm.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_REPOSITORIES_E_QA_SHORT_DESCRIPTION_KEY_HH
+#define PALUDIS_GUARD_PALUDIS_REPOSITORIES_E_QA_SHORT_DESCRIPTION_KEY_HH 1
+
+#include <paludis/qa-fwd.hh>
+#include <paludis/repositories/e/e_repository_id.hh>
+
+namespace paludis
+{
+ namespace erepository
+ {
+ bool short_description_key_check(
+ QAReporter & reporter,
+ const tr1::shared_ptr<const ERepositoryID> &,
+ const std::string & name);
+ }
+}
+
+#endif