Sha256: 900de5a7da1ed7b5787084006013428e61545ed9e4a7b011d279df3aba23159d
Contents?: true
Size: 1.13 KB
Versions: 1
Compression:
Stored size: 1.13 KB
Contents
# frozen_string_literal: true module RuboCop module Cop module Platanus # Flash shouldn't be used in API controllers. # # @safety # Auto correction will delete any lines using `flash[:type] = 'foo'`. There might be cases # where using flash might be the intended behavior. # # @example # # # 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 # class NoFlashInApi < Base extend AutoCorrector MSG = "Don't use `flash` in API controllers." def_node_matcher :flash?, <<~PATTERN (send (send nil? :flash) :[]= ...) PATTERN def on_send(node) return unless flash?(node) add_offense(node) do |corrector| corrector.remove(node) end end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
rubocop-platanus-0.2.0 | lib/rubocop/cop/platanus/no_flash_in_api.rb |