Sha256: 3b6181e61cfe8e5802a62fc67a76bc2e0656767e0b09330d7a40e657565a2a35

Contents?: true

Size: 818 Bytes

Versions: 14

Compression:

Stored size: 818 Bytes

Contents

# frozen_string_literal: true

module Git
  module Lint
    module Analyzers
      # Analyzes commit trailer order value.
      class CommitTrailerOrder < Abstract
        def initialize(...)
          super
          @original_order = commit.trailers.map(&:key)
          @sorted_order = original_order.sort
        end

        def valid? = original_order == sorted_order

        def issue
          return {} if valid?

          {
            hint: "Ensure keys are alphabetically sorted.",
            lines: affected_commit_trailers
          }
        end

        protected

        def invalid_line? trailer
          key = trailer.key
          original_order.index(key) != sorted_order.index(key)
        end

        private

        attr_reader :original_order, :sorted_order
      end
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
git-lint-8.8.0 lib/git/lint/analyzers/commit_trailer_order.rb
git-lint-8.7.0 lib/git/lint/analyzers/commit_trailer_order.rb
git-lint-8.6.0 lib/git/lint/analyzers/commit_trailer_order.rb
git-lint-8.5.0 lib/git/lint/analyzers/commit_trailer_order.rb
git-lint-8.4.0 lib/git/lint/analyzers/commit_trailer_order.rb
git-lint-8.3.0 lib/git/lint/analyzers/commit_trailer_order.rb
git-lint-8.2.0 lib/git/lint/analyzers/commit_trailer_order.rb
git-lint-8.1.0 lib/git/lint/analyzers/commit_trailer_order.rb
git-lint-8.0.0 lib/git/lint/analyzers/commit_trailer_order.rb
git-lint-7.5.0 lib/git/lint/analyzers/commit_trailer_order.rb
git-lint-7.3.0 lib/git/lint/analyzers/commit_trailer_order.rb
git-lint-7.2.0 lib/git/lint/analyzers/commit_trailer_order.rb
git-lint-7.1.0 lib/git/lint/analyzers/commit_trailer_order.rb
git-lint-7.0.0 lib/git/lint/analyzers/commit_trailer_order.rb