Class: Git::Lint::Analyzers::CommitBodyParagraphNewLine

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

Overview

Analyzes proper capitalization of commit body paragraphs.

Constant Summary collapse

PATTERN =
/
  \n      # New line.
  (?!     # Negative lookahead start.
  \s{1,}  # Indentation.
  |       # Or.
  \s*     # Optional whitespace.
  \#      # Comment character.
  )       # Negative lookahead end.
/mx

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

Constructor Details

#initialize(commit, pattern: PATTERN) ⇒ CommitBodyParagraphNewLine

Returns a new instance of CommitBodyParagraphNewLine.



18
19
20
21
# File 'lib/git/lint/analyzers/commit_body_paragraph_new_line.rb', line 18

def initialize(commit, pattern: PATTERN, **)
  super(commit, **)
  @pattern = pattern
end

Instance Method Details

#issueObject



25
26
27
28
29
30
31
32
# File 'lib/git/lint/analyzers/commit_body_paragraph_new_line.rb', line 25

def issue
  return {} if valid?

  {
    hint: "Avoid unnecessary new lines.",
    lines: affected_lines
  }
end

#valid?Boolean

Returns:

  • (Boolean)


23
# File 'lib/git/lint/analyzers/commit_body_paragraph_new_line.rb', line 23

def valid? = invalids.empty?