Sha256: ebb4231f7cf85c999aa19175080cf7772166ff62fc36252bb96429bb4ff4da05

Contents?: true

Size: 718 Bytes

Versions: 4

Compression:

Stored size: 718 Bytes

Contents

# frozen_string_literal: true

module Git
  module Lint
    module Analyzers
      class CommitBodyPresence < Abstract
        using GitPlus::Refinements::Strings

        def self.defaults
          {
            enabled: true,
            severity: :warn,
            minimum: 1
          }
        end

        def valid?
          return true if commit.fixup?

          valid_lines = commit.body_lines.reject { |line| line.match?(/^\s*$/) }
          valid_lines.size >= minimum
        end

        def minimum = settings.fetch(:minimum)

        def issue
          return {} if valid?

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

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
git-lint-2.3.3 lib/git/lint/analyzers/commit_body_presence.rb
git-lint-2.3.2 lib/git/lint/analyzers/commit_body_presence.rb
git-lint-2.3.1 lib/git/lint/analyzers/commit_body_presence.rb
git-lint-2.3.0 lib/git/lint/analyzers/commit_body_presence.rb