Class: Git::Lint::Analyzers::CommitBodyLeadingLine

Inherits:
Abstract
  • Object
show all
Defined in:
lib/git/lint/analyzers/commit_body_leading_line.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
# File 'lib/git/lint/analyzers/commit_body_leading_line.rb', line 7

def self.defaults
  {
    enabled: true,
    severity: :error
  }
end

Instance Method Details

#issueObject



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

def issue
  return {} if valid?

  {hint: "Use blank line between subject and body."}
end

#valid?Boolean

Returns:

  • (Boolean)


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

def valid?
  message = commit.message
  subject, body = message.split "\n", 2

  return true if !String(subject).empty? && String(body).strip.empty?

  message.match?(/\A.+(\n\n|\#).+/m)
end