Skip to content

Commit

Permalink
Improved Pdepend plugin. Issue #107.
Browse files Browse the repository at this point in the history
  • Loading branch information
corpsee committed Jan 20, 2018
1 parent 4956775 commit cf7fb7a
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 14 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Expand Up @@ -3,3 +3,5 @@
/runtime
/app/config.yml
/public/assets/vendor
/public/artifacts
!/public/artifacts/.gitkeep
Empty file added public/artifacts/.gitkeep
Empty file.
34 changes: 20 additions & 14 deletions src/PHPCensor/Plugin/Pdepend.php
Expand Up @@ -8,13 +8,18 @@

/**
* 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
*/
Expand Down Expand Up @@ -56,13 +61,16 @@ public function __construct(Builder $builder, Build $build, array $options = [])
{
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;

$this->summary = 'summary.xml';
$this->pyramid = 'pyramid.svg';
$this->chart = 'chart.svg';

$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->buildDirectory = $build->getProjectId() . '/' . $build->getId();
$this->location = PUBLIC_DIR . 'artifacts/pdepend/' . $this->buildDirectory;
}

/**
Expand All @@ -71,7 +79,7 @@ public function __construct(Builder $builder, Build $build, array $options = [])
public function execute()
{
if (!file_exists($this->location)) {
mkdir($this->location);
mkdir($this->location, 0777, true);

This comment has been minimized.

Copy link
@SimonHeimberg

SimonHeimberg Jan 30, 2018

Contributor

Do we really want 0777, or is 0755 better (readable for everybody, writable only for user)?

This comment has been minimized.

Copy link
@corpsee

corpsee Jan 30, 2018

Author Member

You are right, thanks @SimonHeimberg!

}
if (!is_writable($this->location)) {
throw new \Exception(sprintf('The location %s is not writable or does not exist.', $this->location));
Expand Down Expand Up @@ -104,12 +112,10 @@ public function execute()
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
)
);
}
Expand Down

0 comments on commit cf7fb7a

Please sign in to comment.