Skip to content

chore: add dead code detection and update the CGL tooling - #40

Open
Mainbird wants to merge 18 commits into
mainfrom
maintenance
Open

Mainbird wants to merge 18 commits into
mainfrom
maintenance

Conversation

@Mainbird

Copy link
Copy Markdown
Contributor

Summary

  • Run shipmonk/dead-code-detector with konradmichalik/phpstan-typo3-dead-code inside ddev composer cgl sca. All 26 candidates from the trial run are resolved, the baseline stays empty
  • Raise the CGL presets to their latest versions and fix every finding of phpstan-typo3-preset 0.7 without baseline entries
  • Pin rector/rector below 2.9, because ssch/typo3-rector 3.17.0 still uses classes Rector 2.9 removed (fixed upstream in [BUGFIX] Ship own value objects removed in Rector 2.9 sabbelasichon/typo3-rector#4958, not released yet)

Closes #39

Dead code detection

  • Tests/CGL/phpstan.neon includes the detector rules, analyses ext_localconf.php as entry point and enables markFluidAccess, because the Welcome widget cards and the branding are only read in Fluid templates
  • sca:php passes --autoload-file=../../vendor/autoload.php. Without it, PHPStan started from Tests/CGL does not see the TYPO3 parent classes and reports every ViewHelper, widget and middleware method
  • Triage: OptionsReader::path() and ComponentLifecycle::$product are removed, AbstractRepository is marked @api as public extension point

Preset 0.7 findings

  • json_decode() throws on invalid JSON (HtmlMinifier, LifecycleDataProvider). The EndOfLife widget now logs a warning instead of failing silently
  • Widget option exception codes are within the 32-bit integer range
  • The CSS view helper's anonymous tag builder became UnescapedTagBuilder, without the blanket @phpstan-ignore-line
  • The dashboard widgets read the date via getPropertyFromAspect('date', 'full')
  • Cognitive complexity: whitespace and comment handling moved from JavaScriptMinifier into JavaScriptWhitespace, protected by new characterization tests (JavaScriptMinifierTest, 30 cases). The date formatting of LastDeploymentEventListener moved into own methods

Further changes

  • Bug fix: "Last updated" in the system information toolbar never appeared, because the file check was inverted ($path !== ''). It now shows the modification time of index.php (default from ext_localconf.php)
  • ext_localconf.php declares strict types
  • The type_coverage.constant: 0 override is removed: PHP 8.4 is required and the preset already sets 100
  • phpunit/phpunit is required directly, the unit tests use it. composer.lock only gets a new content hash
  • Dependency analysis scans ext_localconf.php (so networkteam/sentry-client counts as used) and ignores typo3/cms-adminpanel and typo3/cms-linkvalidator, which are meant for the projects installing the toolbox

To discuss

Removing ComponentLifecycle::$product changes the constructor of a class released since 2.2.0. It is an internal value object of the EndOfLife widget, and a code search in the organisation finds no usage outside this repository. If it counts as public API, the commit can be reverted and the property marked @api instead.

Checks

  • ddev composer cgl sca, lint, analyze and Rector pass
  • 179 unit tests pass

@Mainbird
Mainbird requested a review from a team as a code owner November 27, 2026 13:47
@Mainbird
Mainbird requested review from IchigoNeko, danmoebius, hpa-move and konradmichalik and removed request for a team November 27, 2026 13:47
@coderabbitai

coderabbitai Bot commented Nov 27, 2026 •

Copy link
Copy Markdown

Important

  • Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 3f79415a-7ca5-4d85-af10-7c896ed45186
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

* @param list<LifecyclePhase> $phases ordered full support → security → ELTS
*/
public function __construct(
public string $product,

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@konradmichalik Could you review this change, please? The dead code detector reported $product as never read, so it is removed here. That changes the constructor of ComponentLifecycle, which has been released since 2.2.0. Within this repository only LifecycleDataProvider creates it, and a code search in the organisation finds no usage elsewhere.

Is it fine to remove it as internal value object, or should we keep the property and mark it @api instead?

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.

chore: add dead code detection to the PHPStan setup

2 participants