Skip to content

Refactor SFTP helpers into a dedicated part file#1162

Merged
GT-610 merged 2 commits into
mainfrom
p3-code-quality-cleanup
May 4, 2026
Merged

Refactor SFTP helpers into a dedicated part file#1162
GT-610 merged 2 commits into
mainfrom
p3-code-quality-cleanup

Conversation

@GT-610
Copy link
Copy Markdown
Collaborator

@GT-610 GT-610 commented May 4, 2026

Summary

  • Moved SFTP path, decompression, time formatting, and sort helpers out of sftp.dart into sftp_helpers.dart
  • Removed the unused Range model file
  • Kept SFTP page behavior unchanged while improving code organization

Testing

  • Not run (not requested)

Summary by CodeRabbit

  • Refactor
    • Reorganized SFTP storage helpers into a dedicated module for cleaner code structure.
  • Chores
    • Removed an unused internal Range utility class.
  • New Features
    • Added a shell-safe single-quote escaping utility for building shell arguments.
  • Tests
    • Added tests verifying single-quote escaping and behavior with special characters.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 4, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: d0075d62-7f3c-43e2-91cf-230caa52357e

📥 Commits

Reviewing files that changed from the base of the PR and between 075c1b0 and 68027c4.

📒 Files selected for processing (4)
  • lib/core/utils/shell_quote.dart
  • lib/view/page/storage/sftp.dart
  • lib/view/page/storage/sftp_helpers.dart
  • test/sftp_helpers_test.dart
✅ Files skipped from review due to trivial changes (2)
  • lib/core/utils/shell_quote.dart
  • test/sftp_helpers_test.dart
🚧 Files skipped from review as they are similar to previous changes (2)
  • lib/view/page/storage/sftp.dart
  • lib/view/page/storage/sftp_helpers.dart

📝 Walkthrough

Walkthrough

This PR removes the public Range<T extends num> class from lib/data/model/app/range.dart. It refactors SFTP helper logic by adding part 'sftp_helpers.dart'; to lib/view/page/storage/sftp.dart, extracting inline helpers (path normalization, decompression-command lookup, timestamp formatting, and sorting) into the new lib/view/page/storage/sftp_helpers.dart. It also adds shellSingleQuote in lib/core/utils/shell_quote.dart and a corresponding test test/sftp_helpers_test.dart.

Possibly related PRs

Suggested reviewers

  • lollipopkit
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main refactoring: moving SFTP helpers into a dedicated part file (sftp_helpers.dart), which is the primary structural change across the changeset.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch p3-code-quality-cleanup

Review rate limit: 4/5 reviews remaining, refill in 12 minutes.

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot requested a review from lollipopkit May 4, 2026 07:52
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@lib/view/page/storage/sftp_helpers.dart`:
- Around line 5-9: The _getDecompressCmd function is vulnerable to shell
injection by inserting raw filename into shell commands; fix it by performing
POSIX single-quote escaping on the filename before substitution and using single
quotes around the escaped value when replacing FILE in _extCmdMap entries:
create or use a helper (e.g., escapeForSingleQuotes) that replaces each single
quote in filename with '\'' sequence, then replaceAll('FILE',
"'$escapedFilename'") in _getDecompressCmd (referencing _getDecompressCmd and
_extCmdMap) so filenames with quotes, $, backticks, etc. are safely quoted.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 7665a83a-5fdd-4f3d-80f7-8c1585c1ed0e

📥 Commits

Reviewing files that changed from the base of the PR and between 7f63316 and 075c1b0.

📒 Files selected for processing (3)
  • lib/data/model/app/range.dart
  • lib/view/page/storage/sftp.dart
  • lib/view/page/storage/sftp_helpers.dart
💤 Files with no reviewable changes (1)
  • lib/data/model/app/range.dart

Comment thread lib/view/page/storage/sftp_helpers.dart
@GT-610 GT-610 merged commit 39bd447 into main May 4, 2026
3 checks passed
@GT-610 GT-610 deleted the p3-code-quality-cleanup branch May 4, 2026 10:40
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