Bug 13206

Summary: Bitbake needs a lint-like tool
Product: [Build System, Metadata & Runtime] BitBake Reporter: Evadeflow <evadeflow>
Component: bitbakeAssignee: Unassigned <unassigned>
Status: NEW --- QA Contact:
Severity: enhancement    
Priority: Medium CC: duy.dang.yw, pavel, poky.bs.watcher, poky.watcher, randy.macleod
Version: unspecified   
Target Milestone: 6.99   
Hardware: x86   
OS: Multiple   
Whiteboard:
OS type for building Yocto: --- Type of Regression: ---
Verified: Documentation change: Don't know

Description Evadeflow 2019-02-26 21:38:07 UTC
I feel it would benefit the Yocto project *tremendously* to have a linter for Bitbake builds. Bitbake is quite liberal in terms of what it will permit recipe/layer authors to do. However, a set of best practices have emerged over the past several years, many of which take the form: "Avoid X." Here are a few such rules I encountered this week:

- In general, avoid override-style removal (i.e., `FOO_remove = ...`), because it's extremely difficult to undo in append recipes. If you must use this syntax, prefer the idiom`FOO_remove = ${FOO_REMOVALS}` so that appends can override the removal.

- Avoid adding extra whitespace when using += and =+
   BAD: FOO += " bar"
  OKAY: FOO += "bar"

- Avoid forgetting to add whitespace when appending via override syntax.
   BAD: FOO_append = "bar"
  OKAY: FOO_append = " bar"

My guess is that core Yocto project contributors can rattle off a few dozen rules like this off the top of their head. And I'm betting that automated checks could be written for many/most of them.
Comment 1 Randy MacLeod 2023-10-24 14:24:25 UTC
Bulk move from 4.99 or 0.00 to 5.99
Comment 2 Duy Dang 2024-03-18 03:48:13 UTC
There is a python library for this purpose: https://pypi.org/project/oelint-adv/

But can we use it in bitbake or create a contrib script in poky?