Class: Rubocop::Cop::Rails::Output
- Defined in:
- lib/rubocop/cop/rails/output.rb
Overview
This cop checks for the use of output calls like puts and print
Constant Summary collapse
- MSG =
'Do not write to stdout. Use Rails\' logger if you want to log.'
- BLACKLIST =
[:puts, :print, :p, :pp, :pretty_print]
Constants inherited from Cop
Instance Attribute Summary
Attributes inherited from Cop
#config, #corrections, #offences, #processed_source
Instance Method Summary collapse
Methods inherited from Cop
#add_offence, all, #autocorrect?, #convention, #cop_config, cop_name, #cop_name, cop_type, #debug?, #ignore_node, inherited, #initialize, lint?, #message, non_rails, rails?, style?, #support_autocorrect?, #warning
Constructor Details
This class inherits a constructor from Rubocop::Cop::Cop
Instance Method Details
#ignore_paths ⇒ Object
29 30 31 |
# File 'lib/rubocop/cop/rails/output.rb', line 29 def ignore_paths cop_config['Ignore'] end |
#matches_blacklist?(source) ⇒ Boolean
25 26 27 |
# File 'lib/rubocop/cop/rails/output.rb', line 25 def matches_blacklist?(source) ignore_paths.any? { |regex| source.buffer.name =~ /#{regex}/ } end |
#on_send(node) ⇒ Object
16 17 18 19 20 21 22 23 |
# File 'lib/rubocop/cop/rails/output.rb', line 16 def on_send(node) return if matches_blacklist?(processed_source) receiver, method_name, *_args = *node if receiver.nil? && BLACKLIST.include?(method_name) convention(node, :selector) end end |