Skip to content

Commit 278ffb9

Browse files
[dependencies] Consolidate on composer-dependency-analyser (#135) (#136)
* [dependencies] Consolidate on composer-dependency-analyser (#135) * Update wiki submodule pointer for PR #136 * [dependencies] Add dump usage passthrough support (#135) * [dependencies] Reuse packaged analyser config (#135) * Update wiki submodule pointer for PR #136 * [dependencies] Detect packaged analyser context safely (#135) * Update wiki submodule pointer for PR #136 * [dependencies] Support report-only outdated threshold (#135) * [dependencies] Update max-outdated default value to -1 and remove run-dependencies-check input Signed-off-by: Felipe Sayão Lobato Abreu <github@mentordosnerds.com> --------- Signed-off-by: Felipe Sayão Lobato Abreu <github@mentordosnerds.com> Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
1 parent 35b7caf commit 278ffb9

18 files changed

Lines changed: 597 additions & 119 deletions

File tree

.github/wiki

Submodule wiki updated from ddcf608 to a093fa9

.github/workflows/tests.yml

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,33 +8,23 @@ on:
88
required: false
99
type: number
1010
default: 80
11-
run-dependencies-check:
12-
description: Whether to run the dependency health check during CI.
13-
required: false
14-
type: boolean
15-
default: true
1611
max-outdated:
1712
description: Maximum number of outdated packages allowed by the dependencies command.
1813
required: false
1914
type: number
20-
default: 5
15+
default: -1
2116
workflow_dispatch:
2217
inputs:
2318
min-coverage:
2419
description: Minimum line coverage percentage enforced by dev-tools tests.
2520
required: false
2621
type: number
2722
default: 80
28-
run-dependencies-check:
29-
description: Whether to run the dependency health check during CI.
30-
required: false
31-
type: boolean
32-
default: true
3323
max-outdated:
3424
description: Maximum number of outdated packages allowed by the dependencies command.
3525
required: false
3626
type: number
37-
default: 5
27+
default: -1
3828
pull_request:
3929
paths:
4030
- 'src/**'
@@ -126,9 +116,7 @@ jobs:
126116
dependency-health:
127117
needs: resolve_php
128118
name: Dependency Health
129-
if: ${{ github.event_name != 'workflow_call' || inputs.run-dependencies-check }}
130119
runs-on: ubuntu-latest
131-
continue-on-error: true
132120
env:
133121
TESTS_ROOT_VERSION: ${{ github.event_name == 'pull_request' && format('dev-{0}', github.event.pull_request.head.ref) || 'dev-main' }}
134122
FORCE_COLOR: '1'
@@ -162,4 +150,4 @@ jobs:
162150
- name: Run dependency health check
163151
env:
164152
COMPOSER_ROOT_VERSION: ${{ env.TESTS_ROOT_VERSION }}
165-
run: composer dev-tools dependencies -- --max-outdated=${{ inputs.max-outdated || 5 }}
153+
run: composer dev-tools dependencies -- --max-outdated=${{ inputs.max-outdated || -1 }}

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
### Changed
11+
12+
- Consolidate dependency analysis on `composer-dependency-analyser`, add a reusable packaged analyzer config, remove the redundant `composer-unused` dependency, and expose `--dump-usage` plus report-only `--max-outdated=-1` support (#135)
13+
1014
## [1.14.0] - 2026-04-20
1115

1216
### Added

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,12 @@ You can also run individual commands for specific development tasks:
6060
# Run PHPUnit tests
6161
composer dev-tools tests
6262

63-
# Analyze missing, unused, and outdated Composer dependencies
63+
# Analyze missing, unused, misplaced, and outdated Composer dependencies
6464
composer dependencies
6565
composer dependencies --max-outdated=8
66+
composer dependencies --max-outdated=-1
6667
composer dependencies --dev
68+
composer dependencies --dump-usage=symfony/console
6769
composer dependencies --upgrade --dev
6870

6971
# Analyze code metrics with PhpMetrics

composer-dependency-analyser.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
/**
6+
* Fast Forward Development Tools for PHP projects.
7+
*
8+
* This file is part of fast-forward/dev-tools project.
9+
*
10+
* @author Felipe Sayão Lobato Abreu <github@mentordosnerds.com>
11+
* @license https://opensource.org/licenses/MIT MIT License
12+
*
13+
* @see https://github.com/php-fast-forward/
14+
* @see https://github.com/php-fast-forward/dev-tools
15+
* @see https://github.com/php-fast-forward/dev-tools/issues
16+
* @see https://php-fast-forward.github.io/dev-tools/
17+
* @see https://datatracker.ietf.org/doc/html/rfc2119
18+
*/
19+
20+
use FastForward\DevTools\Config\ComposerDependencyAnalyserConfig;
21+
22+
return ComposerDependencyAnalyserConfig::configure();

composer.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@
4949
"fakerphp/faker": "^1.24",
5050
"fast-forward/phpdoc-bootstrap-template": "^2.0",
5151
"friendsofphp/php-cs-fixer": "^3.95",
52-
"icanhazstring/composer-unused": "^0.9.6",
5352
"jolicode/jolinotif": "^3.3",
5453
"nikic/php-parser": "^5.7",
5554
"php-di/php-di": "^7.1",
@@ -68,7 +67,7 @@
6867
"rector/jack": "^0.5",
6968
"rector/rector": "^2.4",
7069
"saggre/phpdocumentor-markdown": "^1.0",
71-
"sebastian/diff": "^7.0",
70+
"sebastian/diff": "^7.0 || ^8.0",
7271
"shipmonk/composer-dependency-analyser": "^1.8.4",
7372
"symfony/config": "^7.4 || ^8.0",
7473
"symfony/console": "^7.4 || ^8.0",

docs/api/commands.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ subprocess execution is needed.
4747
- Runs PHPUnit with optional coverage output.
4848
* - ``FastForward\DevTools\Console\Command\DependenciesCommand``
4949
- ``dependencies``
50-
- Reports missing, unused, and outdated Composer dependencies.
50+
- Reports missing, unused, misplaced, and outdated Composer dependencies.
5151
* - ``FastForward\DevTools\Console\Command\MetricsCommand``
5252
- ``metrics``
5353
- Builds the PhpMetrics site and JSON artifacts for the current project.

docs/commands/dependencies.rst

Lines changed: 39 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
11
dependencies
22
=============
33

4-
Analyzes missing, unused, and outdated Composer dependencies.
4+
Analyzes missing, unused, misplaced, and outdated Composer dependencies.
55

66
Description
77
-----------
88

9-
The ``dependencies`` command (alias: ``deps``) analyzes missing, unused, and
10-
overly outdated Composer dependencies using three tools:
9+
The ``dependencies`` command (alias: ``deps``) analyzes missing, unused,
10+
misplaced, and overly outdated Composer dependencies using two tools:
1111

12-
- ``composer-unused`` - detects unused packages
13-
- ``composer-dependency-analyser`` - detects missing packages
12+
- ``composer-dependency-analyser`` - detects missing, unused, and misplaced packages
1413
- ``jack breakpoint`` - fails when too many outdated packages accumulate
1514

1615
These analyzers ship as direct dependencies of ``fast-forward/dev-tools``, so
@@ -35,6 +34,9 @@ Options
3534

3635
Default: ``5``.
3736

37+
Use ``-1`` to keep the outdated dependency report in the output while
38+
ignoring Jack failures in the final command status.
39+
3840
``--upgrade`` (optional)
3941
Applies the Jack upgrade workflow before the analyzers:
4042

@@ -49,6 +51,10 @@ Options
4951
``--dev`` (optional)
5052
Prioritizes dev dependencies where Jack supports it.
5153

54+
``--dump-usage=<package>`` (optional)
55+
Asks ``composer-dependency-analyser`` to dump usages for the given package
56+
or wildcard pattern and enables ``--show-all-usages`` automatically.
57+
5258
Examples
5359
--------
5460

@@ -64,12 +70,24 @@ Allow up to 10 outdated packages:
6470
6571
composer dependencies --max-outdated=10
6672
73+
Report outdated packages without failing on their count:
74+
75+
.. code-block:: bash
76+
77+
composer dependencies --max-outdated=-1
78+
6779
Preview the upgrade workflow:
6880

6981
.. code-block:: bash
7082
7183
composer dependencies --dev
7284
85+
Dump all matched usages for one package:
86+
87+
.. code-block:: bash
88+
89+
composer dependencies --dump-usage=symfony/console
90+
7391
Apply the upgrade workflow and then analyze dependencies:
7492

7593
.. code-block:: bash
@@ -91,7 +109,7 @@ Exit Codes
91109
* - Code
92110
- Meaning
93111
* - 0
94-
- Success. No missing, unused, or excessive outdated dependencies.
112+
- Success. No missing, unused, misplaced, or excessive outdated dependencies.
95113
* - 1
96114
- Failure. A dependency analyzer or Jack reported findings or errors.
97115

@@ -100,14 +118,22 @@ Behavior
100118

101119
- Always previews or applies ``jack raise-to-installed`` first and then
102120
``jack open-versions`` before running the analyzers.
103-
- Runs ``composer-unused``, ``composer-dependency-analyser``, and
104-
``jack breakpoint`` after the Jack preview or upgrade phase.
121+
- Runs ``composer-dependency-analyser`` and ``jack breakpoint`` after the Jack
122+
preview or upgrade phase.
105123
- ``composer-dependency-analyser`` is configured with:
106-
- ``--ignore-unused-deps`` (leaves unused detection to ``composer-unused``)
107-
- ``--ignore-prod-only-in-dev-deps`` (ignores dev-only usage in production code)
124+
- ``--config composer-dependency-analyser.php`` (resolved through the package
125+
file locator so consumer repositories can override it locally)
126+
- the packaged ``composer-dependency-analyser.php`` delegates to
127+
``FastForward\DevTools\Config\ComposerDependencyAnalyserConfig`` so
128+
consumer repositories can extend the baseline instead of copying it whole
129+
- ``--dump-usages <package>`` and ``--show-all-usages`` when ``--dump-usage``
130+
is passed to the DevTools command
108131
- ``jack breakpoint`` maps ``--max-outdated`` to Jack's ``--limit`` option.
132+
- ``--max-outdated=-1`` keeps ``jack breakpoint`` in the workflow for reporting,
133+
but its failure is ignored so only missing or unused dependency findings fail
134+
the command.
109135
- ``--upgrade`` applies Jack's ``raise-to-installed`` and ``open-versions``
110136
commands before ``composer update -W`` and ``composer normalize``.
111-
- Returns a non-zero exit code when missing, unused, or too many outdated
112-
dependencies are found.
113-
- All three tools must be available in ``vendor/bin/``.
137+
- Returns a non-zero exit code when missing, unused, misplaced, or too many
138+
outdated dependencies are found.
139+
- Both tools must be available in ``vendor/bin/``.

docs/configuration/overriding-defaults.rst

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ Commands and Their Configuration Files
3535
* - ``tests``
3636
- ``phpunit.xml``
3737
- Falls back to the packaged PHPUnit configuration.
38+
* - ``dependencies``
39+
- ``composer-dependency-analyser.php``
40+
- Falls back to the packaged Composer Dependency Analyser configuration.
3841
* - ``phpdoc``
3942
- ``.php-cs-fixer.dist.php`` and ``rector.php``
4043
- Falls back to the packaged files; ``.docheader`` is created locally
@@ -111,6 +114,33 @@ This approach:
111114
- Automatically receives upstream updates
112115
- Only requires overriding what is needed
113116

117+
Extending Composer Dependency Analyser Configuration
118+
----------------------------------------------------
119+
120+
Instead of copying the entire ``composer-dependency-analyser.php`` file,
121+
consumers can extend the default configuration using the
122+
``ComposerDependencyAnalyserConfig`` class:
123+
124+
.. code-block:: php
125+
126+
<?php
127+
128+
use FastForward\DevTools\Config\ComposerDependencyAnalyserConfig;
129+
use ShipMonk\ComposerDependencyAnalyser\Config\Configuration;
130+
use ShipMonk\ComposerDependencyAnalyser\Config\ErrorType;
131+
132+
return ComposerDependencyAnalyserConfig::configure(
133+
static function (Configuration $configuration): void {
134+
$configuration->ignoreErrorsOnPackage(
135+
'vendor/package',
136+
[ErrorType::UNUSED_DEPENDENCY],
137+
);
138+
}
139+
);
140+
141+
This approach keeps the Fast Forward baseline while letting consumer
142+
repositories add project-specific ignores or scan rules.
143+
114144
What Is Not Overwritten Automatically
115145
--------------------------------------
116146

docs/faq.rst

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,30 @@ Use the ``RectorConfig`` class to extend instead of replace:
142142
143143
This approach automatically receives upstream updates while allowing additive customization.
144144

145+
How do I extend the dependency analyser configuration without copying the whole file?
146+
-------------------------------------------------------------------------------------
147+
148+
Use the ``ComposerDependencyAnalyserConfig`` class to extend instead of replace:
149+
150+
.. code-block:: php
151+
152+
<?php
153+
154+
use FastForward\DevTools\Config\ComposerDependencyAnalyserConfig;
155+
use ShipMonk\ComposerDependencyAnalyser\Config\Configuration;
156+
use ShipMonk\ComposerDependencyAnalyser\Config\ErrorType;
157+
158+
return ComposerDependencyAnalyserConfig::configure(
159+
static function (Configuration $configuration): void {
160+
$configuration->ignoreErrorsOnPackage(
161+
'vendor/package',
162+
[ErrorType::UNUSED_DEPENDENCY],
163+
);
164+
}
165+
);
166+
167+
This keeps the packaged baseline while allowing project-specific analyser ignores.
168+
145169
Can I generate coverage without running the full ``standards`` pipeline?
146170
------------------------------------------------------------------------
147171

0 commit comments

Comments
 (0)