Improved Pdepend plugin. Issue #107.

This commit is contained in:
Dmitry Khomutov 2018-01-20 13:09:30 +07:00
parent 4956775121
commit cf7fb7a551
No known key found for this signature in database
GPG key ID: EC19426474B37AAC
3 changed files with 22 additions and 14 deletions

2
.gitignore vendored
View file

@ -3,3 +3,5 @@
/runtime
/app/config.yml
/public/assets/vendor
/public/artifacts
!/public/artifacts/.gitkeep

View file

View file

@ -8,13 +8,18 @@ use PHPCensor\Plugin;
/**
* Pdepend Plugin - Allows Pdepend report
*
*
* @author Johan van der Heide <info@japaveh.nl>
*/
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
)
);
}