Skip to content

chore: extract HumanSize to shared helper (QUAL-003)#455

Merged
laurentiu021 merged 3 commits into
mainfrom
chore/extract-human-size
May 20, 2026
Merged

chore: extract HumanSize to shared helper (QUAL-003)#455
laurentiu021 merged 3 commits into
mainfrom
chore/extract-human-size

Conversation

@laurentiu021

@laurentiu021 laurentiu021 commented May 20, 2026

Copy link
Copy Markdown
Owner

Summary

  • Removed CleanupCategory.HumanSize() and consolidated all size formatting into FormatHelper.FormatSize()
  • Updated FormatHelper.FormatSize to support TB and handle zero/negative values
  • Updated all 4 model call sites + DeepCleanupViewModel + test files

Test plan

  • CI build passes
  • Unit tests pass (existing HumanSize tests now target FormatHelper.FormatSize)
  • Size displays unchanged across UI (same formatting logic)

Summary by CodeRabbit

  • New Features

    • Added terabyte (TB) support in human-readable size displays across the app.
  • Bug Fixes

    • More consistent handling of zero, negative and extreme size values.
    • Size values now show one decimal place (e.g., "2.0 KB") for improved precision.
  • Tests

    • Updated test suites to validate the new size-formatting behavior.

Review Change Stack

@coderabbitai

coderabbitai Bot commented May 20, 2026

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: ba3f3f34-a655-4cab-a455-ea9782b1b50b

📥 Commits

Reviewing files that changed from the base of the PR and between 7db4aa9 and b7fd190.

📒 Files selected for processing (2)
  • SysManager/SysManager.Tests/CleanupCategoryHumanSizeExtendedTests.cs
  • SysManager/SysManager.Tests/ProcessManagerServiceTests.cs
📜 Recent review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Build & unit tests
  • GitHub Check: Analyze (csharp)
🔇 Additional comments (2)
SysManager/SysManager.Tests/CleanupCategoryHumanSizeExtendedTests.cs (1)

86-86: LGTM!

SysManager/SysManager.Tests/ProcessManagerServiceTests.cs (1)

120-120: LGTM!


📝 Walkthrough

Walkthrough

This PR centralizes human-readable byte formatting by enhancing FormatHelper.FormatSize (B→TB, edge cases), removing CleanupCategory.HumanSize, and migrating all model/viewmodel display properties and tests to use FormatHelper.FormatSize.

Changes

Size formatting consolidation

Layer / File(s) Summary
FormatHelper.FormatSize core refactor
SysManager/SysManager/Helpers/FormatHelper.cs
Updates FormatSize(long bytes) to return "0 B" for non-positive values, keep <1KB as "X B", and scale to KB/MB/GB/TB with F1 formatting for unit values.
CleanupCategory model migration
SysManager/SysManager/Models/CleanupCategory.cs
Adds using SysManager.Helpers;, removes CleanupCategory.HumanSize(long), and updates SizeDisplay, LargeFileEntry.SizeDisplay, and CleanupResult.Summary to call FormatHelper.FormatSize.
Related models migration
SysManager/SysManager/Models/DiskUsageEntry.cs, SysManager/SysManager/Models/InstalledApp.cs, SysManager/SysManager/Models/ProcessEntry.cs, SysManager/SysManager/Models/TuneUpResult.cs
Updates computed display properties (SizeDisplay, MemoryDisplay, FreedDisplay) to use FormatHelper.FormatSize and adds the necessary using imports.
DeepCleanupViewModel display updates
SysManager/SysManager/ViewModels/DeepCleanupViewModel.cs
Switches TotalSelectedDisplay, LargeBytesScannedDisplay, final ScanSummary, and completion log formatting to FormatHelper.FormatSize.
Test suite updates
SysManager/SysManager.IntegrationTests/CleanupCategoryTests.cs, SysManager/SysManager.Tests/CleanupCategoryHumanSizeBulkTests.cs, SysManager/SysManager.Tests/CleanupCategoryHumanSizeExtendedTests.cs, SysManager/SysManager.Tests/ProcessManagerServiceTests.cs
Replaces calls to CleanupCategory.HumanSize with FormatHelper.FormatSize, updates expected strings (adds .0 precision at KB/MB/GB/TB thresholds), and adds using SysManager.Helpers where needed.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Poem

🐰 Soft paws on keys, I hop and plot,
Bytes shrink to labels, neat and taut.
TB joins KB in tidy rows,
One helper sings where chaos grows.
Hooray — formatted and well-sought!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 8.57% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: extracting the HumanSize method into a shared FormatHelper, which is the central refactoring across all modified files.
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 docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch chore/extract-human-size

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

@laurentiu021
laurentiu021 force-pushed the chore/extract-human-size branch from 8912806 to 7db4aa9 Compare May 20, 2026 10:54
@laurentiu021
laurentiu021 merged commit 7455fce into main May 20, 2026
5 checks passed
@laurentiu021
laurentiu021 deleted the chore/extract-human-size branch May 20, 2026 11:07
laurentiu021 added a commit that referenced this pull request May 22, 2026
* chore: extract HumanSize to shared helper (QUAL-003)

* fix: restore F1 format in FormatHelper.FormatSize to match original output

* fix: update remaining test assertions to match F1 format output

---------

Co-authored-by: laurentiu021 <laurentiu021@users.noreply.github.com>
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