Class: Git::Lint::Analyzers::CommitTrailerCollaboratorKey

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

Constant Summary

Constants inherited from Abstract

Abstract::ISSUE_LINE_OFFSET, Abstract::LEVELS

Instance Attribute Summary

Attributes inherited from Abstract

#commit

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Abstract

build_issue_line, descendants, #enabled?, #error?, id, inherited, #invalid?, label, #severity, #warning?

Constructor Details

#initialize(commit:, settings: self.class.defaults, parser: Parsers::Trailers::Collaborator) ⇒ CommitTrailerCollaboratorKey

Returns a new instance of CommitTrailerCollaboratorKey.



15
16
17
18
19
20
# File 'lib/git/lint/analyzers/commit_trailer_collaborator_key.rb', line 15

def initialize commit:,
               settings: self.class.defaults,
               parser: Parsers::Trailers::Collaborator
  super commit: commit, settings: settings
  @parser = parser
end

Class Method Details

.defaultsObject



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

def self.defaults
  {
    enabled: true,
    severity: :error,
    includes: ["Co-Authored-By"]
  }
end

Instance Method Details

#issueObject



26
27
28
29
30
31
32
33
# File 'lib/git/lint/analyzers/commit_trailer_collaborator_key.rb', line 26

def issue
  return {} if valid?

  {
    hint: "Use format: #{filter_list.to_hint}.",
    lines: affected_commit_trailers
  }
end

#valid?Boolean

Returns:

  • (Boolean)


22
23
24
# File 'lib/git/lint/analyzers/commit_trailer_collaborator_key.rb', line 22

def valid?
  affected_commit_trailers.empty?
end