Sha256: 66ab34a81ea54b269a0915fb21c40c21e8cf0bf44f7c3646cddad8695b4fb605

Contents?: true

Size: 1 KB

Versions: 8

Compression:

Stored size: 1 KB

Contents

# frozen_string_literal: true

module Git
  module Lint
    module Analyzers
      # Analyzes commit trailer collaborator name construction.
      class CommitTrailerCollaboratorName < Abstract
        def initialize commit,
                       parser: Parsers::Trailers::Collaborator,
                       validator: Validators::Name

          super commit
          @parser = parser
          @validator = validator
        end

        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? line
          collaborator = parser.new line
          collaborator.match? && !validator.new(collaborator.name.strip, minimum:).valid?
        end

        private

        attr_reader :parser, :validator

        def minimum = settings.minimum
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
git-lint-3.3.2 lib/git/lint/analyzers/commit_trailer_collaborator_name.rb
git-lint-3.3.1 lib/git/lint/analyzers/commit_trailer_collaborator_name.rb
git-lint-3.3.0 lib/git/lint/analyzers/commit_trailer_collaborator_name.rb
git-lint-3.2.0 lib/git/lint/analyzers/commit_trailer_collaborator_name.rb
git-lint-3.1.0 lib/git/lint/analyzers/commit_trailer_collaborator_name.rb
git-lint-3.0.2 lib/git/lint/analyzers/commit_trailer_collaborator_name.rb
git-lint-3.0.1 lib/git/lint/analyzers/commit_trailer_collaborator_name.rb
git-lint-3.0.0 lib/git/lint/analyzers/commit_trailer_collaborator_name.rb