Skip to content

Missing Identifier for "DeclareCoverageRule"-Errors #61

@philip-zeyen-adesso

Description

@philip-zeyen-adesso

When a colleague and i wanted to include the "DeclareCoverageRule" into a reporting suit of ours we identified, that the "DeclareCoverageRule" does not provide an identifier. The other Rules do that.

This could be the solution

final readonly class DeclareCoverageRule implements Rule
{
    public const string IDENTIFIER = 'typeCoverage.declareCoverage';

    // ...

    /**
     * @param CollectedDataNode $node
     * @return RuleError[]
     */
    public function processNode(Node $node, Scope $scope): array
    {
        // ...

        $ruleErrors = [];
        foreach ($notCoveredDeclareFilePaths as $notCoveredDeclareFilePath) {
            $errorMessage = sprintf(
                self::ERROR_MESSAGE,
                $totalPossibleDeclares,
                $coveredDeclares,
                $declareCoverage,
                $requiredDeclareLevel,
            );

            $ruleErrors[] = RuleErrorBuilder::message($errorMessage)
                ->identifier(self::IDENTIFIER)
                ->file($notCoveredDeclareFilePath)
                ->build();
        }

        return $ruleErrors;
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions