|
| 1 | +metrics |
| 2 | +======= |
| 3 | + |
| 4 | +Analyzes code metrics with PhpMetrics. |
| 5 | + |
| 6 | +Overview |
| 7 | +-------- |
| 8 | + |
| 9 | +The ``metrics`` command runs `PhpMetrics <https://phpmetrics.github.io/website/>`_ |
| 10 | +against the selected source directory, generates a JSON report, and prints a |
| 11 | +reduced summary with: |
| 12 | + |
| 13 | +- average cyclomatic complexity by class; |
| 14 | +- average maintainability index by class; |
| 15 | +- number of classes analyzed; |
| 16 | +- number of functions analyzed. |
| 17 | + |
| 18 | +Usage |
| 19 | +----- |
| 20 | + |
| 21 | +.. code-block:: bash |
| 22 | +
|
| 23 | + composer metrics |
| 24 | + composer dev-tools metrics -- [options] |
| 25 | + vendor/bin/dev-tools metrics [options] |
| 26 | +
|
| 27 | +Options |
| 28 | +------- |
| 29 | + |
| 30 | +``--src=<path>`` |
| 31 | + Source directory to analyze. |
| 32 | + |
| 33 | + Default: ``src``. |
| 34 | + |
| 35 | +``--exclude=<list>`` |
| 36 | + Comma-separated directories that should be excluded from analysis. |
| 37 | + |
| 38 | + Default: |
| 39 | + ``vendor,test,Test,tests,Tests,testing,Testing,bower_components,node_modules,cache,spec,build``. |
| 40 | + |
| 41 | +``--report-html=<directory>`` |
| 42 | + Optional output directory for the generated HTML report. |
| 43 | + |
| 44 | +``--report-json=<file>`` |
| 45 | + Optional output file for the generated JSON report. |
| 46 | + |
| 47 | +``--cache-dir=<directory>`` |
| 48 | + Cache directory used for temporary JSON reports when ``--report-json`` is |
| 49 | + not provided. |
| 50 | + |
| 51 | + Default: ``tmp/cache/phpmetrics``. |
| 52 | + |
| 53 | +Examples |
| 54 | +-------- |
| 55 | + |
| 56 | +Generate the reduced summary with defaults: |
| 57 | + |
| 58 | +.. code-block:: bash |
| 59 | +
|
| 60 | + composer metrics |
| 61 | +
|
| 62 | +Generate an HTML report for manual inspection: |
| 63 | + |
| 64 | +.. code-block:: bash |
| 65 | +
|
| 66 | + composer dev-tools metrics -- --report-html=build/metrics |
| 67 | +
|
| 68 | +Generate both JSON and HTML reports for CI artifacts: |
| 69 | + |
| 70 | +.. code-block:: bash |
| 71 | +
|
| 72 | + vendor/bin/dev-tools metrics --report-json=build/metrics.json --report-html=build/metrics |
| 73 | +
|
| 74 | +Behavior |
| 75 | +-------- |
| 76 | + |
| 77 | +- the command fails early when ``vendor/bin/phpmetrics`` is not installed; |
| 78 | +- the source directory must exist; |
| 79 | +- the reduced summary is derived from the generated PhpMetrics JSON report; |
| 80 | +- optional HTML and JSON report destinations are created before execution. |
0 commit comments