Skip to content
Closed
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/codecov-analytics.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
permissions:
contents: read
id-token: write
uses: Prekzursil/quality-zero-platform/.github/workflows/reusable-codecov-analytics.yml@e6d4ce5145e76f65491dfa651d492f5ff3961f41
uses: Prekzursil/quality-zero-platform/.github/workflows/reusable-codecov-analytics.yml@be1d889a693c2fcca3b8061350ad1a61bd777fbd
with:
repo_slug: ${{ github.repository }}
event_name: ${{ github.event_name }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/quality-zero-backlog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
permissions:
contents: write
pull-requests: write
uses: Prekzursil/quality-zero-platform/.github/workflows/reusable-backlog-sweep.yml@cb067b5a04b596deef983f93eac95f227b9dc09c
uses: Prekzursil/quality-zero-platform/.github/workflows/reusable-backlog-sweep.yml@be1d889a693c2fcca3b8061350ad1a61bd777fbd
with:
repo_slug: ${{ github.repository }}
lane: quality
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/quality-zero-gate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
aggregate-gate:
permissions:
contents: read
uses: Prekzursil/quality-zero-platform/.github/workflows/reusable-quality-zero-gate.yml@e6d4ce5145e76f65491dfa651d492f5ff3961f41
uses: Prekzursil/quality-zero-platform/.github/workflows/reusable-quality-zero-gate.yml@be1d889a693c2fcca3b8061350ad1a61bd777fbd
with:
repo_slug: ${{ github.repository }}
event_name: ${{ github.event_name }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/quality-zero-platform.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
permissions:
contents: read
id-token: write
uses: Prekzursil/quality-zero-platform/.github/workflows/reusable-scanner-matrix.yml@e6d4ce5145e76f65491dfa651d492f5ff3961f41
uses: Prekzursil/quality-zero-platform/.github/workflows/reusable-scanner-matrix.yml@be1d889a693c2fcca3b8061350ad1a61bd777fbd
with:
repo_slug: ${{ github.repository }}
event_name: ${{ github.event_name }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/quality-zero-remediation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
contents: write
pull-requests: write
if: ${{ github.event_name == 'workflow_dispatch' || github.event.workflow_run.conclusion == 'failure' }}
uses: Prekzursil/quality-zero-platform/.github/workflows/reusable-remediation-loop.yml@cb067b5a04b596deef983f93eac95f227b9dc09c
uses: Prekzursil/quality-zero-platform/.github/workflows/reusable-remediation-loop.yml@be1d889a693c2fcca3b8061350ad1a61bd777fbd
with:
repo_slug: ${{ github.repository }}
failure_context: Quality Zero Gate
Expand Down
60 changes: 60 additions & 0 deletions .qlty/qlty.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# This file was automatically generated by `qlty init`.
# You can modify it to suit your needs.
# We recommend you to commit this file to your repository.
#
# This configuration is used by both Qlty CLI and Qlty Cloud.
#
# Qlty CLI -- Code quality toolkit for developers
# Qlty Cloud -- Fully automated Code Health Platform
#
# Try Qlty Cloud: https://qlty.sh
#
# For a guide to configuration, visit https://qlty.sh/d/config
# Or for a full reference, visit https://qlty.sh/d/qlty-toml
config_version = "0"

exclude_patterns = [
"*_min.*",
"*-min.*",
"*.min.*",
"**/*.d.ts",
"**/.yarn/**",
"**/bower_components/**",
"**/build/**",
"**/cache/**",
"**/config/**",
"**/db/**",
"**/deps/**",
"**/dist/**",
"**/extern/**",
"**/external/**",
"**/generated/**",
"**/Godeps/**",
"**/gradlew/**",
"**/mvnw/**",
"**/node_modules/**",
"**/protos/**",
"**/seed/**",
"**/target/**",
"**/testdata/**",
"**/vendor/**",
"**/assets/**",
]

test_patterns = [
"**/test/**",
"**/spec/**",
"**/*.test.*",
"**/*.spec.*",
"**/*_test.*",
"**/*_spec.*",
"**/test_*.*",
"**/spec_*.*",
]

[smells]
mode = "block"

[[source]]
name = "default"
default = true
24 changes: 10 additions & 14 deletions env_inspector_core/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,27 +184,23 @@ def run_cli(argv: Sequence[str] | None = None, *, service: EnvInspectorService |
return 0

active_service = service or EnvInspectorService()
if args.command == "list":
try:
_list_records(active_service, args)
except ValueError as exc:
print(str(exc), file=sys.stderr)
return 2
return 0

handlers = {
"list": _list_records,
"set": _set_key,
"remove": _remove_key,
"export": _export_records,
"backup": _list_backups,
"restore": _restore_backup,
}
handler = handlers.get(args.command)
exit_code = 2
if handler is None:
print(f"Unknown command: {args.command}", file=sys.stderr)
return 2
try:
return handler(active_service, args)
except ValueError as exc:
print(str(exc), file=sys.stderr)
return 2
else:
try:
exit_code = handler(active_service, args)
if args.command == "list":
exit_code = 0
except ValueError as exc:
print(str(exc), file=sys.stderr)
return exit_code
Comment on lines +196 to +206

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Fragile exit code handling when handler returns None.

The logic has a subtle issue: when handler(active_service, args) returns None (as _list_records does), exit_code is assigned None. The special case on lines 202-203 fixes this for the "list" command, but if any other handler were to return None in the future, the function would return None instead of a valid exit code.

Consider making _list_records return 0 for consistency with other handlers, which would eliminate the special case:

🛠️ Proposed fix
 def _list_records(service: EnvInspectorService, args: argparse.Namespace) -> None:
+def _list_records(service: EnvInspectorService, args: argparse.Namespace) -> int:
     _reject_raw_secret_stdout(args)
     _emit_stdout_rows(_stdout_safe_rows(service, args), output=args.output)
+    return 0

Then remove the special case:

     try:
         exit_code = handler(active_service, args)
-        if args.command == "list":
-            exit_code = 0
     except ValueError as exc:
         print(str(exc), file=sys.stderr)
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@env_inspector_core/cli.py` around lines 196 - 206, The exit code handling is
fragile because a handler (specifically _list_records) can return None which
gets assigned to exit_code; change _list_records to explicitly return 0 on
success (so it behaves like other handlers) and then remove the special-case
branch that forces exit_code = 0 when args.command == "list"; update the code
paths that call handler(active_service, args) to assume an int return and
preserve the initial exit_code value (2) only when handler is None or an
exception occurs.

Loading
Loading