Skip to content

Commit

Permalink
Reports - searchable pdepend dependencies
Browse files Browse the repository at this point in the history
Inspired by dependencies in Qafoo
https://github.com/Qafoo/QualityAnalyzer
  • Loading branch information
zdenekdrahos committed Oct 15, 2016
1 parent 06c8ce6 commit 5907205
Show file tree
Hide file tree
Showing 4 changed files with 89 additions and 7 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ Tool | `--output file` (default) - generated files | `--output cli` |
phploc | [phploc.xml](https://edgedesigncz.github.io/phpqa/report/phploc.xml) | [](https://github.com/sebastianbergmann/phploc#analyse-a-directory-and-print-the-result) |
phpcpd | [phpcpd.xml](https://edgedesigncz.github.io/phpqa/report/phpcpd.xml) | [](https://github.com/sebastianbergmann/phpcpd#usage-example) |
phpcs | [checkstyle.xml](https://edgedesigncz.github.io/phpqa/report/checkstyle.xml) | [full report](https://github.com/squizlabs/PHP_CodeSniffer/wiki/Reporting#printing-full-and-summary-reports) |
pdepend | [pdepend-jdepend.xml](https://edgedesigncz.github.io/phpqa/report/pdepend-jdepend.xml), [pdepend-summary.xml](https://edgedesigncz.github.io/phpqa/report/pdepend-summary.xml), [pdepend-jdepend.svg](https://edgedesigncz.github.io/phpqa/report/pdepend-jdepend.svg), [pdepend-pyramid.svg](https://edgedesigncz.github.io/phpqa/report/pdepend-pyramid.svg) | ✗ |
pdepend | [pdepend-jdepend.xml](https://edgedesigncz.github.io/phpqa/report/pdepend-jdepend.xml), [pdepend-summary.xml](https://edgedesigncz.github.io/phpqa/report/pdepend-summary.xml), [pdepend-dependencies.xml](https://edgedesigncz.github.io/phpqa/report/pdepend-dependencies.xml), [pdepend-jdepend.svg](https://edgedesigncz.github.io/phpqa/report/pdepend-jdepend.svg), [pdepend-pyramid.svg](https://edgedesigncz.github.io/phpqa/report/pdepend-pyramid.svg) | ✗ |
phpmd | [phpmd.xml](https://edgedesigncz.github.io/phpqa/report/phpmd.xml) | [](https://github.com/phpmd/phpmd/blob/master/src/main/php/PHPMD/Renderer/TextRenderer.php#L47) |
phpmetrics | [phpmetrics.html](https://edgedesigncz.github.io/phpqa/report/phpmetrics.html), [phpmetrics.xml](https://edgedesigncz.github.io/phpqa/report/phpmetrics.xml) | [](https://github.com/phpmetrics/PhpMetrics#usage) |

Expand Down
90 changes: 85 additions & 5 deletions app/report/pdepend.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,13 @@
margin-right:2em;
}

.fixed-links {
.fixed-navbar {
list-style-type: none;
position: fixed;
top: 3em;
top: 0;
right: 1em;
}
.fixed-links li {
.fixed-navbar li {
display: inline-block;
margin-left: 1ex;
}
Expand Down Expand Up @@ -100,6 +100,9 @@
<li role="presentation">
<a href="#packages" aria-controls="packages" role="tab" data-toggle="tab">Packages</a>
</li>
<li role="presentation">
<a href="#dependencies" aria-controls="dependencies" role="tab" data-toggle="tab">Dependencies</a>
</li>
<li role="presentation">
<a href="#metrics" aria-controls="metrics" role="tab" data-toggle="tab">Metrics</a>
</li>
Expand Down Expand Up @@ -153,6 +156,9 @@
<div role="tabpanel" class="tab-pane" id="packages">
<xsl:apply-templates select="./Packages"></xsl:apply-templates>
</div>
<div role="tabpanel" class="tab-pane" id="dependencies">
<xsl:apply-templates select="./dependencies"></xsl:apply-templates>
</div>
<div role="tabpanel" class="tab-pane" id="metrics">
<xsl:apply-templates select="./metrics"></xsl:apply-templates>
</div>
Expand All @@ -171,7 +177,7 @@
<!-- XSL from https://github.com/elnebuloso/phing-commons/blob/cc8478f930b38fe7542542d9490128e73d707356/resources/ -->
<xsl:template match="Packages">

<ul class="fixed-links">
<ul class="fixed-navbar">
<li><a class="label label-default" href="#NVsummary">summary</a></li>
<li><a class="label label-default" href="#NVpackages">packages</a></li>
<li><a class="label label-default" href="#NVcycles">cycles</a></li>
Expand Down Expand Up @@ -358,9 +364,83 @@

</xsl:template>

<!-- inspired by Dependencies in Qafoo https://github.com/Qafoo/QualityAnalyzer/blob/master/src/images/screen.png -->
<xsl:template match="dependencies">
<div class="fixed-navbar">
<div class="input-group" style="width: 20em">
<span class="input-group-addon">Filter</span>
<input data-search="dependencies" type="text" class="form-control" placeholder="progressbar..." />
</div>
<small class="help-block">Results count: <strong data-results-count=""></strong></small>
</div>

<script>
onDocumentReady.push(function () {
var rows = $('[data-filterable] tbody tr');
var dependencies = rows.find('[data-dependency], small.text-muted');
var resultsCount = $('[data-results-count]');

$("[data-search]").keyup(function () {
var term = $(this).val().toLowerCase();

rows.hide();
var visibleRows = matchElements(rows);
visibleRows.show();
resultsCount.text(visibleRows.length);

dependencies.removeClass('highlight');
if (term) {
matchElements(dependencies).addClass('highlight');
}

function matchElements(elements) {
return elements.filter(function () {
var rowContent = $(this).text().toLowerCase();
return rowContent.indexOf(term) !== -1
});
}
});
});
</script>
<style>.highlight {background: yellow}</style>

<table class="table table-bordered details" data-filterable="dependencies">
<thead>
<tr>
<th>Dependency</th>
<th>Efferent Couplings</th>
<th>Afferent Couplings</th>
</tr>
</thead>
<xsl:for-each select="./package">
<xsl:for-each select="./*">
<tr>
<td>
<strong data-dependency="">
<xsl:value-of select="./../@name"/>\<xsl:value-of select="@name"/>
</strong>
<br />
<small class="text-muted"><xsl:value-of select="name(.)"/></small>
</td>
<td>
<xsl:for-each select="./efferent/type">
<span data-dependency=""><xsl:value-of select="@namespace" />\<xsl:value-of select="@name" /></span><br />
</xsl:for-each>
</td>
<td>
<xsl:for-each select="./afferent/type">
<span data-dependency=""><xsl:value-of select="@namespace" />\<xsl:value-of select="@name" /></span><br />
</xsl:for-each>
</td>
</tr>
</xsl:for-each>
</xsl:for-each>
</table>
</xsl:template>

<!-- XSL from https://gist.github.com/garex/5cd9b97c40f3369cb8cf60f253868df9 -->
<xsl:template match="metrics">
<div class="fixed-links">
<div class="fixed-navbar">
<div class="checkbox-inline">
<label>
<input type="checkbox" id="class-ranks" />
Expand Down
1 change: 1 addition & 0 deletions app/report/phpqa.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ set tabs = {
'pdepend': {
'overview': 'Overview',
'packages': 'Packages',
'dependencies': 'Dependencies',
'metrics': 'Metrics',
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/CodeAnalysisTasks.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ trait CodeAnalysisTasks
),
'pdepend' => array(
'optionSeparator' => '=',
'xml' => ['pdepend-jdepend.xml', 'pdepend-summary.xml'],
'xml' => ['pdepend-jdepend.xml', 'pdepend-summary.xml', 'pdepend-dependencies.xml'],
),
'phpcpd' => array(
'optionSeparator' => ' ',
Expand Down Expand Up @@ -181,6 +181,7 @@ private function pdepend()
return array(
'jdepend-xml' => $this->options->toFile('pdepend-jdepend.xml'),
'summary-xml' => $this->options->toFile('pdepend-summary.xml'),
'dependency-xml' => $this->options->toFile('pdepend-dependencies.xml'),
'jdepend-chart' => $this->options->toFile('pdepend-jdepend.svg'),
'overview-pyramid' => $this->options->toFile('pdepend-pyramid.svg'),
$this->options->ignore->pdepend(),
Expand Down

0 comments on commit 5907205

Please sign in to comment.