public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-commits] proj/pkgcore/pkgcheck:master commit in: testdata/repos/eclass/eclass/, src/pkgcheck/checks/, ...
@ 2023-06-22 19:44 Arthur Zamarin
  0 siblings, 0 replies; only message in thread
From: Arthur Zamarin @ 2023-06-22 19:44 UTC (permalink / raw
  To: gentoo-commits

commit:     aefdf93fc423a08eb41d09eecb5cd376183e1660
Author:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
AuthorDate: Thu Jun 22 19:39:42 2023 +0000
Commit:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
CommitDate: Thu Jun 22 19:44:44 2023 +0000
URL:        https://gitweb.gentoo.org/proj/pkgcore/pkgcheck.git/commit/?id=aefdf93f

MissingInherits: exclude @USER_VARIABLEs

Resolves: https://github.com/pkgcore/pkgcheck/issues/575
Signed-off-by: Arthur Zamarin <arthurzam <AT> gentoo.org>

 src/pkgcheck/checks/codingstyle.py                         | 14 +++++++++++++-
 .../InheritsCheck/MissingInherits/MissingInherits-2.ebuild |  2 +-
 testdata/repos/eclass/eclass/stub.eclass                   |  6 ++++++
 3 files changed, 20 insertions(+), 2 deletions(-)

diff --git a/src/pkgcheck/checks/codingstyle.py b/src/pkgcheck/checks/codingstyle.py
index a9eb70fa..1ab82ad9 100644
--- a/src/pkgcheck/checks/codingstyle.py
+++ b/src/pkgcheck/checks/codingstyle.py
@@ -749,6 +749,16 @@ class InheritsCheck(Check):
             for name in eclass_obj.variable_names:
                 self.exported.setdefault(name, set()).add(eclass)
 
+        # collect all @USER_VARIABLEs, which are excluded from MissingInherits
+        self.user_variables = frozenset(
+            {
+                x.name
+                for eclass_obj in self.eclass_cache.values()
+                for x in eclass_obj.variables
+                if x.user_variable
+            }
+        )
+
         # register EAPI-related funcs/cmds to ignore
         self.eapi_funcs = {}
         for eapi in EAPI.known_eapis.values():
@@ -826,7 +836,9 @@ class InheritsCheck(Check):
             if node.parent.type == "unset_command":
                 continue
             if name not in self.eapi_vars[pkg.eapi] | assigned_vars.keys():
-                lineno, colno = node.start_point
+                if name in self.user_variables:
+                    continue
+                lineno, _colno = node.start_point
                 if eclass := self.get_eclass(name, pkg):
                     used[eclass].append((lineno + 1, name, name))
 

diff --git a/testdata/repos/eclass/InheritsCheck/MissingInherits/MissingInherits-2.ebuild b/testdata/repos/eclass/InheritsCheck/MissingInherits/MissingInherits-2.ebuild
index 9aa0432e..025d284c 100644
--- a/testdata/repos/eclass/InheritsCheck/MissingInherits/MissingInherits-2.ebuild
+++ b/testdata/repos/eclass/InheritsCheck/MissingInherits/MissingInherits-2.ebuild
@@ -11,5 +11,5 @@ src_prepare() {
 }
 
 inherit_public_func() {
-	echo "inherit_public_func"
+	echo "inherit_public_func" "${LARRY_EASTER_EGG}"
 }

diff --git a/testdata/repos/eclass/eclass/stub.eclass b/testdata/repos/eclass/eclass/stub.eclass
index b30f3f62..0fbb17ea 100644
--- a/testdata/repos/eclass/eclass/stub.eclass
+++ b/testdata/repos/eclass/eclass/stub.eclass
@@ -11,3 +11,9 @@ EXPORT_FUNCTIONS src_prepare
 # @DESCRIPTION:
 # Public src_prepare stub function.
 stub_src_prepare() { :; }
+
+# @ECLASS_VARIABLE: LARRY_EASTER_EGG
+# @USER_VARIABLE
+# @DEFAULT_UNSET
+# @DESCRIPTION:
+# A special user variable, an easter egg if you can find it.


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2023-06-22 19:44 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-06-22 19:44 [gentoo-commits] proj/pkgcore/pkgcheck:master commit in: testdata/repos/eclass/eclass/, src/pkgcheck/checks/, Arthur Zamarin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox