From 79fa12ae4b72b967051f7d19ffddac4fe3651171 Mon Sep 17 00:00:00 2001 From: Richard Purdie Date: Wed, 2 Apr 2025 10:10:40 +0100 Subject: [PATCH] bitbake: parse/ConfHandler: Add warning for deprecated whitespace usage A lack of whitespace around variable assignment operators makes the files harder to read. There is a deeper issue in that a "+" character can sometimes be confused between the variable name and the assignment operator. Start showing warnings for such usage so we encourage people to use consistent whitespace which helps with file readability in general. (Bitbake rev: 24772dd2ae6c0cd11540a260f15065f906fb0997) Signed-off-by: Richard Purdie --- bitbake/lib/bb/parse/parse_py/ConfHandler.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/bitbake/lib/bb/parse/parse_py/ConfHandler.py b/bitbake/lib/bb/parse/parse_py/ConfHandler.py index 1bde597254..675838d845 100644 --- a/bitbake/lib/bb/parse/parse_py/ConfHandler.py +++ b/bitbake/lib/bb/parse/parse_py/ConfHandler.py @@ -23,7 +23,7 @@ __config_regexp__ = re.compile( r""" (?P[a-zA-Z0-9\-_+.${}/~:]*?) (\[(?P[a-zA-Z0-9\-_+.][a-zA-Z0-9\-_+.@/]*)\])? - \s* ( + (?P\s*) ( (?P:=) | (?P\?\?=) | (?P\?=) | @@ -32,7 +32,7 @@ __config_regexp__ = re.compile( r""" (?P=\.) | (?P\.=) | = - ) \s* + ) (?P\s*) (?!'[^']*'[^']*'$) (?!\"[^\"]*\"[^\"]*\"$) @@ -168,6 +168,8 @@ def feeder(lineno, s, fn, statements, baseconfig=False, conffile=True): groupd = m.groupdict() if groupd['var'] == "": raise ParseError("Empty variable name in assignment: '%s'" % s, fn, lineno); + if not groupd['whitespace'] or not groupd['whitespace2']: + logger.warning("%s:%s has a lack of whitespace around the assignment: '%s'" % (fn, lineno, s)) ast.handleData(statements, fn, lineno, groupd) return