diff --git a/e2e/parallel-unused-skips/expected-output.diff b/e2e/parallel-unused-skips/expected-output.diff index 4d79f6e708c..adbcf14bc47 100644 --- a/e2e/parallel-unused-skips/expected-output.diff +++ b/e2e/parallel-unused-skips/expected-output.diff @@ -3,4 +3,5 @@ [WARNING] This skip is unused, it never matched any element. You can remove it from "->withSkip()" - * Rector\CodeQuality\Rector\FunctionLike\SimplifyUselessVariableRector => */NonexistentUnused/* + * Rector\CodeQuality\Rector\FunctionLike\SimplifyUselessVariableRector: + * */NonexistentUnused/* diff --git a/e2e/parallel-unused-skips/rector.php b/e2e/parallel-unused-skips/rector.php new file mode 100644 index 00000000000..7fa0a05148d --- /dev/null +++ b/e2e/parallel-unused-skips/rector.php @@ -0,0 +1,16 @@ +withPaths([ + __DIR__ . '/custom', + __DIR__ . '/src', + ]) + // uncomment to reach your current PHP version + // ->withPhpSets() + ->withTypeCoverageLevel(0) + ->withDeadCodeLevel(0) + ->withCodeQualityLevel(0); diff --git a/src/Reporting/UnusedSkipResolver.php b/src/Reporting/UnusedSkipResolver.php index 841e482c43b..90062f0d20b 100644 --- a/src/Reporting/UnusedSkipResolver.php +++ b/src/Reporting/UnusedSkipResolver.php @@ -25,9 +25,9 @@ public function __construct( /** * Resolves skips configured via "->withSkip()" that never matched any element during the run. - * Rule-scoped skips are grouped under their rule ("rule => path", or "rule => [ path\n path ]" - * for multiple paths) so the user knows exactly what to remove; global skips are returned as a - * plain path. Returns an empty array unless "->reportUnusedSkips()" is enabled. + * Rule-scoped skips are grouped under their rule ("rule:" on its own line, each path nested + * below it) so the user knows exactly what to remove; global skips are returned as a plain + * path. Returns an empty array unless "->reportUnusedSkips()" is enabled. * * @return string[] */ @@ -86,12 +86,8 @@ public function resolve(ProcessResult $processResult): array continue; } - if (count($unusedRelativePaths) === 1) { - $unusedSkips[] = $rectorClass . ' => ' . $unusedRelativePaths[0]; - continue; - } - - $unusedSkips[] = $rectorClass . ' => [ ' . implode("\n ", $unusedRelativePaths) . ' ]'; + // rule on its own line, with each unused path nested below it as a "->listing()" sub-item + $unusedSkips[] = $rectorClass . ':' . "\n * " . implode("\n * ", $unusedRelativePaths); } foreach ($globalRelativePaths as $path => $relativePath) { diff --git a/tests/Reporting/UnusedSkipResolverTest.php b/tests/Reporting/UnusedSkipResolverTest.php index 027b26ef7b7..f6e9baaffef 100644 --- a/tests/Reporting/UnusedSkipResolverTest.php +++ b/tests/Reporting/UnusedSkipResolverTest.php @@ -55,11 +55,11 @@ public function testResolvesUnusedSkipsAsRuleAndPath(): void $processResult = new ProcessResult([], [], 0, [self::USED_RULE_MASK]); $unusedSkips = $this->unusedSkipResolver->resolve($processResult); - // rule-scoped unused skip is reported as "rule => path" - $this->assertContains(FifthElement::class . ' => ' . self::UNUSED_RULE_MASK, $unusedSkips); + // rule-scoped unused skip is reported as "rule:" with the path nested below + $this->assertContains(FifthElement::class . ':' . "\n * " . self::UNUSED_RULE_MASK, $unusedSkips); // matched rule-scoped skip, global mask and skip-everywhere rule are excluded - $this->assertNotContains(AnotherClassToSkip::class . ' => ' . self::USED_RULE_MASK, $unusedSkips); + $this->assertNotContains(AnotherClassToSkip::class . ':' . "\n * " . self::USED_RULE_MASK, $unusedSkips); $this->assertNotContains(self::GLOBAL_MASK, $unusedSkips); $this->assertNotContains(ThreeMan::class, $unusedSkips); } @@ -76,7 +76,10 @@ public function testReportsUnusedSkipAsRelativePath(): void $unusedSkips = $this->unusedSkipResolver->resolve(new ProcessResult([], [], 0, [])); // the absolute path is shortened to a relative one, matching the "->withSkip()" syntax - $this->assertContains(FifthElement::class . ' => src/Reporting/UnusedSkipResolver.php', $unusedSkips); + $this->assertContains( + FifthElement::class . ':' . "\n * " . 'src/Reporting/UnusedSkipResolver.php', + $unusedSkips + ); } public function testGroupsMultipleUnusedPathsUnderRule(): void @@ -91,9 +94,9 @@ public function testGroupsMultipleUnusedPathsUnderRule(): void $unusedSkips = $this->unusedSkipResolver->resolve(new ProcessResult([], [], 0, [])); - // multiple unused paths are grouped under their rule, not repeated per line + // multiple unused paths are grouped under their rule, each nested on its own line $this->assertContains( - FifthElement::class . ' => [ src/Reporting/UnusedSkipResolver.php' . "\n " . 'src/Reporting/MissConfigurationReporter.php ]', + FifthElement::class . ':' . "\n * " . 'src/Reporting/UnusedSkipResolver.php' . "\n * " . 'src/Reporting/MissConfigurationReporter.php', $unusedSkips ); }