Skip to content

Conversation

@adeeshperera
Copy link

@adeeshperera adeeshperera commented Oct 7, 2025

  • Add MaxStagedFiles, MaxUnstagedFiles, and MaxUntrackedFiles constants
  • Update all references to use these constants instead of hardcoded values (5, 3, 3)

Summary by CodeRabbit

  • Refactor
    • Standardized display limits for staged, unstaged, and untracked file lists, ensuring consistent visibility across categories.
    • Unified calculation of the “… and N more” summary so remaining item counts are displayed consistently.
    • Improves predictability of how many items are shown before truncation and how overflow is summarized.

adeeshperera and others added 2 commits October 8, 2025 00:13
… in ShowFileStatistics

- Add MaxStagedFiles, MaxUnstagedFiles, and MaxUntrackedFiles constants
- Update all references to use these constants instead of hardcoded values (5, 3, 3)
fix DFanso#72 : Replace hardcoded display limits with named constants in ShowFileStatistics
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 7, 2025

Walkthrough

Introduced three exported constants (MaxStagedFiles, MaxUnstagedFiles, MaxUntrackedFiles) in internal/display/display.go and replaced hard-coded numeric thresholds in ShowFileStatistics with these constants. Logic and control flow remain unchanged; only the limits for displayed file counts and “... and N more” computations now reference the constants.

Changes

Cohort / File(s) Summary
Display thresholds constants
internal/display/display.go
Added exported constants MaxStagedFiles, MaxUnstagedFiles, MaxUntrackedFiles; replaced hard-coded limits in ShowFileStatistics with these constants for staged, unstaged, and untracked file lists.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant U as User
  participant D as Display
  participant S as ShowFileStatistics

  U->>D: Request file stats display
  D->>S: ShowFileStatistics()
  rect rgba(200,230,255,0.25)
    note right of S: Use constants for list caps
    S->>S: Cap staged by MaxStagedFiles
    S->>S: Cap unstaged by MaxUnstagedFiles
    S->>S: Cap untracked by MaxUntrackedFiles
  end
  alt Any list exceeds its max
    S-->>D: Include "... and N more"
  else All within limits
    S-->>D: Show full lists
  end
  D-->>U: Render statistics
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related issues

Poem

I nibbled numbers, swapped them clean,
Three shiny caps where literals had been.
Staged, unstaged, untracked in a row—
Constants now decide the show.
Thump-thump! my paws approve this art,
Configurable carrots, a tidy start. 🥕🐇

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title clearly summarizes the core change of replacing hardcoded display limits with named constants in ShowFileStatistics and includes the issue reference for context, making it immediately understandable to reviewers and in the project history.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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

@DFanso DFanso self-requested a review October 7, 2025 18:46
@DFanso DFanso added bug Something isn't working enhancement New feature or request hacktoberfest-accepted Approved Hacktoberfest contribution go Pull requests that update go code hacktoberfest Eligible for Hacktoberfest and removed hacktoberfest-accepted Approved Hacktoberfest contribution labels Oct 7, 2025
Copy link
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: 0

🧹 Nitpick comments (1)
internal/display/display.go (1)

9-13: LGTM! Constants correctly replace hardcoded limits.

The constants are well-named and match the PR objectives perfectly.

Consider making them unexported (e.g., maxStagedFiles) since they're only used within this file. This would improve encapsulation while still keeping them within the internal package boundary.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between bc0e7c3 and 2520073.

📒 Files selected for processing (1)
  • internal/display/display.go (4 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
internal/display/display.go (1)
internal/stats/statistics.go (1)
  • GetFileStatistics (14-74)
⏰ 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). (1)
  • GitHub Check: Package Binaries
🔇 Additional comments (3)
internal/display/display.go (3)

40-52: Staged files section correctly uses MaxStagedFiles.

All three occurrences properly reference the constant, maintaining the original display logic.


63-75: Unstaged files section correctly uses MaxUnstagedFiles.

All three occurrences properly reference the constant, maintaining the original display logic.


86-98: Untracked files section correctly uses MaxUntrackedFiles.

All three occurrences properly reference the constant, maintaining the original display logic.

Copy link
Owner

@DFanso DFanso left a comment

Choose a reason for hiding this comment

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

Approved 🎊

@DFanso DFanso merged commit d2726ec into DFanso:main Oct 7, 2025
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working enhancement New feature or request go Pull requests that update go code hacktoberfest Eligible for Hacktoberfest

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants