Sha256: b52812b2c93e0f1cb8f0b6100c808a49deed1570446bde2d75b0582f9b66e962

Contents?: true

Size: 1.16 KB

Versions: 5

Compression:

Stored size: 1.16 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?

        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

5 entries across 5 versions & 1 rubygems

Version Path
git-lint-2.4.0 lib/git/lint/analyzers/commit_trailer_collaborator_capitalization.rb
git-lint-2.3.3 lib/git/lint/analyzers/commit_trailer_collaborator_capitalization.rb
git-lint-2.3.2 lib/git/lint/analyzers/commit_trailer_collaborator_capitalization.rb
git-lint-2.3.1 lib/git/lint/analyzers/commit_trailer_collaborator_capitalization.rb
git-lint-2.3.0 lib/git/lint/analyzers/commit_trailer_collaborator_capitalization.rb