Sha256: 6eb1e4dc52237efe9cef6546427c041b18b8a1a5ffa8133541e60c0c9fecc621

Contents?: true

Size: 849 Bytes

Versions: 9

Compression:

Stored size: 849 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.commits_body_bullet_capitalization_includes
        end

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

        private

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

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
git-lint-8.8.0 lib/git/lint/analyzers/commit_body_bullet_capitalization.rb
git-lint-8.7.0 lib/git/lint/analyzers/commit_body_bullet_capitalization.rb
git-lint-8.6.0 lib/git/lint/analyzers/commit_body_bullet_capitalization.rb
git-lint-8.5.0 lib/git/lint/analyzers/commit_body_bullet_capitalization.rb
git-lint-8.4.0 lib/git/lint/analyzers/commit_body_bullet_capitalization.rb
git-lint-8.3.0 lib/git/lint/analyzers/commit_body_bullet_capitalization.rb
git-lint-8.2.0 lib/git/lint/analyzers/commit_body_bullet_capitalization.rb
git-lint-8.1.0 lib/git/lint/analyzers/commit_body_bullet_capitalization.rb
git-lint-8.0.0 lib/git/lint/analyzers/commit_body_bullet_capitalization.rb