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

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

Overview

Analyzes commit subject uses standard prefix.

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, #initialize, #invalid?, label, #severity, #warning?

Constructor Details

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

Instance Method Details

#issueObject



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

def issue
  return {} if valid?

  {hint: %(Use: #{filter_list.to_usage "or"}.)}
end

#valid?Boolean

Returns:

  • (Boolean)


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

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

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