Sha256: 2ec6255fea1ed6e75961170efd0a13f9459d4c6ecc9d9c7241a55267368228d9

Contents?: true

Size: 784 Bytes

Versions: 17

Compression:

Stored size: 784 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.size.zero?

        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

17 entries across 17 versions & 1 rubygems

Version Path
git-lint-5.0.0 lib/git/lint/analyzers/commit_body_bullet_capitalization.rb
git-lint-4.6.0 lib/git/lint/analyzers/commit_body_bullet_capitalization.rb
git-lint-4.5.0 lib/git/lint/analyzers/commit_body_bullet_capitalization.rb
git-lint-4.4.0 lib/git/lint/analyzers/commit_body_bullet_capitalization.rb
git-lint-4.3.0 lib/git/lint/analyzers/commit_body_bullet_capitalization.rb
git-lint-4.2.0 lib/git/lint/analyzers/commit_body_bullet_capitalization.rb
git-lint-4.1.0 lib/git/lint/analyzers/commit_body_bullet_capitalization.rb
git-lint-4.0.1 lib/git/lint/analyzers/commit_body_bullet_capitalization.rb
git-lint-4.0.0 lib/git/lint/analyzers/commit_body_bullet_capitalization.rb
git-lint-3.3.2 lib/git/lint/analyzers/commit_body_bullet_capitalization.rb
git-lint-3.3.1 lib/git/lint/analyzers/commit_body_bullet_capitalization.rb
git-lint-3.3.0 lib/git/lint/analyzers/commit_body_bullet_capitalization.rb
git-lint-3.2.0 lib/git/lint/analyzers/commit_body_bullet_capitalization.rb
git-lint-3.1.0 lib/git/lint/analyzers/commit_body_bullet_capitalization.rb
git-lint-3.0.2 lib/git/lint/analyzers/commit_body_bullet_capitalization.rb
git-lint-3.0.1 lib/git/lint/analyzers/commit_body_bullet_capitalization.rb
git-lint-3.0.0 lib/git/lint/analyzers/commit_body_bullet_capitalization.rb