commit:     4a63297643accd75971622000f15613200501081
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Sat Jul 15 01:02:24 2017 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Fri Mar 30 03:51:18 2018 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=4a632976

repoman: New linechecks module, nested

 .../repoman/modules/linechecks/nested/__init__.py   | 21 +++++++++++++++++++++
 .../pym/repoman/modules/linechecks/nested/nested.py | 15 +++++++++++++++
 .../repoman/modules/linechecks/nested/nesteddie.py  | 11 +++++++++++
 3 files changed, 47 insertions(+)

diff --git a/repoman/pym/repoman/modules/linechecks/nested/__init__.py 
b/repoman/pym/repoman/modules/linechecks/nested/__init__.py
new file mode 100644
index 000000000..8eeeccbac
--- /dev/null
+++ b/repoman/pym/repoman/modules/linechecks/nested/__init__.py
@@ -0,0 +1,21 @@
+# Copyright 2015-2016 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+doc = """Nested plug-in module for repoman LineChecks.
+Performs nested subshell checks on ebuilds."""
+__doc__ = doc[:]
+
+
+module_spec = {
+       'name': 'do',
+       'description': doc,
+       'provides':{
+               'nesteddie-check': {
+                       'name': "nesteddie",
+                       'sourcefile': "nested",
+                       'class': "EbuildNestedDie",
+                       'description': doc,
+               },
+       }
+}
+

diff --git a/repoman/pym/repoman/modules/linechecks/nested/nested.py 
b/repoman/pym/repoman/modules/linechecks/nested/nested.py
new file mode 100644
index 000000000..06b272772
--- /dev/null
+++ b/repoman/pym/repoman/modules/linechecks/nested/nested.py
@@ -0,0 +1,15 @@
+
+import re
+
+from repoman.modules.linechecks.base import LineCheck
+
+
+class EbuildNestedDie(LineCheck):
+       """Check ebuild for nested die statements (die statements in 
subshells)"""
+
+       repoman_check_name = 'ebuild.nesteddie'
+       nesteddie_re = re.compile(r'^[^#]*\s\(\s[^)]*\bdie\b')
+
+       def check(self, num, line):
+               if self.nesteddie_re.match(line):
+                       return self.errors['NESTED_DIE_ERROR']

diff --git a/repoman/pym/repoman/modules/linechecks/nested/nesteddie.py 
b/repoman/pym/repoman/modules/linechecks/nested/nesteddie.py
new file mode 100644
index 000000000..6c1e4be9f
--- /dev/null
+++ b/repoman/pym/repoman/modules/linechecks/nested/nesteddie.py
@@ -0,0 +1,11 @@
+
+
+class EbuildNestedDie(LineCheck):
+       """Check ebuild for nested die statements (die statements in 
subshells)"""
+
+       repoman_check_name = 'ebuild.nesteddie'
+       nesteddie_re = re.compile(r'^[^#]*\s\(\s[^)]*\bdie\b')
+
+       def check(self, num, line):
+               if self.nesteddie_re.match(line):
+                       return errors.NESTED_DIE_ERROR

Reply via email to