Class: Danger::DangerCommitLint

Inherits:
Plugin
  • Object
show all
Defined in:
lib/commit_lint/plugin.rb,
lib/commit_lint/commit_check.rb,
lib/commit_lint/empty_line_check.rb,
lib/commit_lint/subject_cap_check.rb,
lib/commit_lint/subject_words_check.rb,
lib/commit_lint/subject_length_check.rb,
lib/commit_lint/subject_period_check.rb

Overview

Run each commit in the PR through a message linting.

Commit lint will check each commit in the PR to ensure the following is
true:

* Commit subject begins with a capital letter (`subject_cap`)
* Commit subject is more than one word (`subject_word`)
* Commit subject is no longer than 50 characters (`subject_length`)
* Commit subject does not end in a period (`subject_period`)
* Commit subject and body are separated by an empty line (`empty_line`)

By default, Commit Lint fails, but you can configure this behavior.

Examples:

Lint all commits using defaults


commit_lint.check

Warn instead of fail


commit_lint.check warn: :all

Disable a particular check


commit_lint.check disable: [:subject_period]

See Also:

  • danger/danger

Defined Under Namespace

Classes: CommitCheck, EmptyLineCheck, SubjectCapCheck, SubjectLengthCheck, SubjectPeriodCheck, SubjectWordsCheck

Constant Summary collapse

NOOP_MESSAGE =
'All checks were disabled, nothing to do.'.freeze

Instance Method Summary collapse

Instance Method Details

#check(config = {}) ⇒ void

This method returns an undefined value.

Checks the commits with whatever config the user passes.

Passing in a hash which contain the following keys:

* `disable` - array of checks to skip
* `fail` - array of checks to fail on
* `warn` - array of checks to warn on

The current check types are:

* `subject_cap`
* `subject_word`
* `subject_length`
* `subject_period`
* `empty_line`

Note: you can pass :all instead of an array to target all checks.

Parameters:

  • config (Hash) (defaults to: {})


56
57
58
59
60
61
62
63
64
# File 'lib/commit_lint/plugin.rb', line 56

def check(config = {})
  @config = config

  if all_checks_disabled?
    messaging.warn NOOP_MESSAGE
  else
    check_messages
  end
end