Class: RuboCop::Cop::Platanus::NoFlashInApi

Inherits:
Base
  • Object
show all
Extended by:
AutoCorrector
Defined in:
lib/rubocop/cop/platanus/no_flash_in_api.rb

Overview

Flash shouldn’t be used in API controllers.

Examples:


# bad
class Api::Internal::ResourcesController < Api::Internal::BaseController
  def show
    flash[:notice] = 'Foo'
    ...
  end
end

# good
class Api::Internal::ResourcesController < Api::Internal::BaseController
  def show
    ...
  end
end

Constant Summary collapse

MSG =
"Don't use `flash` in API controllers."

Instance Method Summary collapse

Instance Method Details

#on_send(node) ⇒ Object



38
39
40
41
42
43
44
# File 'lib/rubocop/cop/platanus/no_flash_in_api.rb', line 38

def on_send(node)
  return unless flash?(node)

  add_offense(node) do |corrector|
    corrector.remove(node)
  end
end