Sha256: ff381d73821affd0e104a76dadea5b931dbb349e5beca67ce62c50e0570bdb9e

Contents?: true

Size: 975 Bytes

Versions: 8

Compression:

Stored size: 975 Bytes

Contents

# frozen_string_literal: true

module Git
  module Lint
    module Analyzers
      # Analyzes commit trailer collaborator email address format.
      class CommitTrailerCollaboratorEmail < Abstract
        def initialize commit,
                       parser: Parsers::Trailers::Collaborator,
                       validator: Validators::Email

          super commit
          @parser = parser
          @validator = validator
        end

        def valid? = affected_commit_trailers.empty?

        def issue
          return {} if valid?

          {
            hint: %(Email must follow name and use format: "<name@server.domain>".),
            lines: affected_commit_trailers
          }
        end

        protected

        def invalid_line? line
          collaborator = parser.new line
          collaborator.match? && !validator.new(collaborator.email).valid?
        end

        private

        attr_reader :parser, :validator
      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_email.rb
git-lint-3.3.1 lib/git/lint/analyzers/commit_trailer_collaborator_email.rb
git-lint-3.3.0 lib/git/lint/analyzers/commit_trailer_collaborator_email.rb
git-lint-3.2.0 lib/git/lint/analyzers/commit_trailer_collaborator_email.rb
git-lint-3.1.0 lib/git/lint/analyzers/commit_trailer_collaborator_email.rb
git-lint-3.0.2 lib/git/lint/analyzers/commit_trailer_collaborator_email.rb
git-lint-3.0.1 lib/git/lint/analyzers/commit_trailer_collaborator_email.rb
git-lint-3.0.0 lib/git/lint/analyzers/commit_trailer_collaborator_email.rb