commit: 7a16c107438b06888dfee938ba0bcdd01dadef1a Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org> AuthorDate: Fri Jan 8 08:46:01 2016 +0000 Commit: Brian Dolbec <dolsen <AT> gentoo <DOT> org> CommitDate: Thu Jan 21 00:35:22 2016 +0000 URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=7a16c107
repoman: Create RubyEclassChecks class plugin pym/repoman/checks/ebuilds/eclasses/__init__.py | 0 pym/repoman/modules/scan/eclasses/__init__.py | 8 ++++++++ .../{checks/ebuilds => modules/scan}/eclasses/ruby.py | 18 ++++++++++++++---- pym/repoman/scanner.py | 9 ++------- 4 files changed, 24 insertions(+), 11 deletions(-) diff --git a/pym/repoman/checks/ebuilds/eclasses/__init__.py b/pym/repoman/checks/ebuilds/eclasses/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/pym/repoman/modules/scan/eclasses/__init__.py b/pym/repoman/modules/scan/eclasses/__init__.py index a821f5c..70a6252 100644 --- a/pym/repoman/modules/scan/eclasses/__init__.py +++ b/pym/repoman/modules/scan/eclasses/__init__.py @@ -18,6 +18,14 @@ module_spec = { 'func_kwargs': { }, }, + 'ruby-module': { + 'name': "ruby", + 'class': "RubyEclassChecks", + 'description': doc, + 'functions': ['check'], + 'func_kwargs': { + }, + }, } } diff --git a/pym/repoman/checks/ebuilds/eclasses/ruby.py b/pym/repoman/modules/scan/eclasses/ruby.py similarity index 62% rename from pym/repoman/checks/ebuilds/eclasses/ruby.py rename to pym/repoman/modules/scan/eclasses/ruby.py index e8d36ea..4dc5d62 100644 --- a/pym/repoman/checks/ebuilds/eclasses/ruby.py +++ b/pym/repoman/modules/scan/eclasses/ruby.py @@ -4,19 +4,23 @@ Performs Ruby eclass checks ''' from repoman.qa_data import ruby_deprecated +from repoman.modules.scan.scanbase import ScanBase -class RubyEclassChecks(object): +class RubyEclassChecks(ScanBase): '''Performs checks for the usage of Ruby eclasses in ebuilds''' - def __init__(self, qatracker): + def __init__(self, **kwargs): ''' @param qatracker: QATracker instance ''' - self.qatracker = qatracker + super(RubyEclassChecks, self).__init__(**kwargs) + self.qatracker = kwargs.get('qatracker') self.old_ruby_eclasses = ["ruby-ng", "ruby-fakegem", "ruby"] - def check(self, pkg, ebuild): + def check(self, **kwargs): + pkg = kwargs.get('pkg') + ebuild = kwargs.get('ebuild') is_inherited = lambda eclass: eclass in pkg.inherited is_old_ruby_eclass_inherited = filter( is_inherited, self.old_ruby_eclasses) @@ -30,3 +34,9 @@ class RubyEclassChecks(object): "IUSE.rubydeprecated", (ebuild.relative_path + ": Deprecated ruby target: %s") % myruby) + return {'continue': False} + + @property + def runInEbuilds(self): + '''Ebuild level scans''' + return (True, [self.check]) diff --git a/pym/repoman/scanner.py b/pym/repoman/scanner.py index 0227a93..e6a17cd 100644 --- a/pym/repoman/scanner.py +++ b/pym/repoman/scanner.py @@ -18,7 +18,6 @@ from portage import _unicode_encode from portage.dep import Atom from portage.output import green from repoman.checks.ebuilds.checks import run_checks -from repoman.checks.ebuilds.eclasses.ruby import RubyEclassChecks from repoman.checks.ebuilds.variables.license import LicenseChecks from repoman.checks.ebuilds.variables.restrict import RestrictChecks from repoman.modules.commit import repochecks @@ -211,7 +210,6 @@ class Scanner(object): self.modules[mod_class.__name__] = mod_class(**self.kwargs) # initialize our checks classes here before the big xpkg loop - self.rubyeclasscheck = RubyEclassChecks(self.qatracker) self.licensecheck = LicenseChecks(self.qatracker, liclist, liclist_deprecated) self.restrictcheck = RestrictChecks(self.qatracker) @@ -298,7 +296,7 @@ class Scanner(object): ('thirdpartymirrors', 'ThirdPartyMirrors'), ('description', 'DescriptionChecks'), (None, 'KeywordChecks'), ('arches', 'ArchChecks'), ('depend', 'DependChecks'), - ('use_flags', 'USEFlagChecks'), + ('use_flags', 'USEFlagChecks'), ('ruby', 'RubyEclassChecks'), ]: if mod[0]: mod_class = MODULE_CONTROLLER.get_class(mod[0]) @@ -361,9 +359,7 @@ class Scanner(object): badlicsyntax = badlicsyntax > 0 badprovsyntax = badprovsyntax > 0 - used_useflags = used_useflags.union(dynamic_data['ebuild_used_useflags']) - - self.rubyeclasscheck.check(dynamic_data['pkg'], dynamic_data['ebuild']) + used_useflags = used_useflags.union(dynamic_data['ebuild_UsedUseFlags']) # license checks if not badlicsyntax: @@ -573,7 +569,6 @@ class Scanner(object): # check if there are unused local USE-descriptions in metadata.xml # (unless there are any invalids, to avoid noise) - for myflag in dynamic_data['muselist'].difference(used_useflags): if dynamic_data['allvalid']: for myflag in dynamic_data['muselist'].difference(used_useflags): self.qatracker.add_error(