aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar David Leverton <levertond@googlemail.com> 2008-01-26 17:13:40 +0000
committerAvatar David Leverton <levertond@googlemail.com> 2008-01-26 17:13:40 +0000
commit11f790d46039a5ec4817307dd6877aa4b83761c8 (patch)
treebc8cb822afff88b9067b681e272bddf5ef355988
parenta9b4ed0d06e8238a80dc6b9ec4142fc924339433 (diff)
downloadpaludis-11f790d46039a5ec4817307dd6877aa4b83761c8.tar.gz
paludis-11f790d46039a5ec4817307dd6877aa4b83761c8.tar.xz
Add deprecated_functions check.
-rw-r--r--paludis/repositories/e/qa/Makefile.am3
-rw-r--r--paludis/repositories/e/qa/deprecated_functions.cc120
-rw-r--r--paludis/repositories/e/qa/deprecated_functions.conf5
-rw-r--r--paludis/repositories/e/qa/deprecated_functions.hh43
-rw-r--r--paludis/repositories/e/qa/qa_checks.cc7
5 files changed, 178 insertions, 0 deletions
diff --git a/paludis/repositories/e/qa/Makefile.am b/paludis/repositories/e/qa/Makefile.am
index c922cb6..683aa65 100644
--- a/paludis/repositories/e/qa/Makefile.am
+++ b/paludis/repositories/e/qa/Makefile.am
@@ -18,6 +18,7 @@ if ENABLE_QA
paludis_qa_datadir = $(datadir)/paludis/qa/
dist_paludis_qa_data_DATA = \
+ deprecated_functions.conf \
extractors.conf \
inherited_blacklist.conf \
iuse_blacklist.conf \
@@ -53,6 +54,7 @@ paludis_repositories_e_include_HEADERS = \
whitespace.hh \
header.hh \
variable_assigns.hh \
+ deprecated_functions.hh \
gpg.hh \
ebuild_count.hh \
changelog.hh \
@@ -89,6 +91,7 @@ libpaludiserepositoryqa_la_SOURCES = \
whitespace.cc \
header.cc \
variable_assigns.cc \
+ deprecated_functions.cc \
gpg.cc \
ebuild_count.cc \
changelog.cc \
diff --git a/paludis/repositories/e/qa/deprecated_functions.cc b/paludis/repositories/e/qa/deprecated_functions.cc
new file mode 100644
index 0000000..2e8f479
--- /dev/null
+++ b/paludis/repositories/e/qa/deprecated_functions.cc
@@ -0,0 +1,120 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2006, 2007 Ciaran McCreesh
+ *
+ * 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 "deprecated_functions.hh"
+#include <paludis/qa.hh>
+#include <paludis/util/config_file.hh>
+#include <paludis/util/create_iterator-impl.hh>
+#include <paludis/util/fs_entry.hh>
+#include <paludis/util/instantiation_policy-impl.hh>
+#include <paludis/util/log.hh>
+#include <paludis/util/options.hh>
+#include <paludis/util/system.hh>
+#include <paludis/util/tokeniser.hh>
+#include <paludis/util/wrapped_forward_iterator.hh>
+#include <paludis/name.hh>
+#include <paludis/package_id.hh>
+#include <list>
+#include <string>
+#include <utility>
+#include <pcre++.h>
+
+using namespace paludis;
+using namespace paludis::erepository;
+
+namespace
+{
+ struct DeprecatedFunctions :
+ InstantiationPolicy<DeprecatedFunctions, instantiation_method::SingletonTag>
+ {
+ std::list<std::string> deprecated_functions;
+
+ DeprecatedFunctions(const FSEntry & f = FSEntry(getenv_with_default("PALUDIS_QA_DATA_DIR",
+ stringify(FSEntry(DATADIR) / "paludis" / "qa"))) / "deprecated_functions.conf")
+ {
+ try
+ {
+ LineConfigFile deprecated_functions_file(f, LineConfigFileOptions());
+ std::copy(deprecated_functions_file.begin(), deprecated_functions_file.end(),
+
+ std::back_inserter(deprecated_functions));
+ }
+ catch (const Exception & e)
+ {
+ Log::get_instance()->message(ll_warning, lc_context) << "Got error '" << e.message() << "' (" << e.what()
+ << ") when loading deprecated_functions.conf for QA deprecated_functions";
+ }
+ }
+ };
+
+ QAMessage
+ with_id(QAMessage m, const tr1::shared_ptr<const PackageID> & id)
+ {
+ return id ? m.with_associated_id(id) : m;
+ }
+}
+
+bool
+paludis::erepository::deprecated_functions_check(
+ const FSEntry & entry,
+ QAReporter & reporter,
+ const tr1::shared_ptr<const PackageID> & id,
+ const std::string & content,
+ const std::string & name)
+{
+ Context context("When performing check '" + name + "' using deprecated_functions_check on '" + (id ? stringify(*id) : stringify(entry)) + "':");
+
+ pcrepp::Pcre::Pcre r_comment("^\\s*#");
+ std::list<std::pair<std::string, pcrepp::Pcre::Pcre> > deprecated_functions;
+ for (std::list<std::string>::const_iterator
+ it(DeprecatedFunctions::get_instance()->deprecated_functions.begin()),
+ it_end(DeprecatedFunctions::get_instance()->deprecated_functions.end());
+ it_end != it; ++it)
+ deprecated_functions.push_back(std::make_pair(*it, pcrepp::Pcre::Pcre(*it)));
+
+ if (id)
+ Log::get_instance()->message(ll_debug, lc_context) << "deprecated_functions '"
+ << entry << "', '" << *id << "', '" << name << "'";
+ else
+ Log::get_instance()->message(ll_debug, lc_context) << "deprecated_functions '"
+ << entry << "', '" << name << "'";
+
+ std::list<std::string> lines;
+ tokenise<delim_kind::AnyOfTag, delim_mode::DelimiterTag>(content, "\n", "", std::back_inserter(lines));
+
+ unsigned line_number(0);
+ for (std::list<std::string>::iterator it(lines.begin()),
+ it_end(lines.end()); it_end != it; ++it)
+ {
+ ++line_number;
+
+ if (it->empty() || r_comment.search(*it))
+ continue;
+
+ for (std::list<std::pair<std::string, pcrepp::Pcre::Pcre> >::iterator
+ r(deprecated_functions.begin()), r_end(deprecated_functions.end()) ;
+ r != r_end ; ++r )
+ if (r->second.search(*it))
+ reporter.message(with_id(QAMessage(entry, qaml_normal, name,
+ "Deprecated call to '" + r->first + "' on line " + stringify(line_number)), id));
+ }
+
+ return true;
+}
+
diff --git a/paludis/repositories/e/qa/deprecated_functions.conf b/paludis/repositories/e/qa/deprecated_functions.conf
new file mode 100644
index 0000000..ae6303f
--- /dev/null
+++ b/paludis/repositories/e/qa/deprecated_functions.conf
@@ -0,0 +1,5 @@
+check_KV
+gnuconfig_update
+dyn_[a-z]*
+prepall[a-z.]*
+prepstrip
diff --git a/paludis/repositories/e/qa/deprecated_functions.hh b/paludis/repositories/e/qa/deprecated_functions.hh
new file mode 100644
index 0000000..a986619
--- /dev/null
+++ b/paludis/repositories/e/qa/deprecated_functions.hh
@@ -0,0 +1,43 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2007 Ciaran McCreesh
+ *
+ * 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_DEPRECATED_FUNCTIONS_HH
+#define PALUDIS_GUARD_PALUDIS_REPOSITORIES_E_QA_DEPRECATED_FUNCTIONS_HH 1
+
+#include <paludis/qa-fwd.hh>
+#include <paludis/package_id-fwd.hh>
+#include <paludis/environment-fwd.hh>
+#include <paludis/util/attributes.hh>
+#include <paludis/util/fs_entry-fwd.hh>
+#include <paludis/repositories/e/e_repository.hh>
+
+namespace paludis
+{
+ namespace erepository
+ {
+ bool deprecated_functions_check(
+ const FSEntry &,
+ QAReporter &,
+ const tr1::shared_ptr<const PackageID> &,
+ const std::string &,
+ const std::string &);
+ }
+}
+
+#endif
diff --git a/paludis/repositories/e/qa/qa_checks.cc b/paludis/repositories/e/qa/qa_checks.cc
index 0ddf8c3..135e0ff 100644
--- a/paludis/repositories/e/qa/qa_checks.cc
+++ b/paludis/repositories/e/qa/qa_checks.cc
@@ -41,6 +41,7 @@
#include <paludis/repositories/e/qa/visibility.hh>
#include <paludis/repositories/e/qa/default_functions.hh>
#include <paludis/repositories/e/qa/variable_assigns.hh>
+#include <paludis/repositories/e/qa/deprecated_functions.hh>
#include <paludis/repositories/e/qa/kv_variables.hh>
#include <paludis/repositories/e/qa/root_variable.hh>
#include <paludis/repositories/e/qa/subshell_die.hh>
@@ -96,6 +97,9 @@ QAChecks::QAChecks() :
_imp->eclass_file_contents_checks_group->add_check("variable_assigns",
tr1::bind(variable_assigns_check, _1, _2, tr1::shared_ptr<const ERepositoryID>(), _5, "variable_assigns"));
+ _imp->eclass_file_contents_checks_group->add_check("deprecated_functions",
+ tr1::bind(deprecated_functions_check, _1, _2, tr1::shared_ptr<const ERepositoryID>(), _5, "deprecated_functions"));
+
_imp->eclass_file_contents_checks_group->add_check("subshell_die",
tr1::bind(subshell_die_check, _1, _2, tr1::shared_ptr<const ERepositoryID>(), _5, "subshell_die"));
@@ -179,6 +183,9 @@ QAChecks::QAChecks() :
_imp->package_id_file_contents_checks_group->add_check("variable_assigns",
tr1::bind(variable_assigns_check, _1, _2, _5, _6, "variable_assigns"));
+ _imp->package_id_file_contents_checks_group->add_check("deprecated_functions",
+ tr1::bind(deprecated_functions_check, _1, _2, _5, _6, "deprecated_functions"));
+
_imp->package_id_file_contents_checks_group->add_check("kv_variables",
tr1::bind(kv_variables_check, _1, _2, _5, _6, "kv_variables"));