Class: RuboCop::Cop::Rails::Output
- Inherits:
-
Base
- Object
- Base
- RuboCop::Cop::Rails::Output
- Extended by:
- AutoCorrector
- Includes:
- RangeHelp
- Defined in:
- lib/rubocop/cop/rails/output.rb
Overview
Checks for the use of output calls like puts and print
Constant Summary collapse
- MSG =
'Do not write to stdout. ' \ "Use Rails's logger if you want to log."
- RESTRICT_ON_SEND =
%i[ ap p pp pretty_print print puts binwrite syswrite write write_nonblock ].freeze
Instance Method Summary collapse
Instance Method Details
#on_send(node) ⇒ Object
44 45 46 47 48 49 50 51 52 |
# File 'lib/rubocop/cop/rails/output.rb', line 44 def on_send(node) return unless (output?(node) || io_output?(node)) && node.arguments? range = offense_range(node) add_offense(range) do |corrector| corrector.replace(range, 'Rails.logger.debug') end end |