Module: AsciiChem::Linter
- Defined in:
- lib/asciichem/linter.rb,
lib/asciichem/linter/base.rb,
lib/asciichem/linter/registry.rb,
lib/asciichem/linter/diagnostic.rb,
lib/asciichem/linter/balance_check.rb,
lib/asciichem/linter/valence_check.rb,
lib/asciichem/linter/unclosed_ring_check.rb,
lib/asciichem/linter/isotope_sanity_check.rb,
lib/asciichem/linter/bracket_balance_check.rb,
lib/asciichem/linter/element_validation_check.rb
Overview
Linter framework. The parser is total — it accepts any syntactically valid input without judging chemistry correctness. The linter is a separate opt-in pass that walks the model and reports chemistry errors (unbalanced reactions, valence violations, etc.).
Checks register themselves via Linter.register(:name, Klass). The
registry is open for extension; adding a new check is a single new
file plus one autoload entry.
Defined Under Namespace
Modules: Registry Classes: BalanceCheck, Base, BracketBalanceCheck, Diagnostic, ElementValidationCheck, IsotopeSanityCheck, UnclosedRingCheck, ValenceCheck
Constant Summary collapse
- SEVERITIES =
%i[error warning info].freeze
Class Method Summary collapse
-
.errors?(formula) ⇒ Boolean
Convenience: returns true if any check produced an error.
-
.run(formula) ⇒ Object
Run all registered checks against the model.
Class Method Details
.errors?(formula) ⇒ Boolean
Convenience: returns true if any check produced an error.
32 33 34 |
# File 'lib/asciichem/linter.rb', line 32 def self.errors?(formula) run(formula).any? { |d| d.severity == :error } end |