Skip to content

Potential fixes for 3 code quality findings - #21

Merged
oxGorou merged 3 commits into
mainfrom
ai-findings-autofix/UXTU4Unix-UXTU4Unix.py
Apr 25, 2026
Merged

oxGorou merged 3 commits into
mainfrom
ai-findings-autofix/UXTU4Unix-UXTU4Unix.py

Conversation

@oxGorou

@oxGorou oxGorou commented Apr 25, 2026 •

Copy link
Copy Markdown
Member

This PR applies 3/4 suggestions from code quality AI findings. 1 suggestion was skipped to avoid creating conflicts.

Summary by Sourcery

Replace shell-based subprocess calls with safer argument-list invocations and use direct terminal escape sequences instead of shell printf.

Enhancements:

  • Use subprocess.run with argument lists for clear and sudo-k invocations instead of shell commands.
  • Write terminal resize escape sequence directly to stdout and flush instead of invoking printf via the shell.

oxGorou and others added 3 commits April 25, 2026 21:51
Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>
@sourcery-ai

sourcery-ai Bot commented Apr 25, 2026 •

Copy link
Copy Markdown
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Refactors subprocess usage to avoid shell invocation and adjusts terminal resizing to write escape sequences directly to stdout, improving safety and clarity without changing overall behavior.

File-Level Changes

Change Details Files
Replace shell-invoked subprocess calls with argument-list based invocations for screen clearing and sudo timestamp reset.
  • Update clear() helper to use subprocess.run with an argument list instead of subprocess.call with shell=True for the clear command
  • Change welcome_tutorial() sudo timestamp reset to use subprocess.run with an argument list instead of shell=True
UXTU4Unix/UXTU4Unix.py
Send terminal resize escape sequence directly to stdout instead of via a shell-based printf subprocess.
  • Replace subprocess.run('printf ...', shell=True) with direct sys.stdout.write of the ANSI escape sequence
  • Explicitly flush stdout after writing the resize escape sequence to ensure it is emitted before subsequent logic runs
UXTU4Unix/UXTU4Unix.py

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@oxGorou
oxGorou marked this pull request as ready for review April 25, 2026 14:53
@oxGorou
oxGorou merged commit 5e15923 into main Apr 25, 2026
3 checks passed

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Hey - I've found 1 issue, and left some high level feedback:

  • The terminal resize escape sequence ("\x1b[8;35;100t") in main() is a bit of a magic string; consider pulling the dimensions and sequence into named constants or a small helper to make the intent and parameters clearer.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The terminal resize escape sequence (`"\x1b[8;35;100t"`) in `main()` is a bit of a magic string; consider pulling the dimensions and sequence into named constants or a small helper to make the intent and parameters clearer.

## Individual Comments

### Comment 1
<location path="UXTU4Unix/UXTU4Unix.py" line_range="42" />
<code_context>

 def clear():
-    subprocess.call('clear', shell=True)
+    subprocess.run(['clear'], check=False)
     print(r"""
 +----------------------------------------------------+
</code_context>
<issue_to_address>
**issue:** Consider handling environments where `clear` is not available to avoid `FileNotFoundError`.

This change will now raise `FileNotFoundError` if `clear` isn’t in `PATH` (e.g., minimal containers), instead of just returning a non-zero exit code. Consider wrapping the call in a `try/except FileNotFoundError` so the program continues even when `clear` is unavailable.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment thread UXTU4Unix/UXTU4Unix.py

def clear():
subprocess.call('clear', shell=True)
subprocess.run(['clear'], check=False)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

issue: Consider handling environments where clear is not available to avoid FileNotFoundError.

This change will now raise FileNotFoundError if clear isn’t in PATH (e.g., minimal containers), instead of just returning a non-zero exit code. Consider wrapping the call in a try/except FileNotFoundError so the program continues even when clear is unavailable.

@oxGorou
oxGorou deleted the ai-findings-autofix/UXTU4Unix-UXTU4Unix.py branch April 25, 2026 15:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant