App: Miscellaneous fixes and improvements based on AI code analysis #44
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "jan/feature/20260630-app-get-values-filter-out-empty-split-results"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
This PR adds miscelaneous fixes and improvements following bugs and inconsistencies dug up by an AI bug hunt. Mostly coded by AI with manual beautification.
App.__find_circular_deps(): Move __flip_dep_graph() out
The __flip_dep_graph(graph) call sits inside the while loop and performs redundant graph flipping on every iteration. Hoist it outside to compute once and reuse the result.
App: Remove dead None check in __read_dep_graph()
get_project_refs() always returns a list[str], never None. The
if deps is None: continuecheck in __read_dep_graph() is dead code, remove it.App.find_dir/__find_dir(): Fix mutable default args
Mutable default arguments (list) cause unexpected shared state between calls. Use None as default and initialise to [] inside the function body.
App.__proj_dir(): Use configurable ___opt_root
Replace the hardcoded /opt in __proj_dir() with a configurable ___opt_root member, consistent with how __projs_root is configured.
App.get_value(): Remove redundant fd.close()
The fd.close() call inside the
with open(...) as fd:block is redundant because the file handle is managed by the context manager. Remove it.App: Return cycle path from find_circular_deps()
The __find_circular_deps() and find_circular_deps() methods now return list[str] instead of bool. On a cycle, the path builds up the dependency chain in __find_circular_deps_recursive(), and __find_circular_deps() appends the closing project to complete the cycle. An empty list means no cycle found.
CmdDep prints the cycle as 'a -> b -> c -> a' instead of a generic message.
App.get_value(): Fix FileNotFoundError regression
The refactored __get_project_conf() raises FileNotFoundError when project.conf does not exist, whereas the original read_value() returns None. This causes get_value() to crash for projects with missing or incomplete project.conf files.
Catch FileNotFoundError in __get_project_conf() and return None to restore original behavior. Remove redundant @cache from __read_project_conf() since __get_project_conf() already provides caching.
App.get_values(): Filter out empty split results
get_values() splits comma-separated values and strips whitespace but does not filter out empty strings. A value like "a, b, " produces ['a', 'b', ''], with an empty string at the end. This empty string propagates to callers like CmdRequiredOsPkg.py and pollutes output. Add a filter for non-empty stripped values.
App.get_values(): Filter out empty split resultsto App: Miscellaneous fixes and improvements based on AI code analysis