public function detect(Finder $finder, array $rules): array
    {
        $nodes = $this->parseNodes($finder);
        $violations = array();

        $this->eventDispatcher->dispatch(Events::PRE_RULES_CHECKED, new PreRulesCheckedEvent($rules));

        foreach ($rules as $rule) {
            $ruleViolations = array();

            foreach ($nodes as $node) {
                $violation = $this->ruleChecker->check($rule, $node);
                if (null !== $violation) {
                    $ruleViolations[] = $violation;
                }

                $this->eventDispatcher->dispatch(
                    Events::NODE_CHECKED,
                    new NodeChecked($node, $rule, $violation)
                );
            }

            $this->eventDispatcher->dispatch(
                Events::RULE_CHECKED,
                new RuleCheckedEvent($rule, $ruleViolations)
            );

            $violations = array_merge($violations, $ruleViolations);
        }

        $this->eventDispatcher->dispatch(Events::POST_RULES_CHECKED, new PostRulesCheckedEvent($violations));

        return $violations;
    }