# frozen_string_literal: true class SubjectLengthCheck < CommitCheck def self.type :subject_length end def initialize(message, options = {}) @subject = message[:subject] @max_length = options.fetch(:max, 50) @min_length = options.fetch(:min, 1) end def message if @subject.length > @max_length "Please limit commit subject line to #{@max_length} characters." else "Please write a commit subject line of at least #{@min_length} "\ 'characters.' end end def fail? @subject.length > @max_length || @subject.length < @min_length end end