class Codeqa::Checkers::CheckYard
Public Class Methods
available?()
click to toggle source
# File lib/codeqa/checkers/check_yard.rb, line 9 def self.available? yard? end
check?(sourcefile)
click to toggle source
# File lib/codeqa/checkers/check_yard.rb, line 6 def self.check?(sourcefile) sourcefile.ruby? && !(sourcefile.filename =~ /^(test|spec)/) end
io()
click to toggle source
# File lib/codeqa/checkers/check_yard.rb, line 13 def self.io @@io ||= StringIO.new end
Private Class Methods
yard?()
click to toggle source
# File lib/codeqa/checkers/check_yard.rb, line 43 def self.yard? @loaded ||= begin require 'yard' ::YARD::Logger.instance(io) # replace YARD logger with io true rescue LoadError puts 'yard not installed' false end end
Public Instance Methods
check()
click to toggle source
# File lib/codeqa/checkers/check_yard.rb, line 25 def check if self.class.yard? ::YARD.parse_string(sourcefile.content) # let yard parse the file content io.rewind # rewind the io message = io.read warnings = message.match(/\A\[warn\]: /) errors.add(nil, message.gsub(/\(stdin\)/, sourcefile.filename)) if warnings end ensure io.reopen # clear the message for the next file end
hint()
click to toggle source
# File lib/codeqa/checkers/check_yard.rb, line 21 def hint 'Yard gives us some warnings on the file you can run <yardoc filename> to check yourself.' end
name()
click to toggle source
# File lib/codeqa/checkers/check_yard.rb, line 17 def name 'yard' end
Private Instance Methods
io()
click to toggle source
# File lib/codeqa/checkers/check_yard.rb, line 39 def io self.class.io end