Class: FitCommit::Validators::Tense

Inherits:
Base
  • Object
show all
Defined in:
lib/fit_commit/validators/tense.rb

Constant Summary collapse

VERB_BLACKLIST =
%w(
  adds       adding       added
  allows     allowing     allowed
  amends     amending     amended
  bumps      bumping      bumped
  calculates calculating  calculated
  changes    changing     changed
  cleans     cleaning     cleaned
  commits    committing   committed
  corrects   correcting   corrected
  creates    creating     created
  darkens    darkening    darkened
  disables   disabling    disabled
  displays   displaying   displayed
  drys       drying       dryed
  ends       ending       ended
  enforces   enforcing    enforced
  enqueues   enqueuing    enqueued
  extracts   extracting   extracted
  finishes   finishing    finished
  fixes      fixing       fixed
  formats    formatting   formatted
  guards     guarding     guarded
  handles    handling     handled
  hides      hiding       hid
  increases  increasing   increased
  ignores    ignoring     ignored
  implements implementing implemented
  improves   improving    improved
  keeps      keeping      kept
  kills      killing      killed
  makes      making       made
  merges     merging      merged
  moves      moving       moved
  permits    permitting   permitted
  prevents   preventing   prevented
  pushes     pushing      pushed
  rebases    rebasing     rebased
  refactors  refactoring  refactored
  removes    removing     removed
  renames    renaming     renamed
  reorders   reordering   reordered
  requires   requiring    required
  restores   restoring    restored
  sends      sending      sent
  sets       setting
  separates  separating   separated
  shows      showing      showed
  skips      skipping     skipped
  sorts      sorting
  speeds     speeding     sped
  starts     starting     started
  supports   supporting   supported
  takes      taking       took
  tests      testing      tested
  truncates  truncating   truncated
  updates    updating     updated
  uses       using        used
)

Instance Attribute Summary

Attributes inherited from Base

#branch_name, #config

Instance Method Summary collapse

Methods inherited from Base

#enabled?, inherited, #initialize, #matches_branch?, #validate

Methods included from HasErrors

#add_error, #add_warning, #clear_errors, #clear_warnings, #errors, #merge_errors, #merge_warnings, #warnings

Constructor Details

This class inherits a constructor from FitCommit::Validators::Base

Instance Method Details

#starts_with_blacklisted_verb?(text) ⇒ Boolean

Returns:

  • (Boolean)


72
73
74
75
# File 'lib/fit_commit/validators/tense.rb', line 72

def starts_with_blacklisted_verb?(text)
  first_word = text.split.first(2).detect { |w| w =~ /\A\w/ }
  first_word && VERB_BLACKLIST.include?(first_word.downcase)
end

#validate_line(lineno, text) ⇒ Object



66
67
68
69
70
# File 'lib/fit_commit/validators/tense.rb', line 66

def validate_line(lineno, text)
  if lineno == 1 && starts_with_blacklisted_verb?(text)
    add_error(lineno, "Message must use imperative present tense.")
  end
end