Class: Git::Lint::Analyzers::CommitBodyPhrase

Inherits:
Abstract
  • Object
show all
Defined in:
lib/git/lint/analyzers/commit_body_phrase.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

rubocop:disable Metrics/MethodLength



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/git/lint/analyzers/commit_body_phrase.rb', line 8

def self.defaults
  {
    enabled: true,
    severity: :error,
    excludes: [
      "absolutely",
      "actually",
      "all intents and purposes",
      "along the lines",
      "at this moment in time",
      "basically",
      "each and every one",
      "everyone knows",
      "fact of the matter",
      "furthermore",
      "however",
      "in due course",
      "in the end",
      "last but not least",
      "matter of fact",
      "obviously",
      "of course",
      "really",
      "simply",
      "things being equal",
      "would like to",
      /\beasy\b/,
      /\bjust\b/,
      /\bquite\b/,
      /as\sfar\sas\s.+\sconcerned/,
      /of\sthe\s(fact|opinion)\sthat/
    ]
  }
end

Instance Method Details

#issueObject



48
49
50
51
52
53
54
55
# File 'lib/git/lint/analyzers/commit_body_phrase.rb', line 48

def issue
  return {} if valid?

  {
    hint: %(Avoid: #{filter_list.to_hint}.),
    lines: affected_commit_body_lines
  }
end

#valid?Boolean

rubocop:enable Metrics/MethodLength

Returns:

  • (Boolean)


44
45
46
# File 'lib/git/lint/analyzers/commit_body_phrase.rb', line 44

def valid?
  commit.body_lines.all? { |line| !invalid_line? line }
end