Sha256: 44c72a669f685a1380278f0da9a1553fd2c3ded9a948a68e91f2653337e62966

Contents?: true

Size: 1.21 KB

Versions: 7

Compression:

Stored size: 1.21 KB

Contents

# frozen_string_literal: true

module Git
  module Lint
    module Analyzers
      class CommitTrailerCollaboratorEmail < Abstract
        def self.defaults
          {
            enabled: true,
            severity: :error
          }
        end

        # rubocop:disable Metrics/ParameterLists
        def initialize commit:,
                       settings: self.class.defaults,
                       parser: Parsers::Trailers::Collaborator,
                       validator: Validators::Email

          super commit: commit, settings: settings
          @parser = parser
          @validator = validator
        end
        # rubocop:enable Metrics/ParameterLists

        def valid?
          affected_commit_trailer_lines.empty?
        end

        def issue
          return {} if valid?

          {
            hint: %(Email must follow name and use format: "<name@server.domain>".),
            lines: affected_commit_trailer_lines
          }
        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

7 entries across 7 versions & 1 rubygems

Version Path
git-lint-1.4.0 lib/git/lint/analyzers/commit_trailer_collaborator_email.rb
git-lint-1.3.0 lib/git/lint/analyzers/commit_trailer_collaborator_email.rb
git-lint-1.2.0 lib/git/lint/analyzers/commit_trailer_collaborator_email.rb
git-lint-1.1.1 lib/git/lint/analyzers/commit_trailer_collaborator_email.rb
git-lint-1.1.0 lib/git/lint/analyzers/commit_trailer_collaborator_email.rb
git-lint-1.0.1 lib/git/lint/analyzers/commit_trailer_collaborator_email.rb
git-lint-1.0.0 lib/git/lint/analyzers/commit_trailer_collaborator_email.rb