Class: Git::Lint::Analyzers::CommitBodyPresence

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

Overview

Analyzes presence of commit body.

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



19
20
21
22
23
# File 'lib/git/lint/analyzers/commit_body_presence.rb', line 19

def issue
  return {} if valid?

  {hint: %(Use minimum of #{"#{minimum} line".pluralize "s", minimum} (non-empty).)}
end

#minimumObject



17
# File 'lib/git/lint/analyzers/commit_body_presence.rb', line 17

def minimum = settings.commits_body_presence_minimum

#valid?Boolean

Returns:

  • (Boolean)


10
11
12
13
14
15
# File 'lib/git/lint/analyzers/commit_body_presence.rb', line 10

def valid?
  return true if commit.fixup?

  valid_lines = commit.body_lines.grep_v(/^\s*$/)
  valid_lines.size >= minimum
end