Sha256: 2fbbe3eb3c6ed70b641b082f9804d068e5eb96efba6e878d8a16701050bcde40

Contents?: true

Size: 613 Bytes

Versions: 5

Compression:

Stored size: 613 Bytes

Contents

# frozen_string_literal: true

module Git
  module Lint
    module Analyzers
      # Analyzes presence of commit body.
      class CommitBodyPresence < Abstract
        using Refinements::String

        def valid?
          return true if commit.fixup?

          valid_lines = commit.body_lines.grep_v(/^\s*$/)
          valid_lines.size >= minimum
        end

        def minimum = configuration.commits_body_presence_minimum

        def issue
          return {} if valid?

          {hint: %(Use minimum of #{"#{minimum} line".pluralize "s", minimum} (non-empty).)}
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
git-lint-7.5.0 lib/git/lint/analyzers/commit_body_presence.rb
git-lint-7.3.0 lib/git/lint/analyzers/commit_body_presence.rb
git-lint-7.2.0 lib/git/lint/analyzers/commit_body_presence.rb
git-lint-7.1.0 lib/git/lint/analyzers/commit_body_presence.rb
git-lint-7.0.0 lib/git/lint/analyzers/commit_body_presence.rb