Sha256: 58fabb3f22c59f32fb7aa4d49c02bd25d439b41e42731ac14a3060ee19b7919d

Contents?: true

Size: 612 Bytes

Versions: 3

Compression:

Stored size: 612 Bytes

Contents

# 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

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
danger-wcc-0.0.4 lib/wcc/commit_lint/subject_length_check.rb
danger-wcc-0.0.3 lib/wcc/commit_lint/subject_length_check.rb
danger-wcc-0.0.2 lib/wcc/commit_lint/subject_length_check.rb