Sha256: 3e830c587d226ed12c3b6bb3e54855c02a5e16f87b8fc013867aa55f685e3fb2

Contents?: true

Size: 598 Bytes

Versions: 10

Compression:

Stored size: 598 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's logger if you want to log.".freeze

        def_node_matcher :output?, <<-PATTERN
          (send nil {:ap :p :pp :pretty_print :print :puts} $...)
        PATTERN

        def on_send(node)
          output?(node) do |args|
            return if args.empty?

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

Version data entries

10 entries across 10 versions & 2 rubygems

Version Path
dirwatch-0.0.9 vendor/bundle/ruby/2.5.0/gems/rubocop-0.46.0/lib/rubocop/cop/rails/output.rb
dirwatch-0.0.8 vendor/bundle/ruby/2.5.0/gems/rubocop-0.46.0/lib/rubocop/cop/rails/output.rb
dirwatch-0.0.6 vendor/bundle/ruby/2.3.0/gems/rubocop-0.46.0/lib/rubocop/cop/rails/output.rb
dirwatch-0.0.5 vendor/bundle/ruby/2.3.0/gems/rubocop-0.46.0/lib/rubocop/cop/rails/output.rb
dirwatch-0.0.4 vendor/bundle/ruby/2.3.0/gems/rubocop-0.46.0/lib/rubocop/cop/rails/output.rb
dirwatch-0.0.3 vendor/bundle/ruby/2.3.0/gems/rubocop-0.46.0/lib/rubocop/cop/rails/output.rb
dirwatch-0.0.2 vendor/bundle/ruby/2.3.0/gems/rubocop-0.46.0/lib/rubocop/cop/rails/output.rb
rubocop-0.47.1 lib/rubocop/cop/rails/output.rb
rubocop-0.47.0 lib/rubocop/cop/rails/output.rb
rubocop-0.46.0 lib/rubocop/cop/rails/output.rb