Skip to content

Adjust `Cop/StaticTranslationDefinition` to allow `Constant = Struct.new` style definition

Currently Cop/StaticTranslationDefinition claims the following code is a violation:

SomeClass = Struct.new do
  def text
    _('Some translated text')
  end
end

x = SomeClass.new
x.text #=> 'Some translated text'

Whereas it is fine with the following form:

Struct.new('SomeClass') do
  def text
    _('Some translated text')
  end
end

x = Struct::SomeClass.new
x.text #=> 'Some translated text'
Edited by Dallas Reedy