Sha256: ea637b8ab71da1853f088a0ee16ecd7ea35404ea8569eb0af24c6413da383de1

Contents?: true

Size: 618 Bytes

Versions: 5

Compression:

Stored size: 618 Bytes

Contents

# encoding: utf-8

module Rubocop
  module Cop
    module Rails
      # This cop checks for the use of output calls like puts and print
      class Output < Cop
        MSG = 'Do not write to stdout. Use Rails\' logger if you want to log.'

        BLACKLIST = [:puts,
                     :print,
                     :p,
                     :pp,
                     :pretty_print]

        def on_send(node)
          receiver, method_name, *_args = *node

          if receiver.nil? && BLACKLIST.include?(method_name)
            add_offense(node, :selector)
          end
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
rubocop-0.21.0 lib/rubocop/cop/rails/output.rb
rubocop-0.20.1 lib/rubocop/cop/rails/output.rb
rubocop-0.20.0 lib/rubocop/cop/rails/output.rb
rubocop-0.19.1 lib/rubocop/cop/rails/output.rb
rubocop-0.19.0 lib/rubocop/cop/rails/output.rb