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
- ALLOWED_TYPES =
%i[send csend block numblock].freeze
Instance Method Summary collapse
Instance Method Details
#on_send(node) ⇒ Object
42 43 44 45 46 47 48 49 50 51 |
# File 'lib/rubocop/cop/rails/output.rb', line 42 def on_send(node) return if ALLOWED_TYPES.include?(node.parent&.type) return if !output?(node) && !io_output?(node) range = offense_range(node) add_offense(range) do |corrector| corrector.replace(range, 'Rails.logger.debug') end end |