Class: RuboCop::Cop::Brainfuck::Interpreter

Inherits:
RuboCop::Cop show all
Defined in:
lib/rubocop/cop/brainfuck/interpreter.rb

Overview

This cop check brainfuck program.

Constant Summary collapse

MSG =
'Interpreting the brainfuck code...'.freeze

Instance Method Summary collapse

Instance Method Details

#on_class(node) ⇒ Object



23
24
25
26
27
28
29
30
31
32
# File 'lib/rubocop/cop/brainfuck/interpreter.rb', line 23

def on_class(node)
  body = program?(node)
  return unless body

  pc = int_value(pc(body).first)
  code = code_value(code(body).first)
  return if code.size <= pc

  add_offense(node, :expression)
end