diff options
author | Arthur Zamarin <arthurzam@gentoo.org> | 2023-01-09 20:25:52 +0200 |
---|---|---|
committer | Arthur Zamarin <arthurzam@gentoo.org> | 2023-01-09 20:25:52 +0200 |
commit | d2a5afc73f39786877d7a3353be94f4cbcb5a2a2 (patch) | |
tree | d25f7efea5ec1a57010479084038d45f999bf43b | |
parent | add __main__.py file (diff) | |
download | pkgcheck-d2a5afc73f39786877d7a3353be94f4cbcb5a2a2.tar.gz pkgcheck-d2a5afc73f39786877d7a3353be94f4cbcb5a2a2.tar.bz2 pkgcheck-d2a5afc73f39786877d7a3353be94f4cbcb5a2a2.zip |
MissingInherits: don't show for functions defined in ebuild
Resolves: https://github.com/pkgcore/pkgcheck/issues/513
Signed-off-by: Arthur Zamarin <arthurzam@gentoo.org>
-rw-r--r-- | src/pkgcheck/checks/codingstyle.py | 10 | ||||
-rw-r--r-- | testdata/repos/eclass/InheritsCheck/MissingInherits/MissingInherits-2.ebuild | 15 |
2 files changed, 23 insertions, 2 deletions
diff --git a/src/pkgcheck/checks/codingstyle.py b/src/pkgcheck/checks/codingstyle.py index 6d3e53ca..ea315259 100644 --- a/src/pkgcheck/checks/codingstyle.py +++ b/src/pkgcheck/checks/codingstyle.py @@ -783,6 +783,12 @@ class InheritsCheck(Check): def feed(self, pkg): conditional = set() + # collect globally defined functions in ebuild + defined_funcs = { + pkg.node_str(func_node.child_by_field_name("name")) + for func_node, _ in bash.func_query.captures(pkg.tree.root_node) + } + # register variables assigned in ebuilds assigned_vars = dict() for node, _ in bash.var_assign_query.captures(pkg.tree.root_node): @@ -802,8 +808,8 @@ class InheritsCheck(Check): conditional.update(eclasses) # Also ignore vars since any used in arithmetic expansions, i.e. # $((...)), are captured as commands. - elif name not in self.eapi_funcs[pkg.eapi] | assigned_vars.keys(): - lineno, colno = node.start_point + elif name not in self.eapi_funcs[pkg.eapi] | assigned_vars.keys() | defined_funcs: + lineno, _colno = node.start_point if eclass := self.get_eclass(name, pkg): used[eclass].append((lineno + 1, name, call.split("\n", 1)[0])) diff --git a/testdata/repos/eclass/InheritsCheck/MissingInherits/MissingInherits-2.ebuild b/testdata/repos/eclass/InheritsCheck/MissingInherits/MissingInherits-2.ebuild new file mode 100644 index 00000000..9aa0432e --- /dev/null +++ b/testdata/repos/eclass/InheritsCheck/MissingInherits/MissingInherits-2.ebuild @@ -0,0 +1,15 @@ +EAPI=7 + +DESCRIPTION="Ebuild missing an eclass inherit" +HOMEPAGE="https://github.com/pkgcore/pkgcheck" +SLOT="0" +LICENSE="BSD" + +src_prepare() { + inherit_public_func + unset EBUILD_TEST +} + +inherit_public_func() { + echo "inherit_public_func" +} |