pkgcheck icon indicating copy to clipboard operation
pkgcheck copied to clipboard

Detect unused/stray USE flags

Open thesamesam opened this issue 3 years ago • 4 comments

It's possible to have USE flags in IUSE which are declared in metadata.xml (or global USE flags) which don't actually do anything (no references in dependencies, or in the ebuilds).

  • To make this easier, we may want to ignore ebuilds which inherit from eclasses which modify IUSE at first.
  • We also need to check for use of 'has', 'use', etc in eclasses, not just phase/function bodies in ebuilds

Example: see https://gitweb.gentoo.org/repo/gentoo.git/commit/net-misc/iputils?id=0b738488bed8d9735db35ade5a01834b3e07ebcf.

From 0b738488bed8d9735db35ade5a01834b3e07ebcf Mon Sep 17 00:00:00 2001
From: Mike Gilbert <[email protected]>
Date: Wed, 11 May 2022 14:29:07 -0400
Subject: net-misc/iputils: drop non-functional USE flags

Signed-off-by: Mike Gilbert <[email protected]>
---
 net-misc/iputils/iputils-20210722-r1.ebuild | 2 +-
 net-misc/iputils/iputils-20211215.ebuild    | 2 +-
 net-misc/iputils/iputils-99999999.ebuild    | 2 +-
 net-misc/iputils/metadata.xml               | 2 --
 4 files changed, 3 insertions(+), 5 deletions(-)

(limited to 'net-misc/iputils')

diff --git a/net-misc/iputils/iputils-20210722-r1.ebuild b/net-misc/iputils/iputils-20210722-r1.ebuild
index 2ae5257319b..a97324cae33 100644
--- a/net-misc/iputils/iputils-20210722-r1.ebuild
+++ b/net-misc/iputils/iputils-20210722-r1.ebuild
@@ -28,7 +28,7 @@ HOMEPAGE="https://wiki.linuxfoundation.org/networking/iputils"
 
 LICENSE="BSD GPL-2+ rdisc"
 SLOT="0"
-IUSE="+arping caps clockdiff doc gcrypt idn nettle nls rarpd rdisc ssl static test tftpd tracepath traceroute6"
+IUSE="+arping caps clockdiff doc idn nls rarpd rdisc static test tftpd tracepath traceroute6"
 RESTRICT="!test? ( test )"
 
 BDEPEND="
diff --git a/net-misc/iputils/iputils-20211215.ebuild b/net-misc/iputils/iputils-20211215.ebuild
index dfcc596a154..74d10298e9c 100644
--- a/net-misc/iputils/iputils-20211215.ebuild
+++ b/net-misc/iputils/iputils-20211215.ebuild
@@ -29,7 +29,7 @@ HOMEPAGE="https://wiki.linuxfoundation.org/networking/iputils"
 
 LICENSE="BSD GPL-2+ rdisc"
 SLOT="0"
-IUSE="+arping caps clockdiff doc gcrypt idn nettle nls rarpd rdisc ssl static test tracepath"
+IUSE="+arping caps clockdiff doc idn nls rarpd rdisc static test tracepath"
 RESTRICT="!test? ( test )"
 
 LIB_DEPEND="
diff --git a/net-misc/iputils/iputils-99999999.ebuild b/net-misc/iputils/iputils-99999999.ebuild
index cef1837240e..e94679e4343 100644
--- a/net-misc/iputils/iputils-99999999.ebuild
+++ b/net-misc/iputils/iputils-99999999.ebuild
@@ -29,7 +29,7 @@ HOMEPAGE="https://wiki.linuxfoundation.org/networking/iputils"
 
 LICENSE="BSD GPL-2+ rdisc"
 SLOT="0"
-IUSE="+arping caps clockdiff doc gcrypt idn nettle nls ssl static test tracepath"
+IUSE="+arping caps clockdiff doc idn nls static test tracepath"
 RESTRICT="!test? ( test )"
 
 LIB_DEPEND="
diff --git a/net-misc/iputils/metadata.xml b/net-misc/iputils/metadata.xml
index b6ebdf9c592..cd78568cc22 100644
--- a/net-misc/iputils/metadata.xml
+++ b/net-misc/iputils/metadata.xml
@@ -8,8 +8,6 @@
   <use>
     <flag name="arping">Build and install arping -- tool for sending ARP requests to peers (see also <pkg>net-analyzer/arping</pkg>)</flag>
     <flag name="clockdiff">Build and install clockdiff -- tool for comparing clocks via ICMP packets</flag>
-    <flag name="gcrypt">Use <pkg>dev-libs/libgcrypt</pkg> for md5 support</flag>
-    <flag name="nettle">Use <pkg>dev-libs/nettle</pkg> for md5 support</flag>
     <flag name="rarpd">Build and install rarpd -- server for handling RARP (reverse ARP) requests; generally only used by old systems</flag>
     <flag name="rdisc">Build and install rdisc -- server for the client side of the ICMP router discover protocol</flag>
     <flag name="tftpd">Build and install tftpd -- server for the Trivial File Transfer Protocol (see also <pkg>net-ftp/tftp-hpa</pkg>)</flag>
-- 
cgit v1.2.3-18-g5258

thesamesam avatar Aug 12 '22 16:08 thesamesam

This is related to https://github.com/pkgcore/pkgcheck/issues/414 but it's a bit different.

  • The other bug (#414) is about USE flags which exist and (usually) do something but shouldn't (should be made either always on, or maybe even always off) because they provide little utility.

  • This bug (#427) is about zombie USE flags (USE flags in IUSE which have no effect on the output or build process at all, it does nothing, and its value isn't even checked).

The other bug might hit some cases of this bug.

thesamesam avatar Aug 12 '22 17:08 thesamesam

OK, so as preparation, the list of places where a USE flag can be used:

  • *DEPEND
  • HOMEPAGE, SRC_URI, LICENSE, REQUIRED_USE, PROPERTIES and RESTRICT (PMS, chapter 8.1)
  • argument to functions use, usev, useq (banned), use_with, use_enable, usex

Special cases that I exclude:

  • test
  • doc

arthurzam avatar Aug 18 '22 19:08 arthurzam

I'd suggest disabling the check if any variable reference is found for those invocations- IE, use $VAR. It's a stretch, but consider an eclass that is renaming a use flag- I would use an intermediate var to hold what the flag is for the 'before' and 'after', and this check wouldn't like that.

ferringb avatar Jan 25 '24 22:01 ferringb