aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrian Dolbec <dolsen@gentoo.org>2017-07-15 01:06:38 +0000
committerZac Medico <zmedico@gentoo.org>2018-03-29 20:51:19 -0700
commit340283538afc734790341c78a09742bcd0fc1009 (patch)
treecf6c95106b6273273b2c643e20782faea3c65ad2
parentrepoman: New linechecks module, use (diff)
downloadportage-340283538afc734790341c78a09742bcd0fc1009.tar.gz
portage-340283538afc734790341c78a09742bcd0fc1009.tar.bz2
portage-340283538afc734790341c78a09742bcd0fc1009.zip
repoman: New linechecks module, useless
-rw-r--r--repoman/pym/repoman/modules/linechecks/useless/__init__.py27
-rw-r--r--repoman/pym/repoman/modules/linechecks/useless/cd.py24
-rw-r--r--repoman/pym/repoman/modules/linechecks/useless/dodoc.py16
3 files changed, 67 insertions, 0 deletions
diff --git a/repoman/pym/repoman/modules/linechecks/useless/__init__.py b/repoman/pym/repoman/modules/linechecks/useless/__init__.py
new file mode 100644
index 000000000..acc4479f5
--- /dev/null
+++ b/repoman/pym/repoman/modules/linechecks/useless/__init__.py
@@ -0,0 +1,27 @@
+# Copyright 2015-2016 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+doc = """Useless plug-in module for repoman LineChecks.
+Performs checks for useless operations on ebuilds."""
+__doc__ = doc[:]
+
+
+module_spec = {
+ 'name': 'do',
+ 'description': doc,
+ 'provides':{
+ 'uselesscds-check': {
+ 'name': "uselesscds",
+ 'sourcefile': "cd",
+ 'class': "EbuildUselessCdS",
+ 'description': doc,
+ },
+ 'uselessdodoc-check': {
+ 'name': "uselessdodoc",
+ 'sourcefile': "dodoc",
+ 'class': "EbuildUselessDodoc",
+ 'description': doc,
+ },
+ }
+}
+
diff --git a/repoman/pym/repoman/modules/linechecks/useless/cd.py b/repoman/pym/repoman/modules/linechecks/useless/cd.py
new file mode 100644
index 000000000..3daa04451
--- /dev/null
+++ b/repoman/pym/repoman/modules/linechecks/useless/cd.py
@@ -0,0 +1,24 @@
+
+import re
+
+from repoman.modules.linechecks.base import LineCheck
+
+
+class EbuildUselessCdS(LineCheck):
+ """Check for redundant cd ${S} statements"""
+ repoman_check_name = 'ebuild.minorsyn'
+ _src_phases = r'^\s*src_(prepare|configure|compile|install|test)\s*\(\)'
+ method_re = re.compile(_src_phases)
+ cds_re = re.compile(r'^\s*cd\s+("\$(\{S\}|S)"|\$(\{S\}|S))\s')
+
+ def __init__(self, errors):
+ self.errors = errors
+ self.check_next_line = False
+
+ def check(self, num, line):
+ if self.check_next_line:
+ self.check_next_line = False
+ if self.cds_re.match(line):
+ return self.errors['REDUNDANT_CD_S_ERROR']
+ elif self.method_re.match(line):
+ self.check_next_line = True
diff --git a/repoman/pym/repoman/modules/linechecks/useless/dodoc.py b/repoman/pym/repoman/modules/linechecks/useless/dodoc.py
new file mode 100644
index 000000000..502bfbea8
--- /dev/null
+++ b/repoman/pym/repoman/modules/linechecks/useless/dodoc.py
@@ -0,0 +1,16 @@
+
+import re
+
+from repoman.modules.linechecks.base import LineCheck
+
+
+class EbuildUselessDodoc(LineCheck):
+ """Check ebuild for useless files in dodoc arguments."""
+ repoman_check_name = 'ebuild.minorsyn'
+ uselessdodoc_re = re.compile(
+ r'^\s*dodoc(\s+|\s+.*\s+)(ABOUT-NLS|COPYING|LICENCE|LICENSE)($|\s)')
+
+ def check(self, num, line):
+ match = self.uselessdodoc_re.match(line)
+ if match:
+ return "Useless dodoc '%s'" % (match.group(2), ) + " on line: %d"