Sha256: 7f68d4b186b65f3dfb9a1a6c730b9c4cfb729230b981d56afec641a5dd079bd8

Contents?: true

Size: 739 Bytes

Versions: 4

Compression:

Stored size: 739 Bytes

Contents

# encoding: utf-8
# frozen_string_literal: true

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.'.freeze

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

        def on_send(node)
          receiver, method_name, *args = *node
          return unless receiver.nil? &&
                        !args.empty? &&
                        BLACKLIST.include?(method_name)

          add_offense(node, :selector)
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rubocop-0.37.2 lib/rubocop/cop/rails/output.rb
rubocop-0.37.1 lib/rubocop/cop/rails/output.rb
rubocop-0.37.0 lib/rubocop/cop/rails/output.rb
rubocop-0.36.0 lib/rubocop/cop/rails/output.rb