From cf7fb7a551e5c28dc6fd3541dc37956bd34aef88 Mon Sep 17 00:00:00 2001 From: Dmitry Khomutov Date: Sat, 20 Jan 2018 13:09:30 +0700 Subject: [PATCH] Improved Pdepend plugin. Issue #107. --- .gitignore | 2 ++ public/artifacts/.gitkeep | 0 src/PHPCensor/Plugin/Pdepend.php | 34 +++++++++++++++++++------------- 3 files changed, 22 insertions(+), 14 deletions(-) create mode 100644 public/artifacts/.gitkeep diff --git a/.gitignore b/.gitignore index a75df016..57a654d7 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,5 @@ /runtime /app/config.yml /public/assets/vendor +/public/artifacts +!/public/artifacts/.gitkeep diff --git a/public/artifacts/.gitkeep b/public/artifacts/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/src/PHPCensor/Plugin/Pdepend.php b/src/PHPCensor/Plugin/Pdepend.php index 1b93588b..b8fe1bcd 100644 --- a/src/PHPCensor/Plugin/Pdepend.php +++ b/src/PHPCensor/Plugin/Pdepend.php @@ -8,13 +8,18 @@ use PHPCensor\Plugin; /** * Pdepend Plugin - Allows Pdepend report - * + * * @author Johan van der Heide */ class Pdepend extends Plugin { protected $args; + /** + * @var string + */ + protected $buildDirectory; + /** * @var string Directory which needs to be scanned */ @@ -56,13 +61,16 @@ class Pdepend extends Plugin { parent::__construct($builder, $build, $options); - $this->directory = isset($options['directory']) ? $options['directory'] : $this->builder->buildPath; + $this->directory = isset($options['directory']) + ? $options['directory'] + : $this->builder->buildPath; - $title = $this->builder->getBuildProjectTitle(); - $this->summary = $title . '-summary.xml'; - $this->pyramid = $title . '-pyramid.svg'; - $this->chart = $title . '-chart.svg'; - $this->location = $this->builder->buildPath . '..' . DIRECTORY_SEPARATOR . 'pdepend'; + $this->summary = 'summary.xml'; + $this->pyramid = 'pyramid.svg'; + $this->chart = 'chart.svg'; + + $this->buildDirectory = $build->getProjectId() . '/' . $build->getId(); + $this->location = PUBLIC_DIR . 'artifacts/pdepend/' . $this->buildDirectory; } /** @@ -71,7 +79,7 @@ class Pdepend extends Plugin public function execute() { if (!file_exists($this->location)) { - mkdir($this->location); + mkdir($this->location, 0777, true); } if (!is_writable($this->location)) { throw new \Exception(sprintf('The location %s is not writable or does not exist.', $this->location)); @@ -104,12 +112,10 @@ class Pdepend extends Plugin if ($success) { $this->builder->logSuccess( sprintf( - "Pdepend successful. You can use %s\n, ![Chart](%s \"Pdepend Chart\")\n - and ![Pyramid](%s \"Pdepend Pyramid\")\n - for inclusion in the readme.md file", - $config['url'] . '/build/pdepend/' . $this->summary, - $config['url'] . '/build/pdepend/' . $this->chart, - $config['url'] . '/build/pdepend/' . $this->pyramid + "\nPdepend successful.\nYou can use: %s,\n![Chart](%s \"Pdepend Chart\") and\n![Pyramid](%s \"Pdepend Pyramid\")\nfor inclusion in the readme.md file", + $config['url'] . '/artifacts/pdepend/' . $this->buildDirectory . '/' . $this->summary, + $config['url'] . '/artifacts/pdepend/' . $this->buildDirectory . '/' . $this->chart, + $config['url'] . '/artifacts/pdepend/' . $this->buildDirectory . '/' . $this->pyramid ) ); }