Class: Git::Lint::Validators::RepeatedWord

Inherits:
Object
  • Object
show all
Defined in:
lib/git/lint/validators/repeated_word.rb

Overview

Validates content has no repeated words.

Constant Summary collapse

PATTERNS =
{
  word: /
    \w+(?=\s)         # Match word with trailing space.
    |                 # Or.
    (?<=\s)\w+(?=\s)  # Match word between two spaces.
    |                 # Or.
    (?<=\s)\w+        # Match word with leading space.
  /x,
  code_block: /`.+`/
}.freeze

Instance Method Summary collapse

Constructor Details

#initialize(patterns: PATTERNS) ⇒ RepeatedWord

Returns a new instance of RepeatedWord.



21
22
23
# File 'lib/git/lint/validators/repeated_word.rb', line 21

def initialize patterns: PATTERNS
  @patterns = patterns
end

Instance Method Details

#call(content) ⇒ Object



25
# File 'lib/git/lint/validators/repeated_word.rb', line 25

def call(content) = content ? scan(content) : Core::EMPTY_ARRAY