Class: Greener::Linter

Inherits:
Object
  • Object
show all
Defined in:
lib/greener/linter.rb

Overview

Parse then lint a collection of .feature files for violations

Instance Method Summary collapse

Constructor Details

#initialize(config_path) ⇒ Linter

Returns a new instance of Linter.



8
9
10
11
12
# File 'lib/greener/linter.rb', line 8

def initialize(config_path)
  @config = ConfigStore.new(config_path).resolve
  @results = []
  @formatter_set = FormatterSet.new @config.formatters
end

Instance Method Details

#lintObject



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/greener/linter.rb', line 14

def lint
  @formatter_set.initialized(@config.files)
  @formatter_set.started

  # Here we iterate through a list of files, then iterate through the list of
  # desired checkers, passing each one the filename & parsed AST.
  # This is fine for now, but to speed this up we could refactor this to do a
  # single pass through the file, line-by-line, and flagging violations as
  # they are encountered.
  @config.files.each do |f|
    process_file(f) # TODO: move this to its own class
  end

  @formatter_set.finished @results
end