[namcap] Don't report missing-vcs-makedeps when it is in depends

Message ID 20200317093044.3789897-1-felixonmars@archlinux.org
State New
Headers show
Series
  • [namcap] Don't report missing-vcs-makedeps when it is in depends
Related show

Commit Message

Michael Straube via arch-projects March 17, 2020, 9:30 a.m. UTC
Currently a PKGBUILD warning is shown when the package depends on git
instead of makedepends on it. Since we also have the redundant_makedepends
rule we should not write it again in makedepends. This patch checkes depends
array too so this warning could be suppressed.
---
 Namcap/rules/makedepends.py               | 2 ++
 Namcap/tests/pkgbuild/test_makedepends.py | 8 ++++++++
 2 files changed, 10 insertions(+)

Comments

Michael Straube via arch-projects April 11, 2020, 8:41 a.m. UTC | #1
> Currently a PKGBUILD warning is shown when the package depends on git
> instead of makedepends on it. Since we also have the redundant_makedepends
> rule we should not write it again in makedepends. This patch checkes depends
> array too so this warning could be suppressed.
> ---
>  Namcap/rules/makedepends.py               | 2 ++
>  Namcap/tests/pkgbuild/test_makedepends.py | 8 ++++++++
>  2 files changed, 10 insertions(+)
> 
> diff --git a/Namcap/rules/makedepends.py b/Namcap/rules/makedepends.py
> index 53676c2..8b938a0 100644
> --- a/Namcap/rules/makedepends.py
> +++ b/Namcap/rules/makedepends.py
> @@ -68,6 +68,8 @@ class VCSMakedepends(PkgbuildRule):
>  
>  		for v in protocols:
>  			d = vcs[v]
> +			if 'depends' in pkginfo and d in pkginfo["depends"]:
> +				continue
>  			if 'makedepends' not in pkginfo:
>  				missing.append(d)
>  				continue
> diff --git a/Namcap/tests/pkgbuild/test_makedepends.py b/Namcap/tests/pkgbuild/test_makedepends.py
> index d443b2b..73a3ba2 100644
> --- a/Namcap/tests/pkgbuild/test_makedepends.py
> +++ b/Namcap/tests/pkgbuild/test_makedepends.py
> @@ -111,4 +111,12 @@ package() {
>  		self.assertEqual(r.warnings, [])
>  		self.assertEqual(r.infos, [])
>  
> +	def test_example3(self):
> +		# Example 3
> +		r = self.run_on_pkg(self.pkgbuild1 + 'depends=(bzr git mercurial)')

Package 'bzr' was replaced with 'breezy' in commit 28fdd26b77ac.

		r = self.run_on_pkg(self.pkgbuild1 + 'depends=(breezy git mercurial)')

> +		self.assertEqual(r.errors, [])
> +		self.assertEqual(r.warnings,
> +			[("missing-vcs-makedeps %s", 'subversion')])
> +		self.assertEqual(r.infos, [])
> +
>  # vim: set ts=4 sw=4 noet:
> -- 
> 2.25.1

Patch

diff --git a/Namcap/rules/makedepends.py b/Namcap/rules/makedepends.py
index 53676c2..8b938a0 100644
--- a/Namcap/rules/makedepends.py
+++ b/Namcap/rules/makedepends.py
@@ -68,6 +68,8 @@  class VCSMakedepends(PkgbuildRule):
 
 		for v in protocols:
 			d = vcs[v]
+			if 'depends' in pkginfo and d in pkginfo["depends"]:
+				continue
 			if 'makedepends' not in pkginfo:
 				missing.append(d)
 				continue
diff --git a/Namcap/tests/pkgbuild/test_makedepends.py b/Namcap/tests/pkgbuild/test_makedepends.py
index d443b2b..73a3ba2 100644
--- a/Namcap/tests/pkgbuild/test_makedepends.py
+++ b/Namcap/tests/pkgbuild/test_makedepends.py
@@ -111,4 +111,12 @@  package() {
 		self.assertEqual(r.warnings, [])
 		self.assertEqual(r.infos, [])
 
+	def test_example3(self):
+		# Example 3
+		r = self.run_on_pkg(self.pkgbuild1 + 'depends=(bzr git mercurial)')
+		self.assertEqual(r.errors, [])
+		self.assertEqual(r.warnings,
+			[("missing-vcs-makedeps %s", 'subversion')])
+		self.assertEqual(r.infos, [])
+
 # vim: set ts=4 sw=4 noet: