Skip to content

Commit

Permalink
Remove regex selections from origins to avoid duplicated statements
Browse files Browse the repository at this point in the history
  • Loading branch information
carlosas committed Dec 13, 2021
1 parent ae6a998 commit 35c4fcd
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/Statement/StatementBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,8 @@ private function selectOrigins(array $includedInRule, array $excludedInRule, Ref
$classNamesToValidate = $filteredClassNames;
}

$classNamesToValidate = $this->removeRegexClassNames($classNamesToValidate);

return $classNamesToValidate;
}

Expand Down Expand Up @@ -143,6 +145,14 @@ private function selectDestinations(
return array_values($classLikeNames);
}

private function removeRegexClassNames(array $classNames): array
{
return array_filter(
$classNames,
fn (ClassLike $c) => !$this->isRegex($c->toString())
);
}

private function isRegex(string $str): bool
{
return strpos($str, '*') !== false;
Expand Down

0 comments on commit 35c4fcd

Please sign in to comment.