Sha256: 28c11c62449eccc4270c10f798f5cd209a407bdaf29e1679b67d4027fec65599

Contents?: true

Size: 780 Bytes

Versions: 5

Compression:

Stored size: 780 Bytes

Contents

# frozen_string_literal: true

module Git
  module Lint
    module Analyzers
      # Analyzes commit body for proper capitalization of bullet sentences.
      class CommitBodyBulletCapitalization < Abstract
        def valid? = lowercased_bullets.empty?

        def issue
          return {} if valid?

          {
            hint: "Capitalize first word.",
            lines: affected_commit_body_lines
          }
        end

        protected

        def load_filter_list = Kit::FilterList.new(settings.includes)

        def invalid_line? line
          line.match?(/\A\s*#{Regexp.union filter_list.to_regexp}\s[[:lower:]]+/)
        end

        private

        def lowercased_bullets = commit.body_lines.select { |line| invalid_line? line }
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
git-lint-5.3.0 lib/git/lint/analyzers/commit_body_bullet_capitalization.rb
git-lint-5.2.0 lib/git/lint/analyzers/commit_body_bullet_capitalization.rb
git-lint-5.1.2 lib/git/lint/analyzers/commit_body_bullet_capitalization.rb
git-lint-5.1.1 lib/git/lint/analyzers/commit_body_bullet_capitalization.rb
git-lint-5.1.0 lib/git/lint/analyzers/commit_body_bullet_capitalization.rb