Class: Git::Lint::Analyzers::CommitTrailerOrder

Inherits:
Abstract
  • Object
show all
Defined in:
lib/git/lint/analyzers/commit_trailer_order.rb

Overview

Analyzes commit trailer order value.

Constant Summary

Constants inherited from Abstract

Abstract::BODY_OFFSET, Abstract::LEVELS

Instance Attribute Summary

Attributes inherited from Abstract

#commit

Instance Method Summary collapse

Methods inherited from Abstract

build_issue_line, #error?, id, #invalid?, label, #severity, #warning?

Constructor Details

#initializeCommitTrailerOrder

Returns a new instance of CommitTrailerOrder.



8
9
10
11
12
# File 'lib/git/lint/analyzers/commit_trailer_order.rb', line 8

def initialize(...)
  super
  @original_order = commit.trailers.map(&:key)
  @sorted_order = original_order.sort
end

Instance Method Details

#issueObject



16
17
18
19
20
21
22
23
# File 'lib/git/lint/analyzers/commit_trailer_order.rb', line 16

def issue
  return {} if valid?

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

#valid?Boolean

Returns:

  • (Boolean)


14
# File 'lib/git/lint/analyzers/commit_trailer_order.rb', line 14

def valid? = original_order == sorted_order