Sha256: 559d48aa7d475d4d2a5bbf9cc0de0a432637a7ad2f032db4fb00ed3183996fb5

Contents?: true

Size: 988 Bytes

Versions: 11

Compression:

Stored size: 988 Bytes

Contents

# frozen_string_literal: true

module Git
  module Lint
    module Analyzers
      class CommitBodyParagraphCapitalization < Abstract
        def self.defaults
          {
            enabled: true,
            severity: :error
          }
        end

        def self.invalid? line
          line.match?(/\A[[:lower:]].+\Z/m)
        end

        def valid?
          lowercased_lines.empty?
        end

        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 }
        end

        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) if klass.invalid? line
          end
        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_paragraph_capitalization.rb
git-lint-2.2.0 lib/git/lint/analyzers/commit_body_paragraph_capitalization.rb
git-lint-2.1.0 lib/git/lint/analyzers/commit_body_paragraph_capitalization.rb
git-lint-2.0.0 lib/git/lint/analyzers/commit_body_paragraph_capitalization.rb
git-lint-1.4.0 lib/git/lint/analyzers/commit_body_paragraph_capitalization.rb
git-lint-1.3.0 lib/git/lint/analyzers/commit_body_paragraph_capitalization.rb
git-lint-1.2.0 lib/git/lint/analyzers/commit_body_paragraph_capitalization.rb
git-lint-1.1.1 lib/git/lint/analyzers/commit_body_paragraph_capitalization.rb
git-lint-1.1.0 lib/git/lint/analyzers/commit_body_paragraph_capitalization.rb
git-lint-1.0.1 lib/git/lint/analyzers/commit_body_paragraph_capitalization.rb
git-lint-1.0.0 lib/git/lint/analyzers/commit_body_paragraph_capitalization.rb