Class: Git::Lint::Analyzers::CommitSubjectPrefix

Inherits:
Abstract
  • Object
show all
Defined in:
lib/git/lint/analyzers/commit_subject_prefix.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, #initialize, #invalid?, label, #severity, #warning?

Constructor Details

This class inherits a constructor from Git::Lint::Analyzers::Abstract

Class Method Details

.defaultsObject



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

def self.defaults
  {
    enabled: true,
    severity: :error,
    includes: %w[Fixed Added Updated Removed Refactored]
  }
end

Instance Method Details

#issueObject



22
23
24
25
26
# File 'lib/git/lint/analyzers/commit_subject_prefix.rb', line 22

def issue
  return {} if valid?

  {hint: %(Use: #{filter_list.to_hint}.)}
end

#valid?Boolean

Returns:

  • (Boolean)


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

def valid?
  return true if fixup_or_squash?
  return true if filter_list.empty?

  commit.subject.match?(/\A#{Regexp.union filter_list.to_regexp}/)
end