Skip to content

Commit ef03086

Browse files
F#78299 US#190650 T#207172 add the support of multi coverage file for the baseline command + raises an error when the custom coverage can be increased
1 parent 1c5eac4 commit ef03086

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

src/Lib/Metrics/Inspection/CustomCoverageAboveGlobalInspection.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@ public function inspect(?PathInspectionConfig $fileConfig, FileMetric $metric):
2323
$globalCoverage = $this->config->getMinimumCoverage();
2424
$customCoverage = $fileConfig->getMinimumCoverage();
2525

26-
// custom coverage is lower than global coverage, and file is above global coverage
27-
if ($customCoverage <= $globalCoverage && $metric->getCoverage() >= $globalCoverage) {
26+
if ($customCoverage >= $globalCoverage || $metric->getCoverage() >= $globalCoverage) {
2827
return new Failure($metric, $fileConfig->getMinimumCoverage(), Failure::UNNECESSARY_CUSTOM_COVERAGE);
2928
}
3029

tests/Unit/Lib/Metrics/MetricsAnalyzerTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public function testAnalyzeFileWithCustomCoverageRuleShouldPass(): void
4141
{
4242
$metrics[] = new FileMetric('/a/b/c/test.php', 0, 45, [], []);
4343
$config = new InspectionConfig('/a/', 80, false);
44-
$config->addPathInspection(new PathInspectionConfig(PathInspectionConfig::TYPE_FILE, 'b/c/test.php', 40));
44+
$config->addPathInspection(new PathInspectionConfig(PathInspectionConfig::TYPE_FILE, 'b/c/test.php', 45));
4545

4646
$analyzer = new MetricsAnalyzer($metrics, $config);
4747
$result = $analyzer->analyze();
@@ -66,12 +66,12 @@ public function testAnalyzeFileWithCustomCoverageAboveGlobalCoverageShouldFail()
6666
$metric = new FileMetric('/a/b/c/test.php', 0, 90, [], []);
6767
$metrics = [$metric];
6868
$config = new InspectionConfig('/a/', 80, false);
69-
$config->addPathInspection(new PathInspectionConfig(PathInspectionConfig::TYPE_FILE, 'b/c/test.php', 50));
69+
$config->addPathInspection(new PathInspectionConfig(PathInspectionConfig::TYPE_FILE, 'b/c/test.php', 90));
7070

7171
$analyzer = new MetricsAnalyzer($metrics, $config);
7272
$result = $analyzer->analyze();
7373
static::assertCount(1, $result);
74-
static::assertEquals([new Failure($metric, 50, Failure::UNNECESSARY_CUSTOM_COVERAGE)], $result);
74+
static::assertEquals([new Failure($metric, 90, Failure::UNNECESSARY_CUSTOM_COVERAGE)], $result);
7575
}
7676

7777
public function testAnalyzeFileWithUncoveredMethodsShouldFail(): void

0 commit comments

Comments
 (0)