Sha256: 50457c1e2c526ead1fd0b57cb62b18d39215c2fd5a0ab5615828844be73868cc

Contents?: true

Size: 971 Bytes

Versions: 8

Compression:

Stored size: 971 Bytes

Contents

# frozen_string_literal: true

module Git
  module Lint
    module Analyzers
      # Analyzes commit trailer collaborator key usage.
      class CommitTrailerCollaboratorKey < Abstract
        def initialize commit, parser: Parsers::Trailers::Collaborator
          super commit
          @parser = parser
        end

        def valid? = affected_commit_trailers.empty?

        def issue
          return {} if valid?

          {
            hint: "Use format: #{filter_list.to_hint}.",
            lines: affected_commit_trailers
          }
        end

        protected

        def load_filter_list = Kit::FilterList.new(settings.includes)

        def invalid_line? line
          collaborator = parser.new line
          key = collaborator.key

          collaborator.match? && !key.empty? && !key.match?(
            /\A#{Regexp.union filter_list.to_regexp}\Z/
          )
        end

        private

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