Sha256: 5a1095bd48c93082cbfa853b495e237be440c296c784a6bc0b793f80706f453b

Contents?: true

Size: 747 Bytes

Versions: 3

Compression:

Stored size: 747 Bytes

Contents

# 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,
                     :ap].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

3 entries across 3 versions & 1 rubygems

Version Path
rubocop-0.45.0 lib/rubocop/cop/rails/output.rb
rubocop-0.44.1 lib/rubocop/cop/rails/output.rb
rubocop-0.44.0 lib/rubocop/cop/rails/output.rb