diff --git a/ahoy.test.yml b/ahoy.test.yml
index 253446d49fe65b3dfdd6a829018ef147fb9899d4..60eaabda969cac1bdcfdde43c9c100c2c028ef62 100644
--- a/ahoy.test.yml
+++ b/ahoy.test.yml
@@ -39,7 +39,8 @@ commands:
     cmd: |
       module=$1
       shift
-      ahoy d4d exec vendor/bin/phpunit --configuration /var/www/html/tests/phpunit.xml.dist web/modules/contrib/$module $@
+      mkdir -p tests/junit
+      ahoy d4d exec vendor/bin/phpunit --log-junit tests/junit/${module}.xml --configuration /var/www/html/tests/phpunit.xml.dist web/modules/contrib/$module $@
     usage: PHP unit tests by module
   phpunit:list:suites:
     cmd: ahoy d4d exec vendor/bin/phpunit --configuration /var/www/html/tests/phpunit.xml.dist --list-suites "$@"
@@ -64,3 +65,12 @@ commands:
       shift
       ahoy d4d exec vendor/bin/parallel-lint web/modules/contrib/$module $@
     usage: PHP lint tests by module
+  phpmetricsmodule:
+    cmd: |
+      module=$1
+      shift
+      mkdir -p tests/metrics/$module
+      JUNIT=
+      if [[ -f tests/junit/${module}.xml ]]; then JUNIT=--junit=tests/junit/${module}.xml; fi
+      ahoy d4d exec vendor/bin/phpmetrics --report-html=tests/metrics/$module $JUNIT web/modules/contrib/$module $@
+    usage: PHP Metrics by module
diff --git a/composer.json b/composer.json
index 36568ce1469021c0a3974f8d4873d105d2b525f7..ae6760cc2564feae7f42225e1ed62684267ccc40 100644
--- a/composer.json
+++ b/composer.json
@@ -62,6 +62,7 @@
         "php-parallel-lint/php-parallel-lint": "^1.3",
         "phploc/phploc": "*",
         "phpmd/phpmd": "*",
+        "phpmetrics/phpmetrics": "^2.8",
         "phpspec/prophecy": "*",
         "phpspec/prophecy-phpunit": "*",
         "phpstan/phpstan-deprecation-rules": "*",
diff --git a/src/Handler.php b/src/Handler.php
index af22b296423cb445613fbb8788527b22ff725190..009ebef76ca747d38dc2e01ec35472ce655de910 100644
--- a/src/Handler.php
+++ b/src/Handler.php
@@ -132,6 +132,8 @@ class Handler extends BaseHandler {
     $this->gitIgnore('tests/codesniffer_results.txt');
     $this->gitIgnore('tests/checkstyle.xml');
     $this->gitIgnore('tests/codesniffer_fixes.patch');
+    $this->gitIgnore('tests/junit');
+    $this->gitIgnore('tests/metrics');
 
     // Git Ignore output from simpletest.
     $this->gitIgnore('web/sites/simpletest');