class RuboCop::Cop::Discourse::FabricatorShorthand

fab!(:another_user) { Fabricate(:user) }
# good
fab!(:user) { Fabricate(:user, trust_level: TrustLevel) }
# good
@example
shorthand can’t be used.
When using custom attributes or the identifier doesn’t match, the
fab!(:user)
# good
fab!(:user) { Fabricate(:user) }
# bad
@example
name.
fabricator shorthand as long as the identifier matches the fabricator
When fabricating a record without custom attributes, we can use the

def message(expression)

def message(expression)
  "Use the fabricator shorthand: `#{expression}`"
end

def on_block(node)

def on_block(node)
  offending_fabricator?(node) do |expression, _identifier|
    add_offense(
      node,
      message: message(expression.source)
    ) do |corrector|
      next if part_of_ignored_node?(node)
      corrector.replace(node, expression.source)
    end
    ignore_node(node)
  end
end