Class: Git::Lint::Analyzers::Abstract
- Inherits:
-
Object
- Object
- Git::Lint::Analyzers::Abstract
show all
- Defined in:
- lib/git/lint/analyzers/abstract.rb
Overview
An abstract class which provides basic functionality for all analyzers to inherit from.
Direct Known Subclasses
CommitAuthorCapitalization, CommitAuthorEmail, CommitAuthorName, CommitBodyBulletCapitalization, CommitBodyBulletDelimiter, CommitBodyBulletOnly, CommitBodyLeadingLine, CommitBodyLineLength, CommitBodyParagraphCapitalization, CommitBodyPhrase, CommitBodyPresence, CommitBodyTrackerShorthand, CommitBodyWordRepeat, CommitSignature, CommitSubjectLength, CommitSubjectPrefix, CommitSubjectSuffix, CommitSubjectWordRepeat, CommitTrailerCollaboratorCapitalization, CommitTrailerCollaboratorEmail, CommitTrailerCollaboratorKey, CommitTrailerCollaboratorName, CommitTrailerDuplicate, CommitTrailerFormatKey, CommitTrailerFormatValue, CommitTrailerIssueKey, CommitTrailerIssueValue, CommitTrailerMilestoneKey, CommitTrailerMilestoneValue, CommitTrailerOrder, CommitTrailerReviewerKey, CommitTrailerReviewerValue, CommitTrailerSignerCapitalization, CommitTrailerSignerEmail, CommitTrailerSignerKey, CommitTrailerSignerName, CommitTrailerTrackerKey, CommitTrailerTrackerValue
Constant Summary
collapse
- LEVELS =
%w[warn error].freeze
- BODY_OFFSET =
3
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(commit) ⇒ Abstract
Returns a new instance of Abstract.
26
27
28
29
30
|
# File 'lib/git/lint/analyzers/abstract.rb', line 26
def initialize(commit, **)
super(**)
@commit = commit
@filter_list = load_filter_list
end
|
Instance Attribute Details
#commit ⇒ Object
Returns the value of attribute commit.
24
25
26
|
# File 'lib/git/lint/analyzers/abstract.rb', line 24
def commit
@commit
end
|
Class Method Details
.build_issue_line(index, line) ⇒ Object
22
|
# File 'lib/git/lint/analyzers/abstract.rb', line 22
def self.build_issue_line(index, line) = {number: index + BODY_OFFSET, content: line}
|
.id ⇒ Object
18
|
# File 'lib/git/lint/analyzers/abstract.rb', line 18
def self.id = to_s.delete_prefix!("Git::Lint::Analyzers").snakecase
|
.label ⇒ Object
20
|
# File 'lib/git/lint/analyzers/abstract.rb', line 20
def self.label = to_s.delete_prefix("Git::Lint::Analyzers").titleize
|
Instance Method Details
#error? ⇒ Boolean
43
|
# File 'lib/git/lint/analyzers/abstract.rb', line 43
def error? = invalid? && severity == "error"
|
#invalid? ⇒ Boolean
39
|
# File 'lib/git/lint/analyzers/abstract.rb', line 39
def invalid? = !valid?
|
#issue ⇒ Object
45
|
# File 'lib/git/lint/analyzers/abstract.rb', line 45
def issue = fail NoMethodError, "The `##{__method__}` method must be implemented."
|
#severity ⇒ Object
32
33
34
35
|
# File 'lib/git/lint/analyzers/abstract.rb', line 32
def severity
settings.public_send("#{self.class.id}_severity".sub("commit_", "commits_"))
.tap { |level| fail Errors::Severity, level unless LEVELS.include? level }
end
|
#valid? ⇒ Boolean
37
|
# File 'lib/git/lint/analyzers/abstract.rb', line 37
def valid? = fail NoMethodError, "The `##{__method__}` method must be implemented."
|
#warning? ⇒ Boolean
41
|
# File 'lib/git/lint/analyzers/abstract.rb', line 41
def warning? = invalid? && severity == "warn"
|