Sha256: f76b9c8cf1e86e5a63abff3661c38e7f085293816db41a71dfa5607f4ddd781c

Contents?: true

Size: 917 Bytes

Versions: 6

Compression:

Stored size: 917 Bytes

Contents

# frozen_string_literal: true

module Git
  module Lint
    module Analyzers
      # Analyzes commit trailer collaborator name construction.
      class CommitTrailerCollaboratorName < Abstract
        include Import[
          pattern: "trailers.collaborator",
          parser: "parsers.person",
          validator: "validators.name"
        ]

        def valid? = affected_commit_trailers.empty?

        def issue
          return {} if valid?

          {
            hint: "Name must follow key and consist of #{minimum} parts (minimum).",
            lines: affected_commit_trailers
          }
        end

        protected

        def invalid_line? trailer
          parser.call(trailer.value).then do |person|
            trailer.key.match?(pattern) && !validator.call(person.name, minimum:)
          end
        end

        private

        def minimum = settings.minimum
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
git-lint-5.3.0 lib/git/lint/analyzers/commit_trailer_collaborator_name.rb
git-lint-5.2.0 lib/git/lint/analyzers/commit_trailer_collaborator_name.rb
git-lint-5.1.2 lib/git/lint/analyzers/commit_trailer_collaborator_name.rb
git-lint-5.1.1 lib/git/lint/analyzers/commit_trailer_collaborator_name.rb
git-lint-5.1.0 lib/git/lint/analyzers/commit_trailer_collaborator_name.rb
git-lint-5.0.0 lib/git/lint/analyzers/commit_trailer_collaborator_name.rb