Sha256: 0d020b303e23fc93175a39900917463cf2e749e96eb88c609d7c95b95cad38cd

Contents?: true

Size: 853 Bytes

Versions: 3

Compression:

Stored size: 853 Bytes

Contents

# frozen_string_literal: true

module Git
  module Lint
    module Analyzers
      # Analyzes proper capitalization of commit body paragraphs.
      class CommitBodyParagraphCapitalization < Abstract
        def self.invalid?(line) = line.match?(/\A[[:lower:]].+\Z/m)

        def valid? = lowercased_lines.empty?

        def issue
          return {} if valid?

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

        private

        def lowercased_lines = commit.body_paragraphs.select { |line| self.class.invalid? line }

        def affected_lines
          klass = self.class

          commit.body_paragraphs.each.with_object([]).with_index do |(line, lines), index|
            lines << klass.build_issue_line(index, line)
          end
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
git-lint-4.6.0 lib/git/lint/analyzers/commit_body_paragraph_capitalization.rb
git-lint-4.5.0 lib/git/lint/analyzers/commit_body_paragraph_capitalization.rb
git-lint-4.4.0 lib/git/lint/analyzers/commit_body_paragraph_capitalization.rb