Skip to content

Commit 281774f

Browse files
committed
whitespace, credit
1 parent 0c7c545 commit 281774f

File tree

1 file changed

+75
-74
lines changed

1 file changed

+75
-74
lines changed

PHP/CodeCoverage/Report/Crap4j.php

Lines changed: 75 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@
44
* PHP_CodeCoverage_Report_Crap4j
55
*
66
* @author oker <[email protected]>
7+
* @author pepov <[email protected]>
78
*/
89
class PHP_CodeCoverage_Report_Crap4j
910
{
10-
private $treshHold = 30;
11+
private $treshHold = 30;
1112

1213
/**
1314
* @param PHP_CodeCoverage $coverage
@@ -27,15 +28,15 @@ public function process(PHP_CodeCoverage $coverage, $target = NULL, $name = NULL
2728
$root->appendChild($project);
2829
$root->appendChild($document->createElement('timestamp', date('Y-m-d H:i:s', (int)$_SERVER['REQUEST_TIME'])));
2930

30-
$stats = $document->createElement('stats');
31+
$stats = $document->createElement('stats');
3132
$methodsNode = $document->createElement('methods');
3233

3334
$files = $coverage->getSummary();
3435

35-
$fullMethodCount = 0;
36-
$fullCrapMethodCount = 0;
37-
$fullCrapLoad = 0;
38-
$fullCrap = 0;
36+
$fullMethodCount = 0;
37+
$fullCrapMethodCount = 0;
38+
$fullCrapLoad = 0;
39+
$fullCrap = 0;
3940

4041
foreach ($files as $filename => $data) {
4142

@@ -77,34 +78,34 @@ public function process(PHP_CodeCoverage $coverage, $target = NULL, $name = NULL
7778

7879
foreach ($_class['methods'] as $methodName => $method) {
7980

80-
$methodCount = 0;
81-
$methodLines = 0;
82-
$methodLinesCovered = 0;
83-
$this->methodsDetails($method, $ignoredLines, $files, $filename, $classStatistics, $lines, $methodCount, $methodLines, $methodLinesCovered);
81+
$methodCount = 0;
82+
$methodLines = 0;
83+
$methodLinesCovered = 0;
84+
$this->methodsDetails($method, $ignoredLines, $files, $filename, $classStatistics, $lines, $methodCount, $methodLines, $methodLinesCovered);
8485

85-
$fullMethodCount++;
86+
$fullMethodCount++;
8687

8788
$coveragePercent = PHP_CodeCoverage_Util::percent(
8889
$methodLinesCovered,
8990
$methodLines
9091
);
9192
$crap = PHP_CodeCoverage_Util::crap($method['ccn'], $coveragePercent);
92-
$fullCrap += $crap;
93+
$fullCrap += $crap;
9394

94-
if ($crap >= $this->treshHold) {
95-
$fullCrapMethodCount++;
96-
}
95+
if ($crap >= $this->treshHold) {
96+
$fullCrapMethodCount++;
97+
}
9798

98-
$crapLoad = $this->getCrapLoad($crap, $method['ccn'], $coveragePercent);
99+
$crapLoad = $this->getCrapLoad($crap, $method['ccn'], $coveragePercent);
99100

100-
$fullCrapLoad += $crapLoad;
101+
$fullCrapLoad += $crapLoad;
101102

102103
$methodNode = $document->createElement('method');
103104

104105
$methodNode->appendChild($document->createElement('package', ''));
105106
$methodNode->appendChild($document->createElement('className', $className));
106107
$methodNode->appendChild($document->createElement('methodName', $methodName));
107-
$methodNode->appendChild($document->createElement('methodSignature', htmlspecialchars($method['signature'])));
108+
$methodNode->appendChild($document->createElement('methodSignature', htmlspecialchars($method['signature'])));
108109
$methodNode->appendChild($document->createElement('fullMethod', htmlspecialchars($method['signature'])));
109110
$methodNode->appendChild($document->createElement('crap', $this->roundValue($crap)));
110111
$methodNode->appendChild($document->createElement('complexity', $method['ccn']));
@@ -125,14 +126,14 @@ public function process(PHP_CodeCoverage $coverage, $target = NULL, $name = NULL
125126

126127
$stats->appendChild($document->createElement('name', 'Method Crap Stats'));
127128

128-
$stats->appendChild($document->createElement('methodCount', $fullMethodCount));
129-
$stats->appendChild($document->createElement('crapMethodCount', $fullCrapMethodCount));
129+
$stats->appendChild($document->createElement('methodCount', $fullMethodCount));
130+
$stats->appendChild($document->createElement('crapMethodCount', $fullCrapMethodCount));
130131
$stats->appendChild($document->createElement('crapLoad', round($fullCrapLoad)));
131-
$stats->appendChild($document->createElement('totalCrap', $fullCrap));
132-
$stats->appendChild($document->createElement('crapMethodPercent', $this->roundValue(100 * $fullCrapMethodCount / $fullMethodCount)));
132+
$stats->appendChild($document->createElement('totalCrap', $fullCrap));
133+
$stats->appendChild($document->createElement('crapMethodPercent', $this->roundValue(100 * $fullCrapMethodCount / $fullMethodCount)));
133134

134135
$root->appendChild($stats);
135-
$root->appendChild($methodsNode);
136+
$root->appendChild($methodsNode);
136137

137138
if ($target !== NULL) {
138139
if (!is_dir(dirname($target))) {
@@ -145,57 +146,57 @@ public function process(PHP_CodeCoverage $coverage, $target = NULL, $name = NULL
145146
}
146147
}
147148

148-
private function methodsDetails($method, $ignoredLines, $files, $filename, $classStatistics, $lines, &$methodCount, &$methodLines, &$methodLinesCovered)
149-
{
150-
for ($i = $method['startLine'];
151-
$i <= $method['endLine'];
152-
$i++) {
153-
if (isset($ignoredLines[$i])) {
154-
continue;
155-
}
156-
157-
$add = TRUE;
158-
$count = 0;
159-
160-
if (isset($files[$filename][$i])) {
161-
if ($files[$filename][$i] != -2) {
162-
$classStatistics['statements']++;
163-
$methodLines++;
164-
}
165-
166-
if (is_array($files[$filename][$i])) {
167-
$classStatistics['coveredStatements']++;
168-
$methodLinesCovered++;
169-
$count = count($files[$filename][$i]);
170-
}
171-
172-
else if ($files[$filename][$i] == -2) {
173-
$add = FALSE;
174-
}
175-
} else {
176-
$add = FALSE;
177-
}
178-
179-
$methodCount = max($methodCount, $count);
180-
181-
if ($add) {
182-
$lines[$i] = array(
183-
'count' => $count,
184-
'type' => 'stmt'
185-
);
186-
}
187-
}
188-
}
189-
190-
public function getCrapLoad($crapValue, $cyclomaticComplexity, $coveragePercent)
191-
{
192-
$crapLoad = 0;
193-
if ($crapValue > $this->treshHold) {
194-
$crapLoad += $cyclomaticComplexity * (1.0 - $coveragePercent / 100);
195-
$crapLoad += $cyclomaticComplexity / $this->treshHold;
196-
}
197-
return $crapLoad;
198-
}
149+
private function methodsDetails($method, $ignoredLines, $files, $filename, $classStatistics, $lines, &$methodCount, &$methodLines, &$methodLinesCovered)
150+
{
151+
for ($i = $method['startLine'];
152+
$i <= $method['endLine'];
153+
$i++) {
154+
if (isset($ignoredLines[$i])) {
155+
continue;
156+
}
157+
158+
$add = TRUE;
159+
$count = 0;
160+
161+
if (isset($files[$filename][$i])) {
162+
if ($files[$filename][$i] != -2) {
163+
$classStatistics['statements']++;
164+
$methodLines++;
165+
}
166+
167+
if (is_array($files[$filename][$i])) {
168+
$classStatistics['coveredStatements']++;
169+
$methodLinesCovered++;
170+
$count = count($files[$filename][$i]);
171+
}
172+
173+
else if ($files[$filename][$i] == -2) {
174+
$add = FALSE;
175+
}
176+
} else {
177+
$add = FALSE;
178+
}
179+
180+
$methodCount = max($methodCount, $count);
181+
182+
if ($add) {
183+
$lines[$i] = array(
184+
'count' => $count,
185+
'type' => 'stmt'
186+
);
187+
}
188+
}
189+
}
190+
191+
public function getCrapLoad($crapValue, $cyclomaticComplexity, $coveragePercent)
192+
{
193+
$crapLoad = 0;
194+
if ($crapValue > $this->treshHold) {
195+
$crapLoad += $cyclomaticComplexity * (1.0 - $coveragePercent / 100);
196+
$crapLoad += $cyclomaticComplexity / $this->treshHold;
197+
}
198+
return $crapLoad;
199+
}
199200

200201
private function roundValue($value)
201202
{

0 commit comments

Comments
 (0)