Class: Git::Lint::Analyzers::CommitBodyPresence
- Inherits:
-
Abstract
- Object
- Abstract
- Git::Lint::Analyzers::CommitBodyPresence
show all
- Defined in:
- lib/git/lint/analyzers/commit_body_presence.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?
Class Method Details
.defaults ⇒ Object
9
10
11
12
13
14
15
|
# File 'lib/git/lint/analyzers/commit_body_presence.rb', line 9
def self.defaults
{
enabled: true,
severity: :warn,
minimum: 1
}
end
|
Instance Method Details
#issue ⇒ Object
28
29
30
31
32
|
# File 'lib/git/lint/analyzers/commit_body_presence.rb', line 28
def issue
return {} if valid?
{hint: %(Use minimum of #{"line".pluralize count: minimum} (non-empty).)}
end
|
#minimum ⇒ Object
24
25
26
|
# File 'lib/git/lint/analyzers/commit_body_presence.rb', line 24
def minimum
settings.fetch :minimum
end
|
#valid? ⇒ Boolean
17
18
19
20
21
22
|
# File 'lib/git/lint/analyzers/commit_body_presence.rb', line 17
def valid?
return true if commit.fixup?
valid_lines = commit.body_lines.reject { |line| line.match?(/^\s*$/) }
valid_lines.size >= minimum
end
|