Class: RuboCop::Cop::FactoryBot::IdSequence
- Inherits:
-
Base
- Object
- Base
- RuboCop::Cop::FactoryBot::IdSequence
- Extended by:
- AutoCorrector
- Includes:
- RangeHelp, FactoryBot::Language
- Defined in:
- lib/rubocop/cop/factory_bot/id_sequence.rb
Overview
Do not create a FactoryBot sequence for an id column.
Constant Summary collapse
- MSG =
'Do not create a sequence for an id attribute'
- RESTRICT_ON_SEND =
%i[sequence].freeze
Constants included from FactoryBot::Language
Instance Method Summary collapse
Methods included from FactoryBot::Language
Instance Method Details
#on_send(node) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/rubocop/cop/factory_bot/id_sequence.rb', line 27 def on_send(node) return unless node.receiver.nil? || factory_bot?(node.receiver) return unless node.first_argument&.sym_type? && node.first_argument.value == :id add_offense(node) do |corrector| range_to_remove = range_by_whole_lines( node.source_range, include_final_newline: true ) corrector.remove(range_to_remove) end end |