Sha256: d28fd27f3c4e8993090397f0c05071834b17b72185339159dac892b633885c92

Contents?: true

Size: 964 Bytes

Versions: 5

Compression:

Stored size: 964 Bytes

Contents

# frozen_string_literal: true

module Git
  module Lint
    module Analyzers
      # Analyzes commit trailer collaborator name construction.
      class CommitTrailerCollaboratorName < Abstract
        include Import[
          setting: "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?(setting.pattern) && !validator.call(person.name, minimum:)
          end
        end

        private

        def minimum = configuration.commits_trailer_collaborator_name_minimum
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
git-lint-7.5.0 lib/git/lint/analyzers/commit_trailer_collaborator_name.rb
git-lint-7.3.0 lib/git/lint/analyzers/commit_trailer_collaborator_name.rb
git-lint-7.2.0 lib/git/lint/analyzers/commit_trailer_collaborator_name.rb
git-lint-7.1.0 lib/git/lint/analyzers/commit_trailer_collaborator_name.rb
git-lint-7.0.0 lib/git/lint/analyzers/commit_trailer_collaborator_name.rb