Class: RuboCop::Cop::Migrations::TruncateComponent
- Inherits:
-
Cop
- Object
- Cop
- RuboCop::Cop::Migrations::TruncateComponent
- Defined in:
- lib/primer/view_components/linters/migrations/truncate_component.rb
Overview
Lint & autocorrect Truncate components
Constant Summary collapse
- INVALID_MESSAGE =
<<~STR `Primer::Truncate` is deprecated. Please use `Primer::Beta::Truncate` instead! STR
Instance Method Summary collapse
Instance Method Details
#autocorrect(node) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/primer/view_components/linters/migrations/truncate_component.rb', line 30 def autocorrect(node) return if hash_with_inline_value?(node.arguments.first) lambda do |corrector| if node.arguments.first.nil? == false corrector.replace(node.children.first, "Primer::Beta::Truncate") corrector.insert_after(node.arguments.first, ", tag: :div") unless truncate_with_tag?(node.arguments.first) else corrector.replace(node.loc.expression, "Primer::Beta::Truncate.new(tag: :div)") end end end |
#on_send(node) ⇒ Object
24 25 26 27 28 |
# File 'lib/primer/view_components/linters/migrations/truncate_component.rb', line 24 def on_send(node) return unless truncate_component(node) add_offense(node, message: INVALID_MESSAGE) end |