diff options
-rw-r--r-- | paludis/distributions/exherbo/e.conf | 6 | ||||
-rw-r--r-- | paludis/distributions/gentoo/e.conf | 8 | ||||
-rw-r--r-- | paludis/repositories/e/extra_distribution_data.cc | 21 | ||||
-rw-r--r-- | paludis/repositories/e/extra_distribution_data.hh | 14 | ||||
-rw-r--r-- | paludis/repositories/e/qa/qa_checks.cc | 267 | ||||
-rw-r--r-- | paludis/repositories/e/qa/qa_checks.hh | 11 | ||||
-rw-r--r-- | paludis/repositories/e/qa/qa_controller.cc | 31 |
7 files changed, 234 insertions, 124 deletions
diff --git a/paludis/distributions/exherbo/e.conf b/paludis/distributions/exherbo/e.conf index 982463865..b4c92e01d 100644 --- a/paludis/distributions/exherbo/e.conf +++ b/paludis/distributions/exherbo/e.conf @@ -7,4 +7,8 @@ default_names_cache = /var/cache/paludis/names default_profile_eapi = exheres-0 default_provides_cache = /var/empty default_write_cache = /var/cache/paludis/metadata - +qa_category_dir_checks = +qa_eclass_file_contents_checks = +qa_package_dir_checks = +qa_package_id_checks = +qa_tree_checks = diff --git a/paludis/distributions/gentoo/e.conf b/paludis/distributions/gentoo/e.conf index f4ddaeda2..adda8ed5b 100644 --- a/paludis/distributions/gentoo/e.conf +++ b/paludis/distributions/gentoo/e.conf @@ -7,3 +7,11 @@ default_names_cache = default_profile_eapi = 0 default_provides_cache = default_write_cache = /var/empty +qa_category_dir_checks = stray_category_dir_files +qa_eclass_file_contents_checks = variable_assigns deprecated_functions subshell_die header function_keyword whitespace +qa_package_dir_checks = manifest ebuild_count changelog misc_files files_dir_size +qa_package_id_checks = eapi_supported metadata_keys short_description_key homepage_key iuse_key keywords_key license_key \ + spec_keys extractors fetches_key restrict_key inherited_key visibility +qa_package_id_file_contents_checks = default_functions variable_assigns deprecated_functions kv_variables root_variable \ + subshell_die function_keyword whitespace header +qa_tree_checks = stray_tree_files repo_name categories diff --git a/paludis/repositories/e/extra_distribution_data.cc b/paludis/repositories/e/extra_distribution_data.cc index 917924bc3..69e0b79d2 100644 --- a/paludis/repositories/e/extra_distribution_data.cc +++ b/paludis/repositories/e/extra_distribution_data.cc @@ -20,11 +20,24 @@ #include <paludis/repositories/e/extra_distribution_data.hh> #include <paludis/util/make_named_values.hh> #include <paludis/util/make_shared_ptr.hh> +#include <paludis/util/set.hh> +#include <paludis/util/tokeniser.hh> +#include <paludis/util/wrapped_output_iterator.hh> #include <paludis/distribution-impl.hh> using namespace paludis; using namespace paludis::erepository; +namespace +{ + std::tr1::shared_ptr<const Set<std::string> > make_set(const std::string & s) + { + std::tr1::shared_ptr<Set<std::string> > result(new Set<std::string>); + tokenise_whitespace(s, result->inserter()); + return result; + } +} + namespace paludis { template <> @@ -46,7 +59,13 @@ namespace paludis value_for<n::default_names_cache>(k->get("default_names_cache")), value_for<n::default_profile_eapi>(k->get("default_profile_eapi")), value_for<n::default_provides_cache>(k->get("default_provides_cache")), - value_for<n::default_write_cache>(k->get("default_write_cache")) + value_for<n::default_write_cache>(k->get("default_write_cache")), + value_for<n::qa_category_dir_checks>(make_set(k->get("qa_category_dir_checks"))), + value_for<n::qa_eclass_file_contents_checks>(make_set(k->get("qa_eclass_file_contents_checks"))), + value_for<n::qa_package_dir_checks>(make_set(k->get("qa_package_dir_checks"))), + value_for<n::qa_package_id_checks>(make_set(k->get("qa_package_id_checks"))), + value_for<n::qa_package_id_file_contents_checks>(make_set(k->get("qa_package_id_file_contents_checks"))), + value_for<n::qa_tree_checks>(make_set(k->get("qa_tree_checks"))) ))); } }; diff --git a/paludis/repositories/e/extra_distribution_data.hh b/paludis/repositories/e/extra_distribution_data.hh index 6071d439c..28e458617 100644 --- a/paludis/repositories/e/extra_distribution_data.hh +++ b/paludis/repositories/e/extra_distribution_data.hh @@ -22,6 +22,8 @@ #include <paludis/distribution-fwd.hh> #include <paludis/util/named_value.hh> +#include <paludis/util/set.hh> +#include <tr1/memory> #include <string> namespace paludis @@ -37,6 +39,12 @@ namespace paludis struct default_profile_eapi; struct default_provides_cache; struct default_write_cache; + struct qa_category_dir_checks; + struct qa_eclass_file_contents_checks; + struct qa_package_dir_checks; + struct qa_package_id_checks; + struct qa_package_id_file_contents_checks; + struct qa_tree_checks; } namespace erepository @@ -52,6 +60,12 @@ namespace paludis NamedValue<n::default_profile_eapi, std::string> default_profile_eapi; NamedValue<n::default_provides_cache, std::string> default_provides_cache; NamedValue<n::default_write_cache, std::string> default_write_cache; + NamedValue<n::qa_category_dir_checks, std::tr1::shared_ptr<const Set<std::string> > > qa_category_dir_checks; + NamedValue<n::qa_eclass_file_contents_checks, std::tr1::shared_ptr<const Set<std::string> > > qa_eclass_file_contents_checks; + NamedValue<n::qa_package_dir_checks, std::tr1::shared_ptr<const Set<std::string> > > qa_package_dir_checks; + NamedValue<n::qa_package_id_checks, std::tr1::shared_ptr<const Set<std::string> > > qa_package_id_checks; + NamedValue<n::qa_package_id_file_contents_checks, std::tr1::shared_ptr<const Set<std::string> > > qa_package_id_file_contents_checks; + NamedValue<n::qa_tree_checks, std::tr1::shared_ptr<const Set<std::string> > > qa_tree_checks; }; typedef ExtraDistributionData<EDistribution> EExtraDistributionData; diff --git a/paludis/repositories/e/qa/qa_checks.cc b/paludis/repositories/e/qa/qa_checks.cc index 97e2d4a71..a791fc483 100644 --- a/paludis/repositories/e/qa/qa_checks.cc +++ b/paludis/repositories/e/qa/qa_checks.cc @@ -18,8 +18,11 @@ */ #include <paludis/repositories/e/qa/qa_checks.hh> +#include <paludis/repositories/e/extra_distribution_data.hh> #include <paludis/util/private_implementation_pattern-impl.hh> -#include <paludis/util/instantiation_policy-impl.hh> +#include <paludis/util/wrapped_forward_iterator.hh> +#include <paludis/distribution.hh> +#include <paludis/environment.hh> #include <paludis/repositories/e/qa/stray_files.hh> #include <paludis/repositories/e/qa/manifest.hh> @@ -55,13 +58,12 @@ using namespace paludis; using namespace paludis::erepository; -template class InstantiationPolicy<QAChecks, instantiation_method::SingletonTag>; - namespace paludis { template <> struct Implementation<QAChecks> { + const Environment * const env; const std::tr1::shared_ptr<QAChecksGroup<TreeCheckFunction> > tree_checks_group; const std::tr1::shared_ptr<QAChecksGroup<EclassFileContentsCheckFunction> > eclass_file_contents_checks_group; const std::tr1::shared_ptr<QAChecksGroup<CategoryDirCheckFunction> > category_dir_checks_group; @@ -69,7 +71,8 @@ namespace paludis const std::tr1::shared_ptr<QAChecksGroup<PackageIDCheckFunction> > package_id_checks_group; const std::tr1::shared_ptr<QAChecksGroup<PackageIDFileContentsCheckFunction> > package_id_file_contents_checks_group; - Implementation() : + Implementation(const Environment * const e) : + env(e), tree_checks_group(new QAChecksGroup<TreeCheckFunction>), eclass_file_contents_checks_group(new QAChecksGroup<EclassFileContentsCheckFunction>), category_dir_checks_group(new QAChecksGroup<CategoryDirCheckFunction>), @@ -81,133 +84,197 @@ namespace paludis }; } -QAChecks::QAChecks() : - PrivateImplementationPattern<QAChecks>(new Implementation<QAChecks>()) +QAChecks::QAChecks(const Environment * const env) : + PrivateImplementationPattern<QAChecks>(new Implementation<QAChecks>(env)) { using namespace std::tr1::placeholders; - _imp->tree_checks_group->add_check("stray_tree_files", - std::tr1::bind(stray_files_check, _2, _4, _1, is_stray_at_tree_dir, "stray_tree_files")); - - _imp->tree_checks_group->add_check("repo_name", - std::tr1::bind(repo_name_check, _2, _1, "repo_name")); - - _imp->tree_checks_group->add_check("categories", - std::tr1::bind(categories_check, _2, _4, "categories")); - - _imp->eclass_file_contents_checks_group->add_check("variable_assigns", - std::tr1::bind(variable_assigns_check, _1, _2, std::tr1::shared_ptr<const ERepositoryID>(), _5, "variable_assigns")); - - _imp->eclass_file_contents_checks_group->add_check("deprecated_functions", - std::tr1::bind(deprecated_functions_check, _1, _2, std::tr1::shared_ptr<const ERepositoryID>(), _5, "deprecated_functions")); - - _imp->eclass_file_contents_checks_group->add_check("subshell_die", - std::tr1::bind(subshell_die_check, _1, _2, std::tr1::shared_ptr<const ERepositoryID>(), _5, "subshell_die")); + const std::tr1::shared_ptr<const EDistribution> distribution(EExtraDistributionData::get_instance()->data_from_distribution( + *DistributionData::get_instance()->distribution_from_string(_imp->env->distribution()))); - _imp->eclass_file_contents_checks_group->add_check("header", - std::tr1::bind(header_check, _1, _2, std::tr1::shared_ptr<const ERepositoryID>(), _5, "header")); + if (distribution->qa_tree_checks()->end() != distribution->qa_tree_checks()->find("stray_tree_files")) + _imp->tree_checks_group->add_check("stray_tree_files", + std::tr1::bind(stray_files_check, _2, _4, _1, is_stray_at_tree_dir, "stray_tree_files")); - _imp->eclass_file_contents_checks_group->add_check("function_keyword", - std::tr1::bind(function_keyword_check, _1, _2, std::tr1::shared_ptr<const ERepositoryID>(), _5, "function_keyword")); + if (distribution->qa_tree_checks()->end() != distribution->qa_tree_checks()->find("repo_name")) + _imp->tree_checks_group->add_check("repo_name", + std::tr1::bind(repo_name_check, _2, _1, "repo_name")); - _imp->eclass_file_contents_checks_group->add_check("whitespace", - std::tr1::bind(whitespace_check, _1, _2, std::tr1::shared_ptr<const ERepositoryID>(), _5, "whitespace")); + if (distribution->qa_tree_checks()->end() != distribution->qa_tree_checks()->find("categories")) + _imp->tree_checks_group->add_check("categories", + std::tr1::bind(categories_check, _2, _4, "categories")); - _imp->category_dir_checks_group->add_check("stray_category_dir_files", - std::tr1::bind(stray_files_check, _2, _4, _1, is_stray_at_category_dir, "stray_category_dir_files")); + if (distribution->qa_eclass_file_contents_checks()->end() != distribution->qa_eclass_file_contents_checks()->find("variable_assigns")) + _imp->eclass_file_contents_checks_group->add_check("variable_assigns", + std::tr1::bind(variable_assigns_check, _1, _2, std::tr1::shared_ptr<const ERepositoryID>(), _5, "variable_assigns")); - _imp->package_dir_checks_group->add_check("manifest", - std::tr1::bind(manifest_check, _2, _1, _4, _5, "manifest")); + if (distribution->qa_eclass_file_contents_checks()->end() != distribution->qa_eclass_file_contents_checks()->find("deprecated_functions")) + _imp->eclass_file_contents_checks_group->add_check("deprecated_functions", + std::tr1::bind(deprecated_functions_check, _1, _2, std::tr1::shared_ptr<const ERepositoryID>(), _5, "deprecated_functions")); - _imp->package_dir_checks_group->add_check("ebuild_count", - std::tr1::bind(ebuild_count_check, _2, _1, _4, _5, "ebuild_count")); + if (distribution->qa_eclass_file_contents_checks()->end() != distribution->qa_eclass_file_contents_checks()->find("subshell_die")) + _imp->eclass_file_contents_checks_group->add_check("subshell_die", + std::tr1::bind(subshell_die_check, _1, _2, std::tr1::shared_ptr<const ERepositoryID>(), _5, "subshell_die")); - _imp->package_dir_checks_group->add_check("changelog", - std::tr1::bind(changelog_check, _2, _1, _5, "changelog")); + if (distribution->qa_eclass_file_contents_checks()->end() != distribution->qa_eclass_file_contents_checks()->find("header")) + _imp->eclass_file_contents_checks_group->add_check("header", + std::tr1::bind(header_check, _1, _2, std::tr1::shared_ptr<const ERepositoryID>(), _5, "header")); - _imp->package_dir_checks_group->add_check("misc_files", - std::tr1::bind(misc_files_check, _2, _1, "misc_files")); + if (distribution->qa_eclass_file_contents_checks()->end() != distribution->qa_eclass_file_contents_checks()->find("function_keyword")) + _imp->eclass_file_contents_checks_group->add_check("function_keyword", + std::tr1::bind(function_keyword_check, _1, _2, std::tr1::shared_ptr<const ERepositoryID>(), _5, "function_keyword")); - _imp->package_dir_checks_group->add_check("files_dir_size", - std::tr1::bind(files_dir_size_check, _2, _1, "files_dir_size")); + if (distribution->qa_eclass_file_contents_checks()->end() != distribution->qa_eclass_file_contents_checks()->find("whitespace")) + _imp->eclass_file_contents_checks_group->add_check("whitespace", + std::tr1::bind(whitespace_check, _1, _2, std::tr1::shared_ptr<const ERepositoryID>(), _5, "whitespace")); - _imp->package_id_checks_group->add_check("eapi_supported", - std::tr1::bind(eapi_supported_check, _1, _2, _5, "eapi_supported")); + if (distribution->qa_category_dir_checks()->end() != distribution->qa_category_dir_checks()->find("stray_category_dir_files")) + _imp->category_dir_checks_group->add_check("stray_category_dir_files", + std::tr1::bind(stray_files_check, _2, _4, _1, is_stray_at_category_dir, "stray_category_dir_files")); - _imp->package_id_checks_group->add_check("metadata_keys", - std::tr1::bind(metadata_keys_check, _1, _2, _5, "metadata_keys")); - _imp->package_id_checks_group->add_prerequirement("metadata_keys", "eapi_supported"); + if (distribution->qa_package_dir_checks()->end() != distribution->qa_package_dir_checks()->find("manifest")) + _imp->package_dir_checks_group->add_check("manifest", + std::tr1::bind(manifest_check, _2, _1, _4, _5, "manifest")); - _imp->package_id_checks_group->add_check("short_description_key", - std::tr1::bind(short_description_key_check, _1, _2, _5, "short_description_key")); - _imp->package_id_checks_group->add_prerequirement("short_description_key", "metadata_keys"); + if (distribution->qa_package_dir_checks()->end() != distribution->qa_package_dir_checks()->find("ebuild_count")) + _imp->package_dir_checks_group->add_check("ebuild_count", + std::tr1::bind(ebuild_count_check, _2, _1, _4, _5, "ebuild_count")); - _imp->package_id_checks_group->add_check("homepage_key", - std::tr1::bind(homepage_key_check, _1, _2, _5, "homepage_key")); - _imp->package_id_checks_group->add_prerequirement("homepage_key", "metadata_keys"); + if (distribution->qa_package_dir_checks()->end() != distribution->qa_package_dir_checks()->find("changelog")) + _imp->package_dir_checks_group->add_check("changelog", + std::tr1::bind(changelog_check, _2, _1, _5, "changelog")); - _imp->package_id_checks_group->add_check("iuse_key", - std::tr1::bind(iuse_key_check, _1, _2, _4, _5, "iuse_key")); - _imp->package_id_checks_group->add_prerequirement("iuse_key", "metadata_keys"); + if (distribution->qa_package_dir_checks()->end() != distribution->qa_package_dir_checks()->find("misc_files")) + _imp->package_dir_checks_group->add_check("misc_files", + std::tr1::bind(misc_files_check, _2, _1, "misc_files")); - _imp->package_id_checks_group->add_check("keywords_key", - std::tr1::bind(keywords_key_check, _1, _2, _5, "keywords_key")); - _imp->package_id_checks_group->add_prerequirement("keywords_key", "metadata_keys"); + if (distribution->qa_package_dir_checks()->end() != distribution->qa_package_dir_checks()->find("files_dir_size")) + _imp->package_dir_checks_group->add_check("files_dir_size", + std::tr1::bind(files_dir_size_check, _2, _1, "files_dir_size")); - _imp->package_id_checks_group->add_check("license_key", - std::tr1::bind(license_key_check, _1, _2, _4, _5, "license_key")); - _imp->package_id_checks_group->add_prerequirement("license_key", "metadata_keys"); + if (distribution->qa_package_id_checks()->end() != distribution->qa_package_id_checks()->find("eapi_supported")) + _imp->package_id_checks_group->add_check("eapi_supported", + std::tr1::bind(eapi_supported_check, _1, _2, _5, "eapi_supported")); - _imp->package_id_checks_group->add_check("spec_keys", - std::tr1::bind(spec_keys_check, _1, _2, _5, "spec_keys")); - _imp->package_id_checks_group->add_prerequirement("spec_keys", "metadata_keys"); - - _imp->package_id_checks_group->add_check("extractors", - std::tr1::bind(extractors_check, _1, _2, _5, "extractors")); - _imp->package_id_checks_group->add_prerequirement("extractors", "metadata_keys"); - - _imp->package_id_checks_group->add_check("fetches_key", - std::tr1::bind(fetches_key_check, _1, _2, _5, "fetches_key")); - _imp->package_id_checks_group->add_prerequirement("fetches_key", "metadata_keys"); - - _imp->package_id_checks_group->add_check("restrict_key", - std::tr1::bind(restrict_key_check, _1, _2, _5, "restrict_key")); - _imp->package_id_checks_group->add_prerequirement("restrict_key", "metadata_keys"); + if (distribution->qa_package_id_checks()->end() != distribution->qa_package_id_checks()->find("metadata_keys")) + { + _imp->package_id_checks_group->add_check("metadata_keys", + std::tr1::bind(metadata_keys_check, _1, _2, _5, "metadata_keys")); + _imp->package_id_checks_group->add_prerequirement("metadata_keys", "eapi_supported"); + } - _imp->package_id_checks_group->add_check("inherited_key", - std::tr1::bind(inherited_key_check, _1, _2, _5, "inherited_key")); - _imp->package_id_checks_group->add_prerequirement("inherited_key", "metadata_keys"); + if (distribution->qa_package_id_checks()->end() != distribution->qa_package_id_checks()->find("short_description_key")) + { + _imp->package_id_checks_group->add_check("short_description_key", + std::tr1::bind(short_description_key_check, _1, _2, _5, "short_description_key")); + _imp->package_id_checks_group->add_prerequirement("short_description_key", "metadata_keys"); + } - _imp->package_id_checks_group->add_check("visibility", - std::tr1::bind(visibility_check, _1, _2, _3, _4, _5, "visibility")); - _imp->package_id_checks_group->add_prerequirement("visibility", "metadata_keys"); + if (distribution->qa_package_id_checks()->end() != distribution->qa_package_id_checks()->find("homepage_key")) + { + _imp->package_id_checks_group->add_check("homepage_key", + std::tr1::bind(homepage_key_check, _1, _2, _5, "homepage_key")); + _imp->package_id_checks_group->add_prerequirement("homepage_key", "metadata_keys"); + } - _imp->package_id_file_contents_checks_group->add_check("default_functions", - std::tr1::bind(default_functions_check, _1, _2, _5, _6, "default_functions")); + if (distribution->qa_package_id_checks()->end() != distribution->qa_package_id_checks()->find("iuse_key")) + { + _imp->package_id_checks_group->add_check("iuse_key", + std::tr1::bind(iuse_key_check, _1, _2, _4, _5, "iuse_key")); + _imp->package_id_checks_group->add_prerequirement("iuse_key", "metadata_keys"); + } - _imp->package_id_file_contents_checks_group->add_check("variable_assigns", - std::tr1::bind(variable_assigns_check, _1, _2, _5, _6, "variable_assigns")); + if (distribution->qa_package_id_checks()->end() != distribution->qa_package_id_checks()->find("keywords_key")) + { + _imp->package_id_checks_group->add_check("keywords_key", + std::tr1::bind(keywords_key_check, _1, _2, _5, "keywords_key")); + _imp->package_id_checks_group->add_prerequirement("keywords_key", "metadata_keys"); + } - _imp->package_id_file_contents_checks_group->add_check("deprecated_functions", - std::tr1::bind(deprecated_functions_check, _1, _2, _5, _6, "deprecated_functions")); + if (distribution->qa_package_id_checks()->end() != distribution->qa_package_id_checks()->find("license_key")) + { + _imp->package_id_checks_group->add_check("license_key", + std::tr1::bind(license_key_check, _1, _2, _4, _5, "license_key")); + _imp->package_id_checks_group->add_prerequirement("license_key", "metadata_keys"); + } - _imp->package_id_file_contents_checks_group->add_check("kv_variables", - std::tr1::bind(kv_variables_check, _1, _2, _5, _6, "kv_variables")); + if (distribution->qa_package_id_checks()->end() != distribution->qa_package_id_checks()->find("spec_keys")) + { + _imp->package_id_checks_group->add_check("spec_keys", + std::tr1::bind(spec_keys_check, _1, _2, _5, "spec_keys")); + _imp->package_id_checks_group->add_prerequirement("spec_keys", "metadata_keys"); + } - _imp->package_id_file_contents_checks_group->add_check("root_variable", - std::tr1::bind(root_variable_check, _1, _2, _5, _6, "root_variable")); + if (distribution->qa_package_id_checks()->end() != distribution->qa_package_id_checks()->find("extractors")) + { + _imp->package_id_checks_group->add_check("extractors", + std::tr1::bind(extractors_check, _1, _2, _5, "extractors")); + _imp->package_id_checks_group->add_prerequirement("extractors", "metadata_keys"); + } - _imp->package_id_file_contents_checks_group->add_check("subshell_die", - std::tr1::bind(subshell_die_check, _1, _2, _5, _6, "subshell_die")); + if (distribution->qa_package_id_checks()->end() != distribution->qa_package_id_checks()->find("fetches_key")) + { + _imp->package_id_checks_group->add_check("fetches_key", + std::tr1::bind(fetches_key_check, _1, _2, _5, "fetches_key")); + _imp->package_id_checks_group->add_prerequirement("fetches_key", "metadata_keys"); + } - _imp->package_id_file_contents_checks_group->add_check("function_keyword", - std::tr1::bind(function_keyword_check, _1, _2, _5, _6, "function_keyword")); + if (distribution->qa_package_id_checks()->end() != distribution->qa_package_id_checks()->find("restrict_key")) + { + _imp->package_id_checks_group->add_check("restrict_key", + std::tr1::bind(restrict_key_check, _1, _2, _5, "restrict_key")); + _imp->package_id_checks_group->add_prerequirement("restrict_key", "metadata_keys"); + } - _imp->package_id_file_contents_checks_group->add_check("whitespace", - std::tr1::bind(whitespace_check, _1, _2, _5, _6, "whitespace")); + if (distribution->qa_package_id_checks()->end() != distribution->qa_package_id_checks()->find("inherited_key")) + { + _imp->package_id_checks_group->add_check("inherited_key", + std::tr1::bind(inherited_key_check, _1, _2, _5, "inherited_key")); + _imp->package_id_checks_group->add_prerequirement("inherited_key", "metadata_keys"); + } - _imp->package_id_file_contents_checks_group->add_check("header", - std::tr1::bind(header_check, _1, _2, _5, _6, "header")); + if (distribution->qa_package_id_checks()->end() != distribution->qa_package_id_checks()->find("visibility")) + { + _imp->package_id_checks_group->add_check("visibility", + std::tr1::bind(visibility_check, _1, _2, _3, _4, _5, "visibility")); + _imp->package_id_checks_group->add_prerequirement("visibility", "metadata_keys"); + } + + if (distribution->qa_package_id_file_contents_checks()->end() != distribution->qa_package_id_file_contents_checks()->find("default_functions")) + _imp->package_id_file_contents_checks_group->add_check("default_functions", + std::tr1::bind(default_functions_check, _1, _2, _5, _6, "default_functions")); + + if (distribution->qa_package_id_file_contents_checks()->end() != distribution->qa_package_id_file_contents_checks()->find("variable_assigns")) + _imp->package_id_file_contents_checks_group->add_check("variable_assigns", + std::tr1::bind(variable_assigns_check, _1, _2, _5, _6, "variable_assigns")); + + if (distribution->qa_package_id_file_contents_checks()->end() != distribution->qa_package_id_file_contents_checks()->find("deprecated_functions")) + _imp->package_id_file_contents_checks_group->add_check("deprecated_functions", + std::tr1::bind(deprecated_functions_check, _1, _2, _5, _6, "deprecated_functions")); + + if (distribution->qa_package_id_file_contents_checks()->end() != distribution->qa_package_id_file_contents_checks()->find("kv_variables")) + _imp->package_id_file_contents_checks_group->add_check("kv_variables", + std::tr1::bind(kv_variables_check, _1, _2, _5, _6, "kv_variables")); + + if (distribution->qa_package_id_file_contents_checks()->end() != distribution->qa_package_id_file_contents_checks()->find("root_variable")) + _imp->package_id_file_contents_checks_group->add_check("root_variable", + std::tr1::bind(root_variable_check, _1, _2, _5, _6, "root_variable")); + + if (distribution->qa_package_id_file_contents_checks()->end() != distribution->qa_package_id_file_contents_checks()->find("subshell_die")) + _imp->package_id_file_contents_checks_group->add_check("subshell_die", + std::tr1::bind(subshell_die_check, _1, _2, _5, _6, "subshell_die")); + + if (distribution->qa_package_id_file_contents_checks()->end() != distribution->qa_package_id_file_contents_checks()->find("function_keyword")) + _imp->package_id_file_contents_checks_group->add_check("function_keyword", + std::tr1::bind(function_keyword_check, _1, _2, _5, _6, "function_keyword")); + + if (distribution->qa_package_id_file_contents_checks()->end() != distribution->qa_package_id_file_contents_checks()->find("whitespace")) + _imp->package_id_file_contents_checks_group->add_check("whitespace", + std::tr1::bind(whitespace_check, _1, _2, _5, _6, "whitespace")); + + if (distribution->qa_package_id_file_contents_checks()->end() != distribution->qa_package_id_file_contents_checks()->find("header")) + _imp->package_id_file_contents_checks_group->add_check("header", + std::tr1::bind(header_check, _1, _2, _5, _6, "header")); } QAChecks::~QAChecks() diff --git a/paludis/repositories/e/qa/qa_checks.hh b/paludis/repositories/e/qa/qa_checks.hh index 073c48725..32cdb54b5 100644 --- a/paludis/repositories/e/qa/qa_checks.hh +++ b/paludis/repositories/e/qa/qa_checks.hh @@ -22,7 +22,6 @@ #include <paludis/util/attributes.hh> #include <paludis/util/private_implementation_pattern.hh> -#include <paludis/util/instantiation_policy.hh> #include <paludis/util/fs_entry-fwd.hh> #include <paludis/environment-fwd.hh> @@ -89,16 +88,12 @@ namespace paludis )> PackageIDFileContentsCheckFunction; class QAChecks : - private PrivateImplementationPattern<QAChecks>, - public InstantiationPolicy<QAChecks, instantiation_method::SingletonTag> + private PrivateImplementationPattern<QAChecks> { - friend class InstantiationPolicy<QAChecks, instantiation_method::SingletonTag>; - - private: - QAChecks(); + public: + QAChecks(const Environment * const); ~QAChecks(); - public: const std::tr1::shared_ptr<QAChecksGroup<TreeCheckFunction> > tree_checks_group() PALUDIS_ATTRIBUTE((warn_unused_result)); diff --git a/paludis/repositories/e/qa/qa_controller.cc b/paludis/repositories/e/qa/qa_controller.cc index 66dfda199..f75bc8508 100644 --- a/paludis/repositories/e/qa/qa_controller.cc +++ b/paludis/repositories/e/qa/qa_controller.cc @@ -114,6 +114,8 @@ namespace paludis ThreadSafeQAReporter reporter; const FSEntry base_dir; + QAChecks qa_checks; + std::set<CategoryNamePart> cats_pool; std::set<QualifiedPackageName> pkgs_pool; Mutex pools_mutex; @@ -133,7 +135,8 @@ namespace paludis ignore_unless(u), minimum_level(m), reporter(q), - base_dir(d.realpath()) + base_dir(d.realpath()), + qa_checks(e) { } }; @@ -235,8 +238,8 @@ QAController::_check_eclasses(const FSEntry & dir, const std::string & type) "Couldn't get file contents for " + type.substr(1) + " '" + stringify(*it) + ")")); else std::find_if( - QAChecks::get_instance()->eclass_file_contents_checks_group()->begin(), - QAChecks::get_instance()->eclass_file_contents_checks_group()->end(), + _imp->qa_checks.eclass_file_contents_checks_group()->begin(), + _imp->qa_checks.eclass_file_contents_checks_group()->end(), std::tr1::bind(std::equal_to<bool>(), false, std::tr1::bind<bool>(std::tr1::mem_fn(&EclassFileContentsCheckFunction::operator() ), _1, *it, std::tr1::ref(_imp->reporter), @@ -268,8 +271,8 @@ QAController::_check_category(const CategoryNamePart c, const std::tr1::shared_p { using namespace std::tr1::placeholders; std::find_if( - QAChecks::get_instance()->category_dir_checks_group()->begin(), - QAChecks::get_instance()->category_dir_checks_group()->end(), + _imp->qa_checks.category_dir_checks_group()->begin(), + _imp->qa_checks.category_dir_checks_group()->end(), std::tr1::bind(std::equal_to<bool>(), false, std::tr1::bind<bool>(std::tr1::mem_fn(&CategoryDirCheckFunction::operator() ), _1, _imp->repo->layout()->category_directory(c), std::tr1::ref(_imp->reporter), @@ -321,8 +324,8 @@ QAController::_check_package(const QualifiedPackageName p) if (_above_base_dir(p_dir) || _under_base_dir(p_dir)) { std::find_if( - QAChecks::get_instance()->package_dir_checks_group()->begin(), - QAChecks::get_instance()->package_dir_checks_group()->end(), + _imp->qa_checks.package_dir_checks_group()->begin(), + _imp->qa_checks.package_dir_checks_group()->end(), std::tr1::bind(std::equal_to<bool>(), false, std::tr1::bind<bool>(std::tr1::mem_fn(&PackageDirCheckFunction::operator()), _1, _imp->repo->layout()->package_directory(p), @@ -349,8 +352,8 @@ QAController::_check_id(const std::tr1::shared_ptr<const PackageID> & i) if (_under_base_dir(p_dir)) { std::find_if( - QAChecks::get_instance()->package_id_checks_group()->begin(), - QAChecks::get_instance()->package_id_checks_group()->end(), + _imp->qa_checks.package_id_checks_group()->begin(), + _imp->qa_checks.package_id_checks_group()->end(), std::tr1::bind(std::equal_to<bool>(), false, std::tr1::bind<bool>(std::tr1::mem_fn(&PackageIDCheckFunction::operator() ), _1, i->fs_location_key()->value(), std::tr1::ref(_imp->reporter), @@ -366,8 +369,8 @@ QAController::_check_id(const std::tr1::shared_ptr<const PackageID> & i) .with_associated_key(i, i->fs_location_key())); else std::find_if( - QAChecks::get_instance()->package_id_file_contents_checks_group()->begin(), - QAChecks::get_instance()->package_id_file_contents_checks_group()->end(), + _imp->qa_checks.package_id_file_contents_checks_group()->begin(), + _imp->qa_checks.package_id_file_contents_checks_group()->end(), std::tr1::bind(std::equal_to<bool>(), false, std::tr1::bind<bool>(std::tr1::mem_fn(&PackageIDFileContentsCheckFunction::operator() ), _1, i->fs_location_key()->value(), std::tr1::ref(_imp->reporter), @@ -395,10 +398,10 @@ QAController::run() try { if (_under_base_dir(_imp->repo->params().location)) - if (QAChecks::get_instance()->tree_checks_group()->end() != + if (_imp->qa_checks.tree_checks_group()->end() != std::find_if( - QAChecks::get_instance()->tree_checks_group()->begin(), - QAChecks::get_instance()->tree_checks_group()->end(), + _imp->qa_checks.tree_checks_group()->begin(), + _imp->qa_checks.tree_checks_group()->end(), std::tr1::bind(std::equal_to<bool>(), false, std::tr1::bind<bool>(std::tr1::mem_fn(&TreeCheckFunction::operator() ), _1, _imp->repo->params().location, std::tr1::ref(_imp->reporter), |