Sha256: 696fe6e28f4b758a009d8d2e755644863e2f5c11aa5b7ef6578e6892b8a702c8

Contents?: true

Size: 628 Bytes

Versions: 3

Compression:

Stored size: 628 Bytes

Contents

# frozen_string_literal: true

module Git
  module Lint
    module Analyzers
      class CommitBodyLeadingLine < Abstract
        def self.defaults
          {
            enabled: true,
            severity: :error
          }
        end

        def valid?
          raw_body = commit.raw_body
          subject, body = raw_body.split "\n", 2
          return true if !String(subject).empty? && String(body).strip.empty?

          raw_body.match?(/\A.+\n\n.+/)
        end

        def issue
          return {} if valid?

          {hint: "Use blank line between subject and body."}
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
git-lint-1.1.0 lib/git/lint/analyzers/commit_body_leading_line.rb
git-lint-1.0.1 lib/git/lint/analyzers/commit_body_leading_line.rb
git-lint-1.0.0 lib/git/lint/analyzers/commit_body_leading_line.rb