Class: OpenvoxLint::Linter

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

Overview

Orchestrates the linting of one or more manifest files.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(configuration: OpenvoxLint.configuration) ⇒ Linter

Returns a new instance of Linter.



8
9
10
11
12
# File 'lib/openvox-lint/linter.rb', line 8

def initialize(configuration: OpenvoxLint.configuration)
  @config     = configuration
  @problems   = []
  @file_count = 0
end

Instance Attribute Details

#file_countObject (readonly)

Returns the value of attribute file_count.



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

def file_count
  @file_count
end

#problemsObject (readonly)

Returns the value of attribute problems.



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

def problems
  @problems
end

Instance Method Details

#errors?Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/openvox-lint/linter.rb', line 20

def errors?
  @problems.any? { |p| p[:kind] == :error }
end

#exit_codeObject



28
29
30
31
32
# File 'lib/openvox-lint/linter.rb', line 28

def exit_code
  return 1 if errors?
  return 1 if warnings? && @config.fail_on_warnings
  0
end

#run(*fileargs) ⇒ Object



14
15
16
17
18
# File 'lib/openvox-lint/linter.rb', line 14

def run(*fileargs)
  files = expand_files(fileargs.flatten)
  files.each { |f| lint_file(f) }
  @problems.sort_by! { |p| [p[:path] || '', p[:line] || 0, p[:column] || 0] }
end

#warnings?Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/openvox-lint/linter.rb', line 24

def warnings?
  @problems.any? { |p| p[:kind] == :warning }
end