Class: Git::Lint::Analyzers::CommitAuthorCapitalization

Inherits:
Abstract
  • Object
show all
Defined in:
lib/git/lint/analyzers/commit_author_capitalization.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, #invalid?, label, #severity, #warning?

Constructor Details

#initialize(commit:, settings: self.class.defaults, validator: Validators::Capitalization) ⇒ CommitAuthorCapitalization

Returns a new instance of CommitAuthorCapitalization.



14
15
16
17
# File 'lib/git/lint/analyzers/commit_author_capitalization.rb', line 14

def initialize commit:, settings: self.class.defaults, validator: Validators::Capitalization
  super commit: commit, settings: settings
  @validator = validator
end

Class Method Details

.defaultsObject



7
8
9
10
11
12
# File 'lib/git/lint/analyzers/commit_author_capitalization.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_author_capitalization.rb', line 23

def issue
  return {} if valid?

  {hint: %(Capitalize each part of name: "#{commit.author_name}".)}
end

#valid?Boolean

Returns:

  • (Boolean)


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

def valid?
  validator.new(commit.author_name).valid?
end