Class: OpenvoxLint::Checks

Inherits:
Object
  • Object
show all
Defined in:
lib/openvox-lint/checks.rb

Overview

Runs all enabled checks against a tokenised manifest.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(tokens:, manifest_lines:, fullpath:, configuration:) ⇒ Checks

Returns a new instance of Checks.



8
9
10
11
12
13
14
15
# File 'lib/openvox-lint/checks.rb', line 8

def initialize(tokens:, manifest_lines:, fullpath:, configuration:)
  @tokens         = tokens
  @manifest_lines = manifest_lines
  @fullpath       = fullpath
  @configuration  = configuration
  @problems       = []
  @ignore_comments = parse_ignore_comments
end

Instance Attribute Details

#problemsObject (readonly)

Returns the value of attribute problems.



6
7
8
# File 'lib/openvox-lint/checks.rb', line 6

def problems
  @problems
end

Instance Method Details

#runObject



17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/openvox-lint/checks.rb', line 17

def run
  OpenvoxLint.checks.each do |name, klass|
    next unless @configuration.check_enabled?(name)
    plugin = klass.new
    results = plugin.run(
      tokens: @tokens, manifest_lines: @manifest_lines,
      fullpath: @fullpath, ignore_comments: @ignore_comments,
    )
    @problems.concat(results)
    plugin.fix_problems if @configuration.fix && plugin.respond_to?(:fix_problems)
  end
  @problems.sort_by { |p| [p[:line] || 0, p[:column] || 0] }
end