Sha256: 83b10894a27484da05cbbcc3cd0ddc73a98b609650671a2ba281fac09eac6437

Contents?: true

Size: 830 Bytes

Versions: 7

Compression:

Stored size: 830 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 :minimum
        end
      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_author_name.rb
git-lint-1.3.0 lib/git/lint/analyzers/commit_author_name.rb
git-lint-1.2.0 lib/git/lint/analyzers/commit_author_name.rb
git-lint-1.1.1 lib/git/lint/analyzers/commit_author_name.rb
git-lint-1.1.0 lib/git/lint/analyzers/commit_author_name.rb
git-lint-1.0.1 lib/git/lint/analyzers/commit_author_name.rb
git-lint-1.0.0 lib/git/lint/analyzers/commit_author_name.rb