class Git::Lint::Runner

Attributes

branch[R]
collector[R]
configuration[R]

Public Class Methods

new(configuration:, branch: Branches::Feature.new, collector: Collector.new) click to toggle source
# File lib/git/lint/runner.rb, line 6
def initialize configuration:, branch: Branches::Feature.new, collector: Collector.new
  @configuration = configuration
  @branch = branch
  @collector = collector
end

Public Instance Methods

call(commits: branch.commits) click to toggle source
# File lib/git/lint/runner.rb, line 12
def call commits: branch.commits
  commits.map { |commit| check commit }
  collector
end

Private Instance Methods

check(commit) click to toggle source
# File lib/git/lint/runner.rb, line 21
def check commit
  configuration.map { |id, settings| load_analyzer id, commit, settings }
               .select(&:enabled?)
               .map { |analyzer| collector.add analyzer }
end
load_analyzer(id, commit, settings) click to toggle source
# File lib/git/lint/runner.rb, line 27
def load_analyzer id, commit, settings
  klass = Analyzers::Abstract.descendants.find { |descendant| descendant.id == id }
  fail Errors::Base, "Invalid analyzer: #{id}. See docs for supported analyzer." unless klass

  klass.new commit: commit, settings: settings
end