private function lintDir($dir)
    {
        $finder = Finder::create();
        $finder->files()
            ->in($dir);

        $patterns = $this->input->getOption(self::OPTION_PATTERN);
        if (!empty($patterns)) {
            $patterns = explode(',', $patterns);
            foreach ($patterns as $pattern) {
                $finder->name(trim($pattern));
            }
        } else {
            $finder->name('*.xml.dist')
                ->name('*.xml');
        }

        if (!$this->input->getOption(self::OPTION_RECURSIVE)) {
            $finder->depth(0);
        }

        if ($this->input->hasOption(self::OPTION_EXCLUDE)) {
            $exclude = explode(',', $this->input->getOption(self::OPTION_EXCLUDE));
            $finder->exclude($exclude);
        }

        $totalFiles = $finder->count();

        $counter = 0;
        $ret = true;
        /** @var SplFileInfo $file */
        foreach ($finder as $file) {
            $ret = $this->lintFile($file) && $ret;
            if (0 == ++$counter % 30) {
                $this->output->writeln(sprintf(
                    ' %8d/%d %6.2f%%',
                    $counter,
                    $totalFiles,
                    $counter / $totalFiles * 100
                ));
            }
        }

        return $ret;
    }