Class: Commitlint::Linter
- Inherits:
-
Object
- Object
- Commitlint::Linter
- Defined in:
- lib/commitlint/linter.rb
Overview
Linter class is responsible for linting commit messages.
Instance Method Summary collapse
-
#initialize(commit_message, output: true) ⇒ Linter
constructor
A new instance of Linter.
- #lint! ⇒ Object
Constructor Details
#initialize(commit_message, output: true) ⇒ Linter
Returns a new instance of Linter.
6 7 8 9 |
# File 'lib/commitlint/linter.rb', line 6 def initialize(, output: true) @commit_message = () @output = output end |
Instance Method Details
#lint! ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/commitlint/linter.rb', line 11 def lint! validator = Validator.new(@commit_message) return 0 if validator.valid? errors = validator.errors puts <<~MESSAGE if @output \nYour commit message is invalid: #{errors.map { |e| "=> #{e}" }.join("\n")} Get help: https://github.com/conventional-changelog/commitlint/#what-is-commitlint\n MESSAGE 1 end |