Sha256: 32577b4da3288185f6613fd476dc78babf5b04213697019b977de0e210170471

Contents?: true

Size: 924 Bytes

Versions: 11

Compression:

Stored size: 924 Bytes

Contents

# frozen_string_literal: true

module Git
  module Lint
    module Analyzers
      class CommitBodyBulletCapitalization < Abstract
        def self.defaults
          {
            enabled: true,
            severity: :error,
            includes: %w[\\-]
          }
        end

        def valid?
          lowercased_bullets.size.zero?
        end

        def issue
          return {} if valid?

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

        protected

        def load_filter_list
          Kit::FilterList.new settings.fetch :includes
        end

        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
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
git-lint-2.2.1 lib/git/lint/analyzers/commit_body_bullet_capitalization.rb
git-lint-2.2.0 lib/git/lint/analyzers/commit_body_bullet_capitalization.rb
git-lint-2.1.0 lib/git/lint/analyzers/commit_body_bullet_capitalization.rb
git-lint-2.0.0 lib/git/lint/analyzers/commit_body_bullet_capitalization.rb
git-lint-1.4.0 lib/git/lint/analyzers/commit_body_bullet_capitalization.rb
git-lint-1.3.0 lib/git/lint/analyzers/commit_body_bullet_capitalization.rb
git-lint-1.2.0 lib/git/lint/analyzers/commit_body_bullet_capitalization.rb
git-lint-1.1.1 lib/git/lint/analyzers/commit_body_bullet_capitalization.rb
git-lint-1.1.0 lib/git/lint/analyzers/commit_body_bullet_capitalization.rb
git-lint-1.0.1 lib/git/lint/analyzers/commit_body_bullet_capitalization.rb
git-lint-1.0.0 lib/git/lint/analyzers/commit_body_bullet_capitalization.rb