Skip to content

Fix isVisible() initial value bug in NestedListStringFormatter#1717

Merged
alganet merged 1 commit intoRespect:3.1from
alganet:is-visible
Mar 10, 2026
Merged

Fix isVisible() initial value bug in NestedListStringFormatter#1717
alganet merged 1 commit intoRespect:3.1from
alganet:is-visible

Conversation

@alganet
Copy link
Member

@alganet alganet commented Mar 5, 2026

The array_reduce in isVisible() used true as its initial value with an || reducer, meaning it always returned true when siblings existed regardless of their actual visibility. This caused unnecessary nesting in full messages by showing single-child wrapper nodes that should have been collapsed.

Replace array_reduce with a foreach loop starting from false, which also enables early return on the first visible sibling.


The only test affected is AssertWithPropertiesTest, others pass cleanly. If you look at that test history, it seems that the nesting that was present there is a behavior that drifted with time (it existed before full paths like mysql.host were possible), and the implementation somehow got super complicated in order to pass a test that really doesn't make sense anymore: collapsing the orphan makes for a much cleaner message and faster runtime with an early return instead of expensive reduce.

This arguibly is a BC break, since it changes behavior. However, given the history laid down above, I would prefer to classify it as a bug to be fixed on the 3.1 series.

@codecov
Copy link

codecov bot commented Mar 5, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.45%. Comparing base (84d7436) to head (33927e2).
⚠️ Report is 3 commits behind head on 3.1.

Additional details and impacted files
@@             Coverage Diff              @@
##                3.1    #1717      +/-   ##
============================================
- Coverage     99.45%   99.45%   -0.01%     
- Complexity     1015     1016       +1     
============================================
  Files           194      194              
  Lines          2384     2383       -1     
============================================
- Hits           2371     2370       -1     
  Misses           13       13              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@alganet alganet requested a review from Copilot March 5, 2026 19:13
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@alganet
Copy link
Member Author

alganet commented Mar 5, 2026

I'm going to use this PR to test panda benchmark. We don't need a benchmark here, but I never used it in a real PR.

@alganet
Copy link
Member Author

alganet commented Mar 5, 2026

@TheRespectPanda benchmark

@TheRespectPanda
Copy link
Contributor

Failed to trigger benchmarks: Resource not accessible by personal access token

@alganet
Copy link
Member Author

alganet commented Mar 5, 2026

I made a note about the panda failure on #1635 and will work on it later.

Reviewers: just forget about this benchmark thing here 😄

@alganet alganet requested a review from Copilot March 5, 2026 20:47
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

The array_reduce in isVisible() used `true` as its initial value with
an `||` reducer, meaning it always returned `true` when siblings existed
regardless of their actual visibility. This caused unnecessary nesting
in full messages by showing single-child wrapper nodes that should have
been collapsed.

Replace array_reduce with a foreach loop starting from `false`, which
also enables early return on the first visible sibling.
@alganet alganet marked this pull request as ready for review March 5, 2026 21:09
@alganet alganet requested a review from henriquemoody March 5, 2026 21:10
@alganet alganet merged commit 317ffef into Respect:3.1 Mar 10, 2026
7 checks passed
@alganet alganet deleted the is-visible branch March 10, 2026 15:13
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.

4 participants