/** * {@inheritdoc} */ protected function run(CommitInterface $commit) { $messageLength = strlen($commit->getMessage()); if ($messageLength < $this->minLength) { $this->addViolation($commit); } }
/** * {@inheritdoc} */ protected function run(CommitInterface $commit) { $firstLetter = substr($commit->getMessage(), 0, 1); if (!ctype_upper($firstLetter)) { $this->addViolation($commit); } }
/** * {@inheritdoc} */ protected function run(CommitInterface $commit) { $endsWithPeriod = preg_match('/^.*\\.$/u', $commit->getSummary()) === 1; if ($endsWithPeriod) { $this->addViolation($commit); } }
/** * {@inheritdoc} */ public function isIncluded(CommitInterface $commit) { // Extremely naive implementation. Probably needs improving. $firstCars = substr($commit->getMessage(), 0, 5); $keepThisCommit = !($firstCars === 'Merge'); return $keepThisCommit; }
/** * {@inheritdoc} */ protected function run(CommitInterface $commit) { $noDoubleWhitespace = preg_match('/\\w \\w/', $commit->getMessage()); if ($noDoubleWhitespace) { $this->addViolation($commit); } }
/** * {@inheritdoc} */ protected function run(CommitInterface $commit) { $endsWithNewLine = preg_match("/\n\$/", $commit->getMessage()); if ($endsWithNewLine === 1) { $this->addViolation($commit); } }
/** * {@inheritdoc} */ protected function run(CommitInterface $commit) { foreach ($commit->getChangedFiles() as $file) { if ($this->isFileInIgnoreList($file)) { $this->addViolation($commit); return; } } }
/** * {@inheritdoc} */ protected function run(CommitInterface $commit) { $lines = preg_split('/\\n/', $commit->getMessage()); foreach ($lines as $line) { if (substr($line, -1) === ' ') { $this->addViolation($commit); return; } } }
/** * {@inheritdoc} */ protected function run(CommitInterface $commit) { if (mb_strlen($commit->getDescription()) === 0) { return; } $pieces = preg_split("/\n\n/u", $commit->getMessage(), 2); if (count($pieces) !== 2 || substr($pieces[1], 0, 1) === "\n") { $this->addViolation($commit); } }
/** * {@inheritdoc} */ protected function run(CommitInterface $commit) { foreach ($this->vocabulary as $nonsensePhrase) { $nonsensePhrase = mb_strtolower($nonsensePhrase); $message = mb_strtolower($commit->getMessage()); if ($this->isMessageMostlyNonsense($message, $nonsensePhrase)) { $this->addViolation($commit); return; } } }
/** * {@inheritdoc} */ protected function run(CommitInterface $commit) { $lines = preg_split("/\n/", $commit->getMessage()); if (!count($lines)) { return; } foreach ($lines as $line) { if (mb_strlen($line) > $this->maxLength) { $this->addViolation($commit); } } }
/** * {@inheritdoc} */ protected function run(CommitInterface $commit) { $commitLength = mb_strlen($commit->getMessage()); if ($commitLength <= self::MAX_LINE_LENGTH) { return; } $hasSummary = mb_strlen($commit->getSummary()) > 0; $hasDescription = mb_strlen($commit->getDescription()) > 0; if (!$hasSummary || !$hasDescription) { $this->addViolation($commit); } }
/** * {@inheritdoc} */ protected function run(CommitInterface $commit) { $profane = false; $message = null; $this->profanityChecker->scan($commit->getMessage(), function ($word, $types) use(&$profane, &$message) { $profane = true; $message = sprintf('The word "%s" is considered profane (%s)', mb_strtolower($word), implode(',', $types)); return false; }); if ($profane) { $this->message = $message; $this->addViolation($commit); } }
/** * {@inheritdoc} */ protected function run(CommitInterface $commit) { if (mb_strlen($commit->getSummary()) > 50) { $this->addViolation($commit); } }
/** * {@inheritdoc} */ protected function isIncluded(CommitInterface $commit) { return preg_match($this->pattern, $commit->getMessage()) === 1; }