Sha256: a186e05c215dbc54ee921e019c57b0ec09f0ff839584770ea6f4ce300fe56746

Contents?: true

Size: 832 Bytes

Versions: 4

Compression:

Stored size: 832 Bytes

Contents

# frozen_string_literal: true

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

        def initialize commit:, settings: self.class.defaults, validator: Validators::Name
          super commit: commit, settings: settings
          @validator = validator
        end

        def valid?
          validator.new(commit.author_name, minimum: minimum).valid?
        end

        def issue
          return {} if valid?

          {hint: "Author name must consist of #{minimum} parts (minimum)."}
        end

        private

        attr_reader :validator

        def minimum
          settings.fetch __method__
        end
      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_author_name.rb
git-lint-2.2.0 lib/git/lint/analyzers/commit_author_name.rb
git-lint-2.1.0 lib/git/lint/analyzers/commit_author_name.rb
git-lint-2.0.0 lib/git/lint/analyzers/commit_author_name.rb