public inbox for gentoo-portage-dev@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-portage-dev] [PATCH v3] Add repoman check to warn if src_prepare/src_configure are used in EAPI 0/1 and if pkg_pretend is used in EAPI < 4. Fixes bug 379491.
@ 2014-01-15 21:03 Chris Reffett
  2014-01-15 21:11 ` Sebastian Luther
  0 siblings, 1 reply; 2+ messages in thread
From: Chris Reffett @ 2014-01-15 21:03 UTC (permalink / raw
  To: gentoo-portage-dev

---
 pym/repoman/checks.py | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)

Ignore v2, I apparently didn't commit all of my changes and so that patch
won't work. Undid the compression of the src_prepare/src_configure regex,
because the way that the regex is set up means that it would output "prepare
phase is not defined in EAPI..." instead of "src_prepare" and I feel that
it's more intuitive to match the full name of the function instead of tacking
src_ in front of the output.


diff --git a/pym/repoman/checks.py b/pym/repoman/checks.py
index 85aa065..c6860d8 100644
--- a/pym/repoman/checks.py
+++ b/pym/repoman/checks.py
@@ -731,6 +731,21 @@ class DeprecatedHasq(LineCheck):
 	re = re.compile(r'(^|.*\b)hasq\b')
 	error = errors.HASQ_ERROR
 
+# EAPI <2 checks
+class Eapi01UndefinedPhases(LineCheck):
+	repoman_check_name = 'EAPI.incompatible'
+	src_configprepare_re = re.compile(r'\s*(src_configure|src_prepare)\s*\(\)')
+
+	def check_eapi(self, eapi):
+		return eapi in ('0', '1')
+
+	def check(self, num, line):
+		m = self.src_configprepare_re.match(line)
+		if m is not None:
+			return ("'%s'" % m.group(1)) + \
+				" phase is not defined in EAPI < 2 on line: %d"
+
+
 # EAPI-3 checks
 class Eapi3DeprecatedFuncs(LineCheck):
 	repoman_check_name = 'EAPI.deprecated'
@@ -745,6 +760,20 @@ class Eapi3DeprecatedFuncs(LineCheck):
 			return ("'%s'" % m.group(1)) + \
 				" has been deprecated in EAPI=3 on line: %d"
 
+# EAPI <4 checks
+class Eapi0123UndefinedPhases(LineCheck):
+	repoman_check_name = 'EAPI.incompatible'
+	pkg_pretend_re = re.compile(r'\s*(pkg_pretend)\s*\(\)')
+
+	def check_eapi(self, eapi):
+		return eapi in ('0', '1', '2', '3')
+
+	def check(self, num, line):
+		m = self.pkg_pretend_re.match(line)
+		if m is not None:
+			return ("'%s'" % m.group(1)) + \
+				" phase is not defined in EAPI < 4 on line: %d"
+
 # EAPI-4 checks
 class Eapi4IncompatibleFuncs(LineCheck):
 	repoman_check_name = 'EAPI.incompatible'
-- 
1.8.5.1



^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [gentoo-portage-dev] [PATCH v3] Add repoman check to warn if src_prepare/src_configure are used in EAPI 0/1 and if pkg_pretend is used in EAPI < 4. Fixes bug 379491.
  2014-01-15 21:03 [gentoo-portage-dev] [PATCH v3] Add repoman check to warn if src_prepare/src_configure are used in EAPI 0/1 and if pkg_pretend is used in EAPI < 4. Fixes bug 379491 Chris Reffett
@ 2014-01-15 21:11 ` Sebastian Luther
  0 siblings, 0 replies; 2+ messages in thread
From: Sebastian Luther @ 2014-01-15 21:11 UTC (permalink / raw
  To: gentoo-portage-dev

Am 15.01.2014 22:03, schrieb Chris Reffett:
> +	def check_eapi(self, eapi):
> +		return eapi in ('0', '1')
> +

Instead of hard coding EAPIs here, you should use the functions in
portage.eapi like eapi_has_src_prepare_and_src_configure().

Same applies for the later part of the patch.

The class names of the checks have the same issue. I understand that
there are existing checks with such names, but that doesn't mean that's
a good idea to keep using them.
You could name them after the phases you're checking for.

Sebastian


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2014-01-15 21:12 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-01-15 21:03 [gentoo-portage-dev] [PATCH v3] Add repoman check to warn if src_prepare/src_configure are used in EAPI 0/1 and if pkg_pretend is used in EAPI < 4. Fixes bug 379491 Chris Reffett
2014-01-15 21:11 ` Sebastian Luther

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox