Class: Skeptic::Rules::CheckSyntax
- Inherits:
-
Object
- Object
- Skeptic::Rules::CheckSyntax
- Defined in:
- lib/skeptic/rules/check_syntax.rb
Constant Summary collapse
- DESCRIPTION =
'Check the syntax'
Instance Method Summary collapse
- #apply_to(code, tokens, sexp) ⇒ Object
-
#initialize(enabled = false) ⇒ CheckSyntax
constructor
A new instance of CheckSyntax.
- #name ⇒ Object
- #violations ⇒ Object
Constructor Details
#initialize(enabled = false) ⇒ CheckSyntax
Returns a new instance of CheckSyntax.
8 9 10 |
# File 'lib/skeptic/rules/check_syntax.rb', line 8 def initialize(enabled = false) @errors = [] end |
Instance Method Details
#apply_to(code, tokens, sexp) ⇒ Object
12 13 14 15 16 |
# File 'lib/skeptic/rules/check_syntax.rb', line 12 def apply_to(code, tokens, sexp) output, error, status = Open3.capture3 'ruby -c', stdin_data: code @errors << "Invalid syntax:\n#{error.gsub(/^/m, ' ')}" unless output.chomp == 'Syntax OK' self end |
#name ⇒ Object
22 23 24 |
# File 'lib/skeptic/rules/check_syntax.rb', line 22 def name 'Syntax check' end |
#violations ⇒ Object
18 19 20 |
# File 'lib/skeptic/rules/check_syntax.rb', line 18 def violations @errors end |