diff options
author | 2024-08-01 22:40:27 +0300 | |
---|---|---|
committer | 2024-08-01 22:40:27 +0300 | |
commit | bd21cbc2b2fa4e7761463136c5aaf88304272e68 (patch) | |
tree | ec4b126f6dc086e7502802fdac7bad7cb5a79cab | |
parent | ci: test on py3.13 (diff) | |
download | pkgcheck-master.tar.gz pkgcheck-master.tar.bz2 pkgcheck-master.zip |
Resolves: https://github.com/pkgcore/pkgcheck/issues/695
Signed-off-by: Arthur Zamarin <arthurzam@gentoo.org>
-rw-r--r-- | src/pkgcheck/checks/codingstyle.py | 9 | ||||
-rw-r--r-- | testdata/data/repos/standalone/MetadataVarCheck/EmptyGlobalAssignment/expected.json | 1 |
2 files changed, 7 insertions, 3 deletions
diff --git a/src/pkgcheck/checks/codingstyle.py b/src/pkgcheck/checks/codingstyle.py index cfc7f8da..42bd0004 100644 --- a/src/pkgcheck/checks/codingstyle.py +++ b/src/pkgcheck/checks/codingstyle.py @@ -634,6 +634,8 @@ class MetadataVarCheck(Check): # mapping between registered variables and verification methods known_variables = {} + empty_vars_whitelist = frozenset({"KEYWORDS"}) + @verify_vars("HOMEPAGE", "KEYWORDS") def _raw_text(self, var, node, value, pkg): matches = [] @@ -710,8 +712,11 @@ class MetadataVarCheck(Check): value_str = self.canonicalize_assign(pkg.node_str(value_node)) if value_node else "" if name in pkg.eapi.eclass_keys: if not value_str: - lineno, _ = node.start_point - yield EmptyGlobalAssignment(line=pkg.node_str(node), lineno=lineno + 1, pkg=pkg) + if name not in self.empty_vars_whitelist: + lineno, _ = node.start_point + yield EmptyGlobalAssignment( + line=pkg.node_str(node), lineno=lineno + 1, pkg=pkg + ) elif pkg.node_str(value_node.prev_sibling) == "=": for var_node, _ in bash.var_query.captures(value_node): if ( diff --git a/testdata/data/repos/standalone/MetadataVarCheck/EmptyGlobalAssignment/expected.json b/testdata/data/repos/standalone/MetadataVarCheck/EmptyGlobalAssignment/expected.json index 7cab9376..c5c90f2d 100644 --- a/testdata/data/repos/standalone/MetadataVarCheck/EmptyGlobalAssignment/expected.json +++ b/testdata/data/repos/standalone/MetadataVarCheck/EmptyGlobalAssignment/expected.json @@ -1,3 +1,2 @@ {"__class__": "EmptyGlobalAssignment", "category": "DescriptionCheck", "package": "BadDescription", "version": "1", "line": "DESCRIPTION=\"\"", "lineno": 1} -{"__class__": "EmptyGlobalAssignment", "category": "MetadataVarCheck", "package": "MultipleKeywordsLines", "version": "0", "line": "KEYWORDS=\"\"", "lineno": 8} {"__class__": "EmptyGlobalAssignment", "category": "MetadataVarCheck", "package": "ReferenceInMetadataVar", "version": "3", "line": "LICENSE=\"\"", "lineno": 4} |