[namcap,1/4] Split warning for non-unique source filenames from pkginfo rules

Message ID 20190527034922.27316-2-jamespharvey20@gmail.com
State New
Headers show
Series Add a rule against common filenames in source() without overridden name | expand

Commit Message

Emil Velikov via arch-projects May 27, 2019, 3:49 a.m. UTC
This was originally here, because it used PkgInfoRule, but was changed to use
PkgbuildRule and was left here.

Signed-off-by: James P. Harvey <jamespharvey20@gmail.com>
---
 Namcap/rules/__init__.py         |  1 +
 Namcap/rules/nonuniquesources.py | 34 ++++++++++++++++++++++++++++++++
 Namcap/rules/pkginfo.py          | 11 +----------
 3 files changed, 36 insertions(+), 10 deletions(-)
 create mode 100644 Namcap/rules/nonuniquesources.py

Patch

diff --git a/Namcap/rules/__init__.py b/Namcap/rules/__init__.py
index dcc950f..111f08b 100644
--- a/Namcap/rules/__init__.py
+++ b/Namcap/rules/__init__.py
@@ -62,6 +62,7 @@  from . import (
   makedepends,
   makepkgfunctions,
   missingvars,
+  nonuniquesources,
   pkginfo,
   pkgnameindesc,
   sfurl,
diff --git a/Namcap/rules/nonuniquesources.py b/Namcap/rules/nonuniquesources.py
new file mode 100644
index 0000000..a16f56e
--- /dev/null
+++ b/Namcap/rules/nonuniquesources.py
@@ -0,0 +1,34 @@ 
+#
+# namcap rules - package variables
+# Copyright (C) 2018 Simon Doppler <dopsi at dopsi dot ch>
+#
+#   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
+#
+
+"These rules checks basic sanity of source files"
+
+import re
+import os
+from Namcap.ruleclass import PkgbuildRule
+
+class nonuniquesources(PkgbuildRule):
+	name = "nonuniquesources"
+	description = "Verifies the downloaded sources have a unique filename"
+	def analyze(self, pkginfo, tar):
+		for source_file in pkginfo["source"]:
+			if '::' not in source_file and re.match(r'^[vV]?(([0-9]){8}|([0-9]+\.?)+)\.', os.path.basename(source_file)):
+				self.warnings.append(("non-unique-source-name %s", os.path.basename(source_file)))
+
+# vim: set ts=4 sw=4 noet:
diff --git a/Namcap/rules/pkginfo.py b/Namcap/rules/pkginfo.py
index 5a42810..216e417 100644
--- a/Namcap/rules/pkginfo.py
+++ b/Namcap/rules/pkginfo.py
@@ -20,8 +20,7 @@ 
 "These rules checks basic sanity of package metadata"
 
 import re
-import os
-from Namcap.ruleclass import PkgInfoRule,PkgbuildRule
+from Namcap.ruleclass import PkgInfoRule
 
 class CapsPkgnameRule(PkgInfoRule):
 	name = "capsnamespkg"
@@ -44,12 +43,4 @@  class LicenseRule(PkgInfoRule):
 		if "license" not in pkginfo or len(pkginfo["license"]) == 0:
 			self.errors.append(("missing-license", ()))
 
-class NonUniqueSourcesRule(PkgbuildRule):
-	name = "non-unique-source"
-	description = "Verifies the downloaded sources have a unique filename"
-	def analyze(self, pkginfo, tar):
-		for source_file in pkginfo["source"]:
-			if '::' not in source_file and re.match(r'^[vV]?(([0-9]){8}|([0-9]+\.?)+)\.', os.path.basename(source_file)):
-				self.warnings.append(("non-unique-source-name %s", os.path.basename(source_file)))
-
 # vim: set ts=4 sw=4 noet: