App: Miscellaneous fixes and improvements based on AI code analysis #44

Merged
Jan Lindemann merged 8 commits from jan/feature/20260630-app-get-values-filter-out-empty-split-results into master 2026-06-30 15:21:31 +02:00 AGit

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: continue check 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.

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: continue` check 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.

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.

Assisted-by: unsloth/Qwen3.6-35B-A3B-GGUF:IQ4_NL and pi.dev
Signed-off-by: Jan Lindemann <jan@janware.com>

get_project_refs() always returns a list[str], never None. The `if deps is None: continue` check in __read_dep_graph() is dead code, remove it.

Assisted-by: unsloth/Qwen3.6-35B-A3B-GGUF:IQ4_NL and pi.dev
Signed-off-by: Jan Lindemann <jan@janware.com>

Mutable default arguments (list) cause unexpected shared state between calls. Use None as default and initialise to [] inside the function body.

Assisted-by: unsloth/Qwen3.6-35B-A3B-GGUF:IQ4_NL and pi.dev
Signed-off-by: Jan Lindemann <jan@janware.com>

Replace the hardcoded /opt in __proj_dir() with a configurable ___opt_root member, consistent with how __projs_root is configured.

Assisted-by: unsloth/Qwen3.6-35B-A3B-GGUF:IQ4_NL and pi.dev
Signed-off-by: Jan Lindemann <jan@janware.com>

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.

Assisted-by: unsloth/Qwen3.6-35B-A3B-GGUF:IQ4_NL and pi.dev
Signed-off-by: Jan Lindemann <jan@janware.com>

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.

Assisted-by: unsloth/Qwen3.6-35B-A3B-GGUF:IQ4_NL and pi.dev
Signed-off-by: Jan Lindemann <jan@janware.com>

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.

Assisted-by: unsloth/Qwen3.6-35B-A3B-GGUF:IQ4_NL and pi.dev
Signed-off-by: Jan Lindemann <jan@janware.com>
App.get_values(): Filter out empty split results
All checks were successful
CI / Packaging - Kali Linux (pull_request) Successful in 4m20s
CI / Packaging - OpenSUSE Tumbleweed (pull_request) Successful in 4m29s
CI / Packaging test (pull_request) Successful in 0s
CI / Packaging - Kali Linux (push) Successful in 4m0s
CI / Packaging - OpenSUSE Tumbleweed (push) Successful in 4m14s
CI / Packaging test (push) Successful in 0s
a2a4312f5b

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.

Assisted-by: unsloth/Qwen3.6-35B-A3B-GGUF:IQ4_NL and pi.dev
Signed-off-by: Jan Lindemann <jan@janware.com>
Jan Lindemann scheduled this pull request to auto merge when all checks succeed 2026-06-30 15:12:36 +02:00
Jan Lindemann changed title from App.get_values(): Filter out empty split results to App: Miscellaneous fixes and improvements based on AI code analysis 2026-06-30 15:14:38 +02:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
janware/jw-pkg!44
No description provided.