Skip to content

Remove dead code in StringHelper::truncateWordsByLength() - #167

Merged
vjik merged 1 commit into
masterfrom
deadcode
Jul 26, 2026
Merged

Remove dead code in StringHelper::truncateWordsByLength()#167
vjik merged 1 commit into
masterfrom
deadcode

Conversation

@vjik

@vjik vjik commented Jul 25, 2026

Copy link
Copy Markdown
Member
Q A
Is bugfix?
New feature?
Breaks BC?

The branch existed to handle $cut === '', returning mb_substr($trimMarker, 0, $length, $encoding). But $length > $markerLength is already guaranteed by the earlier check on line 376, so that mb_substr call always returns $trimMarker in full — the same value the general branch produces via $cut . $trimMarker when $cut is empty. So the
special-case branch never changed the output; it was redundant dead code duplicating the general case.

@vjik
vjik requested review from a team and Copilot July 25, 2026 15:42
@codecov

codecov Bot commented Jul 25, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (d12072d) to head (23b5c07).

Additional details and impacted files
@@              Coverage Diff              @@
##             master      #167      +/-   ##
=============================================
+ Coverage     99.79%   100.00%   +0.20%     
+ Complexity      172       171       -1     
=============================================
  Files             7         7              
  Lines           478       476       -2     
=============================================
- Hits            477       476       -1     
+ Misses            1         0       -1     

☔ View full report in Codecov by Harness.
📢 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.

@vjik vjik added the status:code review The pull request needs review. label Jul 25, 2026

Copilot AI 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.

Pull request overview

This PR removes a redundant special-case branch in StringHelper::truncateWordsByLength() that never altered the returned value due to the existing $length <= $markerLength guard, simplifying the word-boundary truncation path without changing behavior.

Changes:

  • Simplified the “last space within snippet” return path in StringHelper::truncateWordsByLength() by removing dead code.
  • Documented the internal cleanup in CHANGELOG.md under the upcoming release.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
src/StringHelper.php Removes an unreachable/redundant conditional branch and returns the same value via the general concatenation path.
CHANGELOG.md Adds an entry noting the dead-code removal enhancement.

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

@vjik
vjik merged commit f7c9db9 into master Jul 26, 2026
28 checks passed
@vjik
vjik deleted the deadcode branch July 26, 2026 14:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status:code review The pull request needs review.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants