diff --git a/composer.json b/composer.json index ef0d7bb1..f596757e 100644 --- a/composer.json +++ b/composer.json @@ -10,15 +10,16 @@ } ], "require": { - "consolidation/robo": "^1.4 || ^2 || ^3", + "consolidation/robo": "^3.0", "squizlabs/php_codesniffer": "^3.5", "phpstan/phpstan": "^0.12.77", "phpstan/phpstan-deprecation-rules": "^0.12.6", "async-aws/s3": "^1.8", "php": ">=7.4", - "drush/drush": "^8 || ^10", + "drush/drush": "^10.6.1", "webflo/drupal-finder": "^1.2", - "vincentlanglet/twig-cs-fixer": "^0.4.1" + "vincentlanglet/twig-cs-fixer": "^0.4.1", + "nunomaduro/phpinsights": "^2.0" }, "autoload": { "psr-4": { diff --git a/src/Robo/Plugin/Commands/CICommands.php b/src/Robo/Plugin/Commands/CICommands.php index d32fddc0..edf34364 100644 --- a/src/Robo/Plugin/Commands/CICommands.php +++ b/src/Robo/Plugin/Commands/CICommands.php @@ -41,6 +41,13 @@ class CICommands extends Tasks */ protected $lintTwigFiles; + /** + * Boolean indicating whether architecture checks should be run. + * + * @var bool + */ + protected $runArchitectureAnalysis; + /** * RoboFile constructor. */ @@ -53,6 +60,7 @@ public function __construct() $this->phpcsIgnorePaths = Robo::config()->get('phpcs_ignore_paths'); $this->customCodePaths = implode(' ', $this->getCustomCodePaths()); $this->lintTwigFiles = Robo::config()->get('twig_lint_enable', true); + $this->runArchitectureAnalysis = Robo::config()->get('architecture_analysis_enable', true); } /** @@ -107,6 +115,9 @@ public function jobCheckCodingStandards(): Result if ($this->lintTwigFiles) { $stack->exec("vendor/bin/twig-cs-fixer lint $this->customCodePaths"); } + if ($this->runArchitectureAnalysis) { + $this->runArchitectureAnalysis(); + } return $stack->run(); } @@ -135,6 +146,18 @@ public function jobFixCodingStandards(): Result return $stack->run(); } + /** + * Command to run architecture analysis. + * + * @return \Robo\Result + * The result of the collection of tasks. + * + * @throws \Robo\Exception\TaskException + */ + public function jobRunArchitectureAnalysis(): Result { + return $this->runArchitectureAnalysis(); + } + /** * Get custom code paths for static analysis tools to use. * @@ -166,4 +189,20 @@ protected function getCodingStandards(): array } return $phpcsStandards; } + + /** + * Run architecture checks. + * + * @return null|\Robo\Result + * The result of the set of tasks. + * + * @throws \Robo\Exception\TaskException + */ + protected function runArchitectureAnalysis(): Result + { + return $this->taskExecStack() + ->stopOnFail() + ->exec("./vendor/bin/phpinsights analyse --no-interaction $this->customCodePaths --min-quality=100 --min-complexity=100 --min-architecture=100 --min-style=100") + ->run(); + } }