Class: Codeqa::Checkers::PatternChecker

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

Instance Attribute Summary

Attributes inherited from Codeqa::Checker

#errors, #sourcefile

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Codeqa::Checker

#initialize

Constructor Details

This class inherits a constructor from Codeqa::Checker

Class Method Details

.available?Boolean

Returns:

  • (Boolean)


11
12
13
# File 'lib/codeqa/checkers/pattern_checker.rb', line 11

def self.available?
  respond_to?(:pattern)
end

Instance Method Details

#checkObject



4
5
6
7
8
9
# File 'lib/codeqa/checkers/pattern_checker.rb', line 4

def check
  sourcefile.content.lines.each.with_index do |line, line_number|
    pos = (line =~ pattern)
    errors.add([line_number + 1, pos + 1], error_msg(line, line_number + 1, pos)) if pos
  end
end