Sha256: 16cf9d91d4177fd8c785330d85577354c07fff3efed7c56dafa7e86d4e8bc421

Contents?: true

Size: 705 Bytes

Versions: 2

Compression:

Stored size: 705 Bytes

Contents

# frozen_string_literal: true

module Git
  module Lint
    module Analyzers
      # Analyzes commit body for repeated words.
      class CommitBodyWordRepeat < Abstract
        include Dependencies[validator: "validators.repeated_word"]

        def valid? = commit.body_lines.all? { |line| !invalid_line? line }

        def issue
          return {} if valid?

          {
            hint: "Avoid repeating these words: #{validator.call commit.body}.",
            lines: affected_commit_body_lines
          }
        end

        protected

        def invalid_line? line
          return false if line.start_with? "#"

          !validator.call(line).empty?
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
git-lint-9.1.0 lib/git/lint/analyzers/commit_body_word_repeat.rb
git-lint-9.0.0 lib/git/lint/analyzers/commit_body_word_repeat.rb