Class: Codeqa::Checkers::CheckRubySyntax

Inherits:
Codeqa::Checker show all
Defined in:
lib/codeqa/checkers/check_ruby_syntax.rb

Instance Attribute Summary

Attributes inherited from Codeqa::Checker

#errors, #sourcefile

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Codeqa::Checker

available?, #initialize

Constructor Details

This class inherits a constructor from Codeqa::Checker

Class Method Details

.check?(sourcefile) ⇒ Boolean

Returns:

  • (Boolean)


5
6
7
# File 'lib/codeqa/checkers/check_ruby_syntax.rb', line 5

def self.check?(sourcefile)
  sourcefile.ruby?
end

Instance Method Details

#checkObject



17
18
19
20
21
22
# File 'lib/codeqa/checkers/check_ruby_syntax.rb', line 17

def check
  with_existing_file do |filename|
    command = "/usr/bin/env ruby -c '#{filename}' 1>/dev/null 2>/dev/null"
    errors.add(nil, 'Ruby syntax error') unless system(command)
  end
end

#hintObject



13
14
15
# File 'lib/codeqa/checkers/check_ruby_syntax.rb', line 13

def hint
  'Ruby can not parse the file, please check it for syntax errors.'
end

#nameObject



9
10
11
# File 'lib/codeqa/checkers/check_ruby_syntax.rb', line 9

def name
  'ruby syntax'
end