Sha256: 6df477e9a6babf1aa48478e74dc2ef6fc5885aa8f158b53f828128c97e4b51bd

Contents?: true

Size: 1.18 KB

Versions: 4

Compression:

Stored size: 1.18 KB

Contents

# frozen_string_literal: true

module Git
  module Lint
    module Analyzers
      class CommitTrailerCollaboratorCapitalization < 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::Capitalization
          super commit: commit, settings: settings
          @parser = parser
          @validator = validator
        end
        # rubocop:enable Metrics/ParameterLists

        def valid?
          affected_commit_trailers.empty?
        end

        def issue
          return {} if valid?

          {
            hint: "Name must be capitalized.",
            lines: affected_commit_trailers
          }
        end

        protected

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

        private

        attr_reader :parser, :validator
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
git-lint-2.2.1 lib/git/lint/analyzers/commit_trailer_collaborator_capitalization.rb
git-lint-2.2.0 lib/git/lint/analyzers/commit_trailer_collaborator_capitalization.rb
git-lint-2.1.0 lib/git/lint/analyzers/commit_trailer_collaborator_capitalization.rb
git-lint-2.0.0 lib/git/lint/analyzers/commit_trailer_collaborator_capitalization.rb