diff mbox series

[v2,2/3] classes-global: insane.bbclass : simplify conditional operations with bb.utils.filter

Message ID 20260427130846.96013-3-joaomarcos.costa@bootlin.com
State Under Review
Headers show
Series Simplify conditional operations with bb.utils.filter | expand

Commit Message

Joao Marcos Costa April 27, 2026, 1:08 p.m. UTC
The append override on ERROR_QA uses bb.utils.contains to check for a
string inside a variable, and return the exact same string if true.

This can be simplified by a call to bb.utils.filter, since the result is
the same, and the inline is shorter.

Replace "bb.utils.contains(A, 'a', 'a', '', d)" by "bb.utils.filter(A, 'a', d)".

Signed-off-by: João Marcos Costa <joaomarcos.costa@bootlin.com>
---
 meta/classes-global/insane.bbclass | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Quentin Schulz April 27, 2026, 2:15 p.m. UTC | #1
Hi João,

On 4/27/26 3:08 PM, João Marcos Costa wrote:
> The append override on ERROR_QA uses bb.utils.contains to check for a
> string inside a variable, and return the exact same string if true.
> 
> This can be simplified by a call to bb.utils.filter, since the result is
> the same, and the inline is shorter.
> 
> Replace "bb.utils.contains(A, 'a', 'a', '', d)" by "bb.utils.filter(A, 'a', d)".
> 

*Technically*, you are replacing

bb.utils.contains(A, 'a', ' a', '', d)
with
  bb.utils.filter(A, 'a', d)

You could have also said that you checked that ERROR_QA doesn't care 
about spurious whitespaces so that is a fine change.

Reviewed-by: Quentin Schulz <quentin.schulz@cherry.de>

Thanks!
Quentin
diff mbox series

Patch

diff --git a/meta/classes-global/insane.bbclass b/meta/classes-global/insane.bbclass
index feddfe0335..04700be71c 100644
--- a/meta/classes-global/insane.bbclass
+++ b/meta/classes-global/insane.bbclass
@@ -46,7 +46,7 @@  ERROR_QA ?= "\
     ${CHECKLAYER_REQUIRED_TESTS}"
 
 # Add usrmerge QA check based on distro feature
-ERROR_QA:append = "${@bb.utils.contains('DISTRO_FEATURES', 'usrmerge', ' usrmerge', '', d)}"
+ERROR_QA:append = " ${@bb.utils.filter('DISTRO_FEATURES', 'usrmerge', d)}"
 WARN_QA:append:layer-core = " missing-metadata missing-maintainer"
 
 FAKEROOT_QA = "host-user-contaminated"