Class: OpenvoxLint::Linter
- Inherits:
-
Object
- Object
- OpenvoxLint::Linter
- Defined in:
- lib/openvox-lint/linter.rb
Overview
Orchestrates the linting of one or more manifest files.
Instance Attribute Summary collapse
-
#file_count ⇒ Object
readonly
Returns the value of attribute file_count.
-
#problems ⇒ Object
readonly
Returns the value of attribute problems.
Instance Method Summary collapse
- #errors? ⇒ Boolean
- #exit_code ⇒ Object
-
#initialize(configuration: OpenvoxLint.configuration) ⇒ Linter
constructor
A new instance of Linter.
- #run(*fileargs) ⇒ Object
- #warnings? ⇒ Boolean
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_count ⇒ Object (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 |
#problems ⇒ Object (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
20 21 22 |
# File 'lib/openvox-lint/linter.rb', line 20 def errors? @problems.any? { |p| p[:kind] == :error } end |
#exit_code ⇒ Object
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 = (fileargs.flatten) files.each { |f| lint_file(f) } @problems.sort_by! { |p| [p[:path] || '', p[:line] || 0, p[:column] || 0] } end |
#warnings? ⇒ Boolean
24 25 26 |
# File 'lib/openvox-lint/linter.rb', line 24 def warnings? @problems.any? { |p| p[:kind] == :warning } end |