Skip to content

Commit

Permalink
Ignore files with a score of zero
Browse files Browse the repository at this point in the history
  • Loading branch information
villfa committed Nov 13, 2020
1 parent 4c1110e commit a91e619
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/Result/ResultAccumulator.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ public function __construct(int $maxSize, ?float $minScore)
*/
public function add(Result $result): void
{
if ($result->getPriority() === 0) {
return;
}
$this->numberOfFiles++;
if ($result->getCommits() > $this->maxCommits) {
$this->maxCommits = $result->getCommits();
Expand Down
11 changes: 11 additions & 0 deletions tests/Unit/Result/ResultAccumulatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,4 +88,15 @@ public function it_takes_min_score_into_account(): void

$this->assertEquals($expectedResult, $accumulator->toArray());
}

/** @test */
public function it_ignores_files_with_a_score_of_zero(): void
{
$accumulator = new ResultAccumulator(10, 0.1);
$accumulator->add($this->mockResult(0, 1, 'file1', 0.3));
$accumulator->add($this->mockResult(1, 0, 'file2', 0.2));
$accumulator->add($this->mockResult(0, 0, 'file3', 0.1));

$this->assertEquals(0, $accumulator->getNumberOfFiles());
}
}

0 comments on commit a91e619

Please sign in to comment.