[arch-projects] [namcap] [PATCH v2 2/3] Add test for the makedepends rule

2018-11-25 Thread Michael Straube via arch-projects
Signed-off-by: Michael Straube 
---
 Namcap/tests/pkgbuild/test_makedepends.py | 65 +++
 1 file changed, 65 insertions(+)
 create mode 100644 Namcap/tests/pkgbuild/test_makedepends.py

diff --git a/Namcap/tests/pkgbuild/test_makedepends.py 
b/Namcap/tests/pkgbuild/test_makedepends.py
new file mode 100644
index 000..c8d6e97
--- /dev/null
+++ b/Namcap/tests/pkgbuild/test_makedepends.py
@@ -0,0 +1,65 @@
+# -*- coding: utf-8 -*-
+#
+# namcap tests - makedepends
+# Copyright (C) 2011 Rémy Oudompheng 
+#
+#   This program is free software; you can redistribute it and/or modify
+#   it under the terms of the GNU General Public License as published by
+#   the Free Software Foundation; either version 2 of the License, or
+#   (at your option) any later version.
+#
+#   This program is distributed in the hope that it will be useful,
+#   but WITHOUT ANY WARRANTY; without even the implied warranty of
+#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#   GNU General Public License for more details.
+#
+#   You should have received a copy of the GNU General Public License
+#   along with this program; if not, write to the Free Software
+#   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
+#   USA
+#
+
+from Namcap.tests.pkgbuild_test import PkgbuildTest
+import Namcap.rules.makedepends as module
+
+class NamcapRedundantMakedependsTest(PkgbuildTest):
+   pkgbuild1 = """
+# Maintainer: Arch Linux 
+# Contributor: Arch Linux 
+
+pkgname=mypackage
+pkgver=1.0
+pkgrel=1
+pkgdesc="A package"
+url="http://www.example.com/;
+arch=('i686' 'x86_64')
+depends=('lib1' 'lib2' 'lib3')
+makedepends=('lib1' 'lib2' 'lib4')
+license=('GPL')
+options=('!libtool')
+source=(ftp://ftp.example.com/pub/mypackage-0.1.tar.gz)
+md5sums=('abcdefabcdef12345678901234567890')
+
+build() {
+  true
+}
+
+package() {
+  true
+}
+"""
+
+   test_valid = PkgbuildTest.valid_tests
+
+   def preSetUp(self):
+   self.rule = module.RedundantMakedepends
+
+   def test_example1(self):
+   # Example 1
+   r = self.run_on_pkg(self.pkgbuild1)
+   self.assertEqual(r.errors, [])
+   self.assertEqual(set(r.warnings),
+   set(("redundant-makedep %s", i) for i in ["lib1" 
,"lib2"]))
+   self.assertEqual(r.infos, [])
+
+# vim: set ts=4 sw=4 noet:
-- 
2.19.2


[arch-projects] [namcap] [PATCH v2 1/3] Warn about makedepends already in depends

2018-11-25 Thread Michael Straube via arch-projects
Add a rule that warns about make dependencies already listed as
dependencies.

Signed-off-by: Michael Straube 
---
v1 -> v2
Added patch that implements FS#58303
Warn about missing VCS make dependencies.

 Namcap/rules/__init__.py|  1 +
 Namcap/rules/makedepends.py | 41 +
 namcap-tags |  1 +
 3 files changed, 43 insertions(+)
 create mode 100644 Namcap/rules/makedepends.py

diff --git a/Namcap/rules/__init__.py b/Namcap/rules/__init__.py
index e8775a0..dcc950f 100644
--- a/Namcap/rules/__init__.py
+++ b/Namcap/rules/__init__.py
@@ -59,6 +59,7 @@ from . import (
   carch,
   extravars,
   invalidstartdir,
+  makedepends,
   makepkgfunctions,
   missingvars,
   pkginfo,
diff --git a/Namcap/rules/makedepends.py b/Namcap/rules/makedepends.py
new file mode 100644
index 000..48b1049
--- /dev/null
+++ b/Namcap/rules/makedepends.py
@@ -0,0 +1,41 @@
+#
+# namcap rules - makedepends
+# Copyright (C) 2018 Michael Straube 
+#
+#   This program is free software; you can redistribute it and/or modify
+#   it under the terms of the GNU General Public License as published by
+#   the Free Software Foundation; either version 2 of the License, or
+#   (at your option) any later version.
+#
+#   This program is distributed in the hope that it will be useful,
+#   but WITHOUT ANY WARRANTY; without even the implied warranty of
+#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#   GNU General Public License for more details.
+#
+#   You should have received a copy of the GNU General Public License
+#   along with this program; if not, write to the Free Software
+#   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+#
+
+from Namcap.ruleclass import *
+
+class RedundantMakedepends(PkgbuildRule):
+   """
+   This rule checks for make dependencies that are already
+   included as dependencies.
+   """
+   name = "makedepends"
+   description = "Check for redundant make dependencies"
+
+   def analyze(self, pkginfo, pkgbuild):
+   redundant_makedeps = []
+
+   if 'makedepends' in pkginfo and 'depends' in pkginfo:
+   for d in pkginfo["makedepends"]:
+   if d in pkginfo["depends"]:
+   redundant_makedeps.append(d)
+
+   for i in redundant_makedeps:
+   self.warnings.append(("redundant-makedep %s", i))
+
+# vim: set ts=4 sw=4 noet:
diff --git a/namcap-tags b/namcap-tags
index 2133c45..c253042 100644
--- a/namcap-tags
+++ b/namcap-tags
@@ -71,6 +71,7 @@ potential-non-fhs-man-page %s :: Potential non-FHS man page 
(%s) found.
 py-mtime-mtree-warning :: Found .py file unnoticeably newer than associated 
.pyc/pyo.
 py-mtime-tar-error :: Found .py file newer than associated .pyc/pyo.
 py-mtime-file-name %s :: Python script (%s) is newer than associated .pyc/pyo.
+redundant-makedep %s :: Make dependency (%s) already included as dependency
 script-link-detected %s in %s :: Script link detected (%s) in file %s
 scrollkeeper-dir-exists %s :: Scrollkeeper directory exists (%s). Remember to 
not run scrollkeeper till post_{install,upgrade,remove}.
 site-ruby :: Found usr/lib/ruby/site_ruby in package, usr/lib/ruby/vendor_ruby 
should be used instead.
-- 
2.19.2