Sha256: 1c7cae0a2d4799f78d04b6d46b7ec26963382b5a1d6a509d8902ad8b507e84de

Contents?: true

Size: 536 Bytes

Versions: 2

Compression:

Stored size: 536 Bytes

Contents

module Codeqa
  module Checkers
    class PatternChecker < Checker
      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

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

    private

      def pattern
        self.class.pattern
      end

      def error_msg(*_args)
        raise 'not implemented'
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
codeqa-0.3.1 lib/codeqa/checkers/pattern_checker.rb
codeqa-0.3.0 lib/codeqa/checkers/pattern_checker.rb