Permalink
Browse files

- Do not report self duplicates.

  • Loading branch information...
1 parent 47a8833 commit 5e428cab65257298d957cadfd051ca40464c0f3e @sebastianbergmann committed Jul 9, 2008
Showing with 18 additions and 8 deletions.
  1. +18 −8 PHPUnit/Util/Metrics/Project.php
@@ -424,13 +424,18 @@ protected function copyPasteDetection($minLines, $minMatches)
}
} else {
if ($found) {
- if ($line + 1 - $firstLine > $minLines) {
+ $fileA = $this->cpdHashes[$firstHash][0];
+ $firstLineA = $this->cpdHashes[$firstHash][1];
+
+ if ($line + 1 - $firstLine > $minLines &&
+ ($fileA->getPath() != $file->getPath() ||
+ $firstLineA != $firstLine)) {
$this->cpdDuplicates[] = array(
- 'fileA' => $this->cpdHashes[$firstHash][0],
- 'firstLineA' => $this->cpdHashes[$firstHash][1],
+ 'fileA' => $fileA,
+ 'firstLineA' => $firstLineA,
'fileB' => $file,
'firstLineB' => $firstLine,
- 'numLines' => $line + 1 - $firstLine,
+ 'numLines' => $line + 1 - $firstLine,
'numTokens' => $tokenNr + 1 - $firstToken
);
}
@@ -448,13 +453,18 @@ protected function copyPasteDetection($minLines, $minMatches)
}
if ($found) {
- if ($line + 1 - $firstLine > $minLines) {
+ $fileA = $this->cpdHashes[$firstHash][0];
+ $firstLineA = $this->cpdHashes[$firstHash][1];
+
+ if ($line + 1 - $firstLine > $minLines &&
+ ($fileA->getPath() != $file->getPath() ||
+ $firstLineA != $firstLine)) {
$this->cpdDuplicates[] = array(
- 'fileA' => $this->cpdHashes[$firstHash][0],
- 'firstLineA' => $this->cpdHashes[$firstHash][1],
+ 'fileA' => $fileA,
+ 'firstLineA' => $firstLineA,
'fileB' => $file,
'firstLineB' => $firstLine,
- 'numLines' => $line + 1 - $firstLine,
+ 'numLines' => $line + 1 - $firstLine,
'numTokens' => $tokenNr + 1 - $firstToken
);
}

0 comments on commit 5e428ca

Please sign in to comment.