public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Brian Dolbec" <dolsen@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/portage:repoman commit in: repoman/pym/repoman/modules/linechecks/useless/
Date: Sat, 15 Jul 2017 02:08:48 +0000 (UTC)	[thread overview]
Message-ID: <1500084508.c53c37c1f9c609837073600709a153779120238a.dolsen@gentoo> (raw)

commit:     c53c37c1f9c609837073600709a153779120238a
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Sat Jul 15 01:06:38 2017 +0000
Commit:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Sat Jul 15 02:08:28 2017 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=c53c37c1

repoman: New linechecks module, useless

 .../repoman/modules/linechecks/useless/__init__.py | 27 ++++++++++++++++++++++
 .../pym/repoman/modules/linechecks/useless/cd.py   | 24 +++++++++++++++++++
 .../repoman/modules/linechecks/useless/dodoc.py    | 16 +++++++++++++
 3 files changed, 67 insertions(+)

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"


             reply	other threads:[~2017-07-15  2:09 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-15  2:08 Brian Dolbec [this message]
  -- strict thread matches above, loose matches on Subject: below --
2017-07-15  2:29 [gentoo-commits] proj/portage:repoman commit in: repoman/pym/repoman/modules/linechecks/useless/ Brian Dolbec
2017-09-11 21:43 Brian Dolbec
2017-11-26 17:46 Brian Dolbec
2017-12-05 18:32 Brian Dolbec
2017-12-06  0:16 Brian Dolbec
2018-03-29 21:35 Brian Dolbec
2018-03-30  0:48 Brian Dolbec
2018-03-30  5:20 Zac Medico

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1500084508.c53c37c1f9c609837073600709a153779120238a.dolsen@gentoo \
    --to=dolsen@gentoo.org \
    --cc=gentoo-commits@lists.gentoo.org \
    --cc=gentoo-dev@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox